About MCP Client
MCP Client is a Python client for chatting with Claude 3.5 Sonnet and processing tool-based queries. It supports a command-line interface and a Chainlit UI, with PostgreSQL access through MCP.
Key features
- 01Claude 3.5 Sonnet chat
- 02Command-line and Chainlit interfaces
- 03PostgreSQL access through MCP
- 04Python and JavaScript MCP servers
Use cases
- 01Chatting with Claude through a CLI
- 02Using a web UI for database queries
- 03Running tool-based queries against PostgreSQL
MCP support
The client connects to MCP servers, including the PostgreSQL MCP server, and supports both Python and JavaScript server implementations.
Details
From the project READMEMCP Client
A Python client implementation for the Model Context Protocol (MCP) that integrates with Claude 3.5 Sonnet.
Prerequisites
- Python 3.12 or higher
- PostgreSQL database
- Node.js (for running the PostgreSQL MCP server)
uvpackage manager (recommended) orpip
Installation
-
Clone the repository:
-
Create and activate a virtual environment:
# Create virtual environment
uv venv
# Activate virtual environment
# On Windows:
.venv\Scripts\activate
# On Unix or MacOS:
source .venv/bin/activate
- Install dependencies
# For python equivalent of:
# Install required packages
uv add mcp anthropic python-dotenv chainlit asyncpg
# or install from requirements.txt
# For node:
npm init
npm install @modelcontextprotocol/server-postgres
- Create a
.envfile in the project root and add your Anthropic API key:
ANTHROPIC_API_KEY=your_api_key_here
Usage
The client can be run in two modes:
- Command Line Interface:
uv run client.py <path-to-mcp-server> <database-url>
For example:
uv run client.py ./node_modules/@modelcontextprotocol/server-postgres/dist/index.js postgresql://localhost/your_database
- UI with Chainlit For first time setup:
- Create a db in postgres with name
chat_history - initialise tables in db by running
init_db.py.bash python app/init_db.py
To start chainlit run:
chainlit run app/chainlit_app.py
Where:
<path-to-mcp-server>is the path to the MCP server JavaScript file<database-url>is your PostgreSQL connection string
Once running, you can interact with the client through the command line interface. Type your queries and type 'quit' to exit.
Features
- Interactive chat interface with Claude 3.5 Sonnet
- Integration with PostgreSQL database through MCP
- Support for both Python and JavaScript MCP servers
- Tool-based query processing
Development
The project uses:
anthropicfor Claude API integrationmcpfor Model Context Protocol implementationpython-dotenvfor environment variable management
License
MIT License
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.