MCP Chat CLI
A command-line chat interface that connects to an MCP server for reading and editing documents. It provides tools for document manipulation, resource access, and prompts for formatting and summarization.
README
MCP Chat CLI
A command-line chat interface that connects to an MCP server using the Anthropic API. Built while working through Anthropic's Introduction to Model Context Protocol course, extended with custom tools, resources, and prompts.
What this is
MCP (Model Context Protocol) is an open standard for connecting AI models to external tools and data sources. This project implements both sides of that connection — a FastMCP server that exposes documents as resources and defines tools for reading and editing them, and a client that connects to the server and makes those capabilities available inside a chat interface.
The server defines:
- Tools — read and edit documents
- Resources — list all documents or fetch a specific one by URI
- Prompts — reformat a document to markdown, or summarize its contents
The client implements the full MCP client session, including tool calls, resource reads, prompt retrieval, and command autocompletion.
What I worked through
Starting from a course starter pack, I implemented the missing pieces on both sides:
read_resource,list_prompts, andget_prompton the client- Resource endpoints (
docs://documentsanddocs://documents/{doc_id}) on the server - Two prompts (
formatandsummarize) that instruct the model to use the available tools
The main thing this project made concrete for me is the separation between the server (which defines what's available) and the client (which knows how to call it) — and how prompts are just structured messages that give the model a starting context, not magic.
Prerequisites
- Python 3.9+
- Anthropic API key
Setup
-
Clone the repo and navigate into the project folder.
-
Create a virtual environment and activate it:
uv venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # Mac/Linux
- Install dependencies:
uv pip install -e .
- Create a
.envfile in the project root:
ANTHROPIC_API_KEY="your-key-here"
- Run the app:
uv run main.py
Usage
Type a message to chat. Use @doc_id to include a document in your query, and /command to trigger a prompt. Tab autocompletes available commands.
> Tell me about @deposition.md
> /summarize report.pdf
> /format plan.md
To add your own documents, edit the docs dictionary in mcp_server.py.
Testing the server directly
mcp dev mcp_server.py
This opens the MCP Inspector in your browser where you can test tools, resources, and prompts without the chat interface.
Project structure
mcp_chat_cli/
├── main.py # entrypoint
├── mcp_server.py # FastMCP server — tools, resources, prompts
├── mcp_client.py # MCP client session wrapper
├── core/
│ ├── chat.py # chat loop logic
│ ├── claude.py # Anthropic API integration
│ ├── cli.py # CLI setup and input handling
│ ├── cli_chat.py # connects CLI and chat
│ └── tools.py # tool call handling
├── .env # API key (not committed)
└── pyproject.toml # dependencies
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。