Search⌘ K
AI Features

Building Single-Server MCP Architecture

Explore how to implement a single-server MCP architecture by building a complete agentic weather assistant. Learn to design the MCP server to handle live weather data and the client agent that uses LangGraph for reasoning. Understand the separation of concerns between the agent's brain and skills, and how to integrate API calls securely, manage tool definitions, and handle errors for robust AI application development.

Now that we have covered MCP’s core architecture, we will apply these concepts by building an agentic system. The project demonstrates how MCP’s client-server model works in an application by connecting an agent to a custom MCP tool.

Scenario: Building an intelligent weather assistant

Suppose we want to build a weather assistant. A standalone language model can explain meteorological concepts, but without access to a live weather service, it cannot reliably provide current conditions for a specific location. We will build an agent that answers queries such as “What’s the weather like in Tokyo?” by calling a live weather API through an external tool.

Implementing our agent

To achieve this, we’ll implement a complete client-server system using the MCP. This system will be powered by live data from OpenWeatherMap, a widely used weather data service that we will access via a secure API key.

Our architecture is intentionally decoupled, separating the agent logic from the external capability it invokes. This separation allows each component to be developed, tested, and maintained independently. We will build two components:

  • MCP server (The weather provider): This server acts as our dedicated “weather tool.” Its role is singular and focused: to encapsulate all the logic needed to communicate with the OpenWeatherMap API. It will expose a single, discoverable tool named get_weather. This tool will accept a location string as input, fetch the live weather data, and then process the complex JSON response from the API into a simple, clean dictionary. This abstracts all the complexity of the external API away from our agent.

  • MCP client (The agent brain): This client is the intelligent core of our application. Using the powerful LangChain and LangGraph libraries, it will function as a stateful agent. It will take a natural language query from the user (e.g., “What is the weather like in Tokyo?”), use the LLM to understand the user’s intent and decide that the get_weather tool is needed. It will then intelligently extract the “Tokyo” argument, send the tool call request to our server via MCP, and receive the structured weather data in response. Finally, it will pass this data back to the LLM to formulate a human-friendly answer for the user.

Single-server MCP architecture
Single-server MCP architecture

With the architecture defined, we can begin the implementation, starting with the MCP server that exposes the weather capability. ...