- LLM: 'gpt-oss:20b` running inside Ollama
- MCP library FastMCP
- LangChain Ollama Chat client to communicate with Ollama.
- Use
mitmproxyto intercept the communication between the - Use
uvinstead ofpip - Use Python 3.13 (3.14 has build error on some wheel of a dependency)
$ python3.13 -m venv .venv
$ uv pip install -r requirements.txt
...
$Start mitmproxy on terminal 2:
$ source .venv/bin/activate
(.venv) $ mitmproxy --mode reverse:http://localhost:11434 --listen-port 8080
< shows UI >Start add_client.py on terminal 1:
$ source .venv/bin/activate
(.venv) $ python add_client.py
2025-10-16 20:25:52,996 - mcp_use.telemetry.telemetry - INFO - Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable.
2025-10-16 20:25:52,996 - mcp_use - INFO - 🚀 Initializing MCP agent and connecting to services...
2025-10-16 20:25:52,996 - mcp_use - INFO - 🔌 Found 0 existing sessions
2025-10-16 20:25:52,996 - mcp_use - INFO - 🔄 No active sessions found, creating new ones...
[10/16/25 20:25:53] INFO Processing request of type ListToolsRequest server.py:664
INFO Processing request of type ListResourcesRequest server.py:664
INFO Processing request of type ListPromptsRequest server.py:664
2025-10-16 20:25:53,286 - mcp_use - INFO - ✅ Created 1 new sessions
INFO Processing request of type ListToolsRequest server.py:664
INFO Processing request of type ListResourcesRequest server.py:664
INFO Processing request of type ListPromptsRequest server.py:664
2025-10-16 20:25:53,291 - mcp_use - INFO - 🛠️ Created 1 LangChain tools from client
2025-10-16 20:25:53,292 - mcp_use - INFO - 🧰 Found 1 tools across all connectors
2025-10-16 20:25:53,292 - mcp_use - INFO - 🧠 Agent ready with tools: add
2025-10-16 20:25:53,294 - mcp_use - INFO - ✨ Agent initialization complete
2025-10-16 20:25:53,294 - mcp_use - INFO - 💬 Received query: 'Add the numbers 42 and 17. Always accept tools res...'
2025-10-16 20:25:53,294 - mcp_use - INFO - 🏁 Starting agent execution with max_steps=20
2025-10-16 20:25:53,294 - mcp_use - INFO - 👣 Step 1/20
[10/16/25 20:26:02] INFO Processing request of type CallToolRequest server.py:664
2025-10-16 20:26:02.614 | INFO | __main__:add:10 - Agent: Adding 42 and 17
2025-10-16 20:26:02,618 - mcp_use - INFO - 💭 Reasoning: Invoking: `add` with `{'number1': 42, 'number2': 17}`
2025-10-16 20:26:02,618 - mcp_use - INFO - 🔧 Tool call: add with input: {'number1': 42, 'number2': 17}
2025-10-16 20:26:02,618 - mcp_use - INFO - 📄 Tool result: [TextContent(type='text', text='59', annotations=None, meta=None)]
2025-10-16 20:26:02,618 - mcp_use - INFO - 👣 Step 2/20
2025-10-16 20:26:03,077 - mcp_use - INFO - ✅ Agent finished at step 2
2025-10-16 20:26:03,077 - mcp_use - INFO - 🎉 Agent execution complete in 10.081256866455078 seconds
Result: 59On terminal 2, check the see requests and responses between MCP host and the LLM for the two steps.
Example by smrati katiyar (6/30/2025).
Start mitmproxy on terminal 2:
$ source .venv/bin/activate
(.venv) $ mitmproxy --mode reverse:http://localhost:11434 --listen-port 8080
< shows UI >Start demo_client.py on terminal 1:
$ source .venv/bin/activate
(.venv) $ python demo_client.py
2025-10-16 20:28:45,116 - mcp_use.telemetry.telemetry - INFO - Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable.
2025-10-16 20:28:45,116 - mcp_use - INFO - 🚀 Initializing MCP agent and connecting to services...
2025-10-16 20:28:45,116 - mcp_use - INFO - 🔌 Found 0 existing sessions
2025-10-16 20:28:45,116 - mcp_use - INFO - 🔄 No active sessions found, creating new ones...
[10/16/25 20:28:45] INFO Processing request of type ListToolsRequest server.py:664
INFO Processing request of type ListResourcesRequest server.py:664
INFO Processing request of type ListPromptsRequest server.py:664
2025-10-16 20:28:45,412 - mcp_use - INFO - ✅ Created 1 new sessions
INFO Processing request of type ListToolsRequest server.py:664
INFO Processing request of type ListResourcesRequest server.py:664
INFO Processing request of type ListPromptsRequest server.py:664
2025-10-16 20:28:45,421 - mcp_use - INFO - 🛠️ Created 3 LangChain tools from client
2025-10-16 20:28:45,421 - mcp_use - INFO - 🧰 Found 3 tools across all connectors
2025-10-16 20:28:45,421 - mcp_use - INFO - 🧠 Agent ready with tools: generate_md5_hash, count_characters, get_first_half
2025-10-16 20:28:45,425 - mcp_use - INFO - ✨ Agent initialization complete
2025-10-16 20:28:45,425 - mcp_use - INFO - 💬 Received query: 'Compute md5 hash for following string: 'Hello, wor...'
2025-10-16 20:28:45,425 - mcp_use - INFO - 🏁 Starting agent execution with max_steps=20
2025-10-16 20:28:45,425 - mcp_use - INFO - 👣 Step 1/20
[10/16/25 20:28:47] INFO Processing request of type CallToolRequest server.py:664
2025-10-16 20:28:47.869 | INFO | __main__:generate_md5_hash:13 - Generating MD5 hash for: Hello, world!
2025-10-16 20:28:47,871 - mcp_use - INFO - 💭 Reasoning: Invoking: `generate_md5_hash` with `{'input_str': 'Hello, world!'}`
2025-10-16 20:28:47,871 - mcp_use - INFO - 🔧 Tool call: generate_md5_hash with input: {'input_str': 'Hello, world!'}
2025-10-16 20:28:47,871 - mcp_use - INFO - 📄 Tool result: [TextContent(type='text', text='6cd3556deb0da54bca060b4c39479839', annotations=None, meta=None)]
2025-10-16 20:28:47,871 - mcp_use - INFO - 👣 Step 2/20
[10/16/25 20:28:50] INFO Processing request of type CallToolRequest server.py:664
2025-10-16 20:28:50.664 | INFO | __main__:count_characters:25 - Counting characters in: 6cd3556deb0da54b
2025-10-16 20:28:50,665 - mcp_use - INFO - 💭 Reasoning: Invoking: `count_characters` with `{'input_str': '6cd3556deb0da54b'}`
2025-10-16 20:28:50,665 - mcp_use - INFO - 🔧 Tool call: count_characters with input: {'input_str': '6cd3556deb0da54b'}
2025-10-16 20:28:50,665 - mcp_use - INFO - 📄 Tool result: [TextContent(type='text', text='16', annotations=None, meta=None)]
2025-10-16 20:28:50,665 - mcp_use - INFO - 👣 Step 3/20
2025-10-16 20:28:54,551 - mcp_use - INFO - ✅ Agent finished at step 3
2025-10-16 20:28:54,551 - mcp_use - INFO - 🎉 Agent execution complete in 9.43472409248352 seconds
Result: The MD5 hash of the string **'Hello, world!'** is:
6cd3556deb0da54bca060b4c39479839
The first half of this hash is:
6cd3556deb0da54b
The number of characters in that first half is **16**.On terminal 2, check the see requests and responses between MCP host and the LLM for the 3 steps.
Interestingly, the LLM did not call the get_first_half tool, instead it determined the first half
the the MD5 hash itself.