> ## Documentation Index
> Fetch the complete documentation index at: https://docs.platform.statista.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Build using Python FastMCP

> Connect the Statista MCP Server to a Python FastMCP Client

> [!NOTE]
>
> This guide requires an installation of Python and `fastmcp` library. If you do not know what that is; this guide is not intended for you.

**1. Ensure that FastMCP is installed**

Run `pip install fastmcp` and read the [FastMCP documentation](https://gofastmcp.com/getting-started/welcome).

```sh theme={null}
pip install fastmcp
```

**2. Set provided Statista configuration details**

```sh theme={null}
mcp_api_key = "<YOUR_API_KEY>"
mcp_server_url = "<PROVIDED_MCP_SERVER_URL>"
```

**3. Run example client**

```py theme={null}
from fastmcp import Client
from fastmcp.client.transports import StreamableHttpTransport

import asyncio
import json

mcp_client = Client(
    transport=StreamableHttpTransport(
        mcp_server_url,
        headers={"x-api-key": mcp_api_key},
    ),
)

async def main():
    async with mcp_client as client:
        # List available tools
        tools = await client.list_tools()

        # Call search-statistics with a natural language query
        statistics = await client.call_tool("search-statistics",
                                            {"query": "What's the GDP of Japan?"})
        print(json.loads(statistics.content[0].text))

        # grab the first statistic id
        grab_statistic_id = json.loads(statistics.content[0].text)["items"][0]["identifier"]

        # fetch chart data for a specific statistic id
        statistic_chart_data = await client.call_tool("get-chart-data-by-id",
                                            {"id": int(grab_statistic_id)})

        statistic_id = json.loads(statistic_chart_data.content[0].text)
        chart_data = statistic_chart_data.content[1].text

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.