cslylla

MCP Chat CLI

Community cslylla
Updated

MCP Chat CLI

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, and get_prompt on the client
  • Resource endpoints (docs://documents and docs://documents/{doc_id}) on the server
  • Two prompts (format and summarize) 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

  1. Clone the repo and navigate into the project folder.

  2. Create a virtual environment and activate it:

uv venv
.venv\Scripts\activate  # Windows
source .venv/bin/activate  # Mac/Linux
  1. Install dependencies:
uv pip install -e .
  1. Create a .env file in the project root:
ANTHROPIC_API_KEY="your-key-here"
  1. 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

MCP Server · Populars

MCP Server · New

    wallneradam

    Claude Auto-Approve MCP

    An MCP server to inject auto-approve MCP functionality into Claude Desktop

    Community wallneradam
    YV17labs

    ghostdesk

    Give any AI agent a full desktop — it sees the screen, clicks, types, and runs apps like a human. Automate anything with a UI: browsers, legacy software, internal tools. No API needed. One Docker command.

    Community YV17labs
    remotebrowser

    mcp

    Free your data

    Community remotebrowser
    Decodo

    Decodo MCP Server

    The Decodo MCP server which enables MCP clients to interface with services.

    Community Decodo
    kuberstar

    Qartez MCP

    Semantic code intelligence MCP server for Claude Code - project maps, symbol search, impact analysis, and more

    Community kuberstar