This is a demo project showing how to create an MCP client with a local LLM in both Python and TypeScript.
It also demonstrates how to configure an MCP server in Python (with FastAPI) and in TypeScript.
The workflow is as follows:
- The MCP client requests a list of available tools from the MCP server.
- The local LLM decides which tool to use based on the given prompt.
- If a tool is selected, the client calls the tool on the server and returns the result.
All combinations of clients in {Python, TypeScript} and servers in {Python, TypeScript} are supported.
For the demo, a small, lightweight model is used.
I selected a model that returns tool arguments in the correct data types instead of as strings.
For example:
❌ Problem with some models (e.g., llama3.2):
{"a":"4","b":"8"}✅ Desired output:
{"a":4,"b":8}This avoids having to manually parse and convert argument values.
Pull the model with (requires OLLAMA):
ollama pull gwen3:1.7bMake sure an MCP server is running locally at
http://localhost:8000/mcp.
For the demo, the prompt used is:
What is 45432542 plus 87468748?
cd client/py
pip install -r requirements.txt
python mcp_client.pyExample output:
Available tools: ['root__get', 'add', 'multiply']
Tool: add
Args: {'a': 45432542, 'b': 87468748}
Tool output: {
"operation": "add",
"a": 45432542,
"b": 87468748,
"result": 132901290
}cd client/ts
npm install
npm run startExample output:
Available tools: [ 'root__get', 'add', 'multiply' ]
Tool: add
Args: {"a":45432542,"b":87468748}
Tool output: {
"operation": "add",
"a": 45432542,
"b": 87468748,
"result": 132901290
}This example shows how to add MCP endpoints to an existing FastAPI application.
cd server/py
pip install -r requirements.txt
python mcp_server.pycd server/ts
npm installFirst start the math API (runs on http://localhost:3333):
npm run apiThen start the MCP server:
npm run mcpIn this TypeScript approach, tools need to be defined manually.
Currently, there is no direct equivalent to FastAPI-MCP in the TypeScript ecosystem.