A command-line AI chat application that lets you interact with documents using Claude. Built on the MCP (Model Context Protocol) architecture, it connects an AI-powered chat interface to a document server that exposes tools, resources, and prompt templates.
mcpChat implements the complete MCP architecture — a custom MCP server that exposes tools, resources, and prompt templates, paired with a custom MCP client that connects to it over stdio transport. The client feeds retrieved context into a Claude-powered conversational loop, all surfaced through a rich terminal interface.
Built using FastMCP, the server exposes three categories of MCP primitives:
- Tools —
read_documentandedit_documentallow Claude to read and modify documents during a conversation - Resources — URI-addressable endpoints (
docs://documents,docs://documents/{doc_id}) that the client can fetch directly - Prompts — reusable prompt templates (e.g.
format) that inject structured instructions into the message history
A custom MCPClient class manages the full lifecycle of an MCP session:
- Spawns the server as a subprocess and connects via stdio transport
- Initializes and holds a
ClientSessionfor the duration of the app - Exposes typed methods for
list_tools,call_tool,list_prompts,get_prompt, andread_resource
Multiple MCP clients can be registered simultaneously, enabling tool aggregation across servers.
- Document-aware chat — reference any document in your query using
@filenameand its content is automatically injected as context - Slash commands — run predefined prompt templates (e.g.
/format report.pdf) directly from the CLI - Tab completion — autocomplete for
@documentsand/commandspowered byprompt_toolkit - Multi-server support — pass additional MCP server scripts as CLI arguments to extend available tools
The app runs two components side by side:
- MCP Server — manages a document store and exposes
read_documentandedit_documenttools, document resources, and prompt templates - MCP Client + Claude — the CLI connects to the server over stdio, retrieves context, and sends messages to the Anthropic API
When you type a message, the app resolves any @document references, builds a context-aware prompt, and streams the response from Claude back to the terminal.
- Create a
.envfile in the project root:
ANTHROPIC_API_KEY="your-api-key"
CLAUDE_MODEL="claude-sonnet-4-6"
- Install dependencies and run:
uv venv
source .venv/bin/activate
uv pip install -e .
uv run main.pyNaveen Soni