GoPenAI

Where the ChatGPT community comes together to share insights and stories.

Follow publication

Member-only story

Understanding MCP Architecture: Single-Server vs Multi-Server Clients

Rajat Nigam
GoPenAI
Published in
4 min readApr 1, 2025

--

Modern AI-driven applications require efficient and scalable architectures to interact with multiple external services. The Multi-Client Protocol (MCP) provides a robust framework to communicate with various tool servers, enabling seamless interaction between AI models and external computations. In this blog, we’ll explore the advantages of MCP architecture by comparing single-server and multi-server clients.

Photo credit: Dr. Jennifer Howes (@jhowesuk) — New Delhi, 1995. View of Connaught Place with Jami Masjid visible in the background.

Math Server (math_server.py)

The Math Server acts as an MCP tool server that provides basic mathematical operations like addition and multiplication. It listens for incoming requests, processes tool invocations, and responds with results.

Code Breakdown

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("Math")

@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b

@mcp.tool()
def multiply(a: int, b: int) -> int:
"""Multiply two numbers"""
return a * b

if __name__ == "__main__":
mcp.run(transport="stdio")
  • Defines an MCP server named Math.
  • Registers add(a, b) and multiply(a, b) as available tools.
  • Runs with stdio transport, allowing communication via standard input/output.

Single-Server Client

A single-server client connects to one MCP server, which exposes a set of tools to be used in computations. Let’s analyze the single_server_client.py script, which interacts with math_server.py to perform mathematical operations.

How It Works

  1. Start the Math Server: The math_server.py runs as an MCP server exposing two tools: add(a, b) and multiply(a, b).
  2. Initialize a Stdio Connection: The client creates a subprocess to communicate with the math server via stdio transport.
  3. Load Available Tools: The client fetches the available tools (add, multiply) from the server.
  4. Invoke AI Model: The AI model, GPT-4o, uses LangGraph’s ReAct (Reasoning + Acting) agent to decide how to solve the given mathematical expression.
  5. Perform Computation: The model generates tool calls…

--

--

Published in GoPenAI

Where the ChatGPT community comes together to share insights and stories.

Written by Rajat Nigam

I'm a lifetime student of software engineering. Professionally I work in the capacity of Individual Contributor, Trainer, Lead Engineer and an Architect.

No responses yet

Write a response