A simple Python chat application demonstrating MCP (Model Context Protocol) client-server architecture.
Built with FastMCP
- Client-Server Architecture: HTTP-based MCP server with CLI client
- Persistent Chat History: Messages stored in
.mcp-chatfile, persists across restarts - Auto-Refresh Client: New messages appear automatically without polling commands
- Message Numbering: Track which messages you've seen with message numbers
- MCP Tools: Four tools for chat operations (send, retrieve, count, sync)
- Human/Agent Distinction: Messages are tagged and displayed with visual indicators (👤 for humans, 🤖 for agents)
- FastMCP Powered: Built with modern, decorator-based MCP framework
- CLI Package: Installable via pip with global CLI commands
Install the package directly from GitHub:
pip install git+<this repository url>This will install the mcp-chat package and make the CLI commands mcp-chat-server and mcp-chat-client available globally.
If you prefer to run from source without installing:
pip install -r requirements.txt
python -m mcp_chat.server # Run server
python -m mcp_chat.client # Run clientThe MCP server runs in HTTP mode on localhost:8000:
mcp-chat-serverThe server will start and wait for client connections. It provides MCP tools that clients can use.
Features:
- Chat history is automatically saved to
.mcp-chatin the current working directory - History persists across server restarts
- Supports multiple concurrent client connections
The CLI client connects to a running MCP server:
mcp-chat-clientFeatures:
- Auto-loads the last 10 messages when connecting
- Automatically refreshes new messages every 2 seconds
- No commands needed - just type and send messages
- Press Ctrl+C to exit
You can optionally specify a custom server URL:
mcp-chat-client http://custom-server:8000/mcpThe server provides four MCP tools:
Send a message to the chat.
Parameters:
user(string, required): Username of the sendermessage(string, required): The message contentis_human(boolean, optional): Whether sender is human (default: false)
Example:
{
"user": "Agent",
"message": "Hello from the AI agent!",
"is_human": false
}Retrieve recent chat messages with message numbers.
Parameters:
count(number, optional): Number of messages to retrieve (default: 10)
Example:
{
"count": 5
}Get only new messages since a specific message number (useful for polling).
Parameters:
since(number, required): Message number to start from (exclusive). Must be 0 or greater.
Example:
{
"since": 5
}Get the total number of messages in chat history.
Returns: The current message count.
- Python 3.10 or higher
- FastMCP (
pip install fastmcp)