MCP Client

In shortConnect to MCP servers with FastMCP Client, list remote tools, inspect metadata, and invoke tools directly.

  • 2 min read
  • 13 sections
  • Updated
  • v0.9.2
  • Markdown

Source example: examples/react-mcp/client.py

What you will build

A standalone MCP client that connects to a weather server, lists the remote tools it exposes, inspects their metadata, and calls get_weather.

Prerequisites

  • Python 3.12 or later
  • fastmcp installed
  • the MCP server from the previous tutorial running locally

Install:

Terminal
pip install fastmcp

Start the server in another terminal:

Terminal
python examples/react-mcp/server.py

Step 1 — Define the MCP server config

The client uses a config object keyed by server name:

Python
config = {
    "mcpServers": {
        "weather": {
            "url": "http://127.0.0.1:8000/mcp",
            "transport": "streamable-http",
            "headers": {"Authorization": "Bearer TEST_WEATHER_API_KEY"},
        },
    },
}

This config tells the client:

  • which server to connect to
  • which transport to use
  • which headers to send

Step 2 — Create the client

Python
from fastmcp import Client

client_http = Client(config)

The client manages MCP connections with async context management.

Step 3 — List tools

The example calls list_tools() and reads metadata:

Python
from mcp import Tool

async def call_tools():
    async with client_http:
        tools: list[Tool] = await client_http.list_tools()
        for i in tools:
            meta = i.meta or {}
            tags = meta.get("_fastmcp", {}).get("tags", [])
            print(f"Tool: {i.name}, Tags: {tags}")
            print(i.model_dump())

This is useful when you want to:

  • inspect what a server can do
  • build a UI for available tools
  • filter tools by server-side metadata

Discovery and invocation flow

sequenceDiagram
    participant App
    participant Client as FastMCP Client
    participant Server as MCP server

    App->>Client: list_tools()
    Client->>Server: MCP list tools request
    Server-->>Client: tool schemas + metadata
    Client-->>App: Tool objects
    App->>Client: call_tool("get_weather", {...})
    Client->>Server: MCP tool invocation
    Server-->>Client: structured result
    Client-->>App: CallToolResult

Step 4 — Invoke a tool directly

The example then calls get_weather:

Python
async def invoke():
    async with client_http:
        result = await client_http.call_tool(
            "get_weather",
            {
                "location": "New York",
            },
        )
        print(result)

You get a structured MCP result rather than a plain string. That result may contain:

  • human-readable content
  • structured JSON content
  • error flags

Example run

Python
async def main():
    await call_tools()
    await invoke()

if __name__ == "__main__":
    asyncio.run(main())

Run it:

Terminal
python examples/react-mcp/client.py

Expected output:

  • one or more tool definitions from the server
  • a successful CallToolResult for get_weather

How this relates to 10xGraph

This page shows raw MCP usage without a graph. 10xGraph builds on the same idea by plugging an MCP client into ToolNode, which lets an agent call these tools as part of a graph run.

That is the next tutorial:

Common mistakes

  • Not starting the MCP server first.
  • Pointing the client at the wrong URL or transport.
  • Forgetting auth headers when the server requires them.
  • Expecting direct Python return values instead of MCP response objects.

Key concepts

Concept Details
Client(config) Connects to one or more MCP servers
list_tools() Discovers remote tools and their schemas
call_tool(name, args) Invokes a remote MCP tool directly
meta Metadata block that can include tags and server-specific hints

What you learned

  • How to configure an MCP client.
  • How to discover remote tool schemas.
  • How to invoke a remote tool without 10xGraph orchestration.

Next step

→ MCP ReAct Agent to let an 10xGraph graph call those MCP tools automatically.

Last updated for v0.9.2Edit this page on GitHubReport an issue