๐ฅ๏ธ MCP Terminal Chat Client
April 13, 2025 ยท View on GitHub
A terminal-based interactive chat client for communicating with Model Context Protocol (MCP) servers using Anthropic's Claude models.
Designed for developers building and testing tools via the MCP spec.
๐ก Features
- ๐งโ๐ป Terminal chat interface with Claude
- ๐ Auto-discovers tools from an MCP server
- ๐งฐ Executes Claude's
tool_usecalls live - โ Validates tool inputs via JSON Schema
- ๐ชต Full structured logging and debugging
- ๐ Multi-turn conversation loop with memory
- ๐ File Attachments for Images and PDF
โ๏ธ Requirements
- Python 3.11+
- MCP tool server (conforming to the spec)
.envfile with Anthropic API key
๐ฆ Python Packages
Install with uv (recommended) or pip:
uv pip install -r requirements.txt
# or
pip install -r requirements.txt
Dependencies:
anthropicanyiomcppython-dotenvjsonschema
๐งพ Configuration
๐ llm_config.json
{
"provider": "anthropic",
"model": "claude-3-haiku-20240307"
}
โ๏ธ mcp_servers.json
{
"mcpServers": {
"default": {
"command": "python",
"args": ["-m", "your_mcp_tool_server"],
"env": {
"MY_ENV_VAR": "value"
}
}
}
}
๐ .env
ANTHROPIC_API_KEY=your-api-key-here
๐งช Usage
Run with default config:
python main.py
Custom configs:
python main.py --llm_config custom_llm_config.json --mcp_config custom_mcp_servers.json
๐ฌ Conversation Flow
- You send a prompt in terminal
- Claude replies with text or
tool_useblocks - MCP client validates and calls the appropriate tool
- Tool results are returned to Claude
- Claude completes the response
All without leaving your terminal.
๐ File Attachments
You can attach PDF and image files (.png, .jpg, .webp) to your prompt using the --file flag.
These files will be sent to Claude along with your message using base64 encoding and the correct MIME type.
๐ผ๏ธ Supported Types
application/pdfimage/pngimage/jpegimage/webp
๐ Example Usage
python main.py --file ./sample.pdf
๐ Tool Handling
- Tools are discovered via
tools/list - Input schemas are parsed and validated
- Tool outputs must return a string (per Claude API)
- Errors are passed back as strings with
content
๐ Troubleshooting
- Make sure
ANTHROPIC_API_KEYis in.env - Set log level to
DEBUGfor full trace - If Claude throws 400 errors:
- Ensure
tool_result.contentis a string - Validate tool inputs match declared schema
- Ensure
๐ TODO
- Support OpenAI, VertexAI
- Vendor-agnostic LLM integration
- SSE support
- Packaging
- Add tests and CLI improvements