About MCP Client
MCP Client is a TypeScript client for connecting language models to external MCP server tools and services. It supports OpenAI and Anthropic models, simultaneous server connections, and platform-specific command handling.
Key features
- 01Connect to multiple MCP servers
- 02Support OpenAI and Anthropic models
- 03Cross-platform operation
- 04Adjust commands for each platform
- 05Configure environment variables
Use cases
- 01Connect a language model to several MCP servers
- 02Run configured servers on Windows, macOS, or Linux
MCP support
The client reads server commands, arguments, and optional environment variables from an MCP configuration file, then connects to the configured MCP servers.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEMCP Client
A TypeScript client for the Model Context Protocol (MCP) that enables communication between language models and external MCP server tools/services.
Overview
This MCP client provides a flexible interface for connecting to various MCP servers, allowing language models like OpenAI's GPT and Anthropic's Claude to access external tools and services through a standardized protocol. The client supports multiple server types and handles cross-platform compatibility.
Features
- Connect to multiple MCP servers simultaneously
- Support for both OpenAI and Anthropic language models
- Cross-platform compatibility (Windows, macOS, Linux)
- Automatic handling of platform-specific commands
- Configurable environment variables
Prerequisites
- Node.js (v16+)
- npm or yarn
- TypeScript
Installation
-
Clone the repository:
git clone https://github.com/kamusis/mcp-client.git cd mcp-client -
Install dependencies:
npm install -
Create a
.envfile in the project root with your API keys:# LLM (OPENAI or ANTHROPIC) LLM=OPENAI OPENAI_MODEL=gpt-4o ANTHROPIC_MODEL=claude-3-5-sonnet-20241022 # LLM API Key ANTHROPIC_API_KEY=your_anthropic_api_key OPENAI_API_KEY=your_openai_api_key # MCP Configuration File Path (optional, defaults to ./mcp_config.json) # MCP_CONFIG_PATH=./mcp_config.json -
Configure your MCP servers in
mcp_config.json:{ "mcpServers": { "sequential-thinking": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-sequential-thinking" ] }, "postgres-full-localhost-dev": { "command": "node", "args": [ "/path/to/mcp-postgres-full-access-extended/dist/index.js", "postgresql://postgres:[email protected]:5432/postgres" ], "env": { "TRANSACTION_TIMEOUT_MS": "60000", "MAX_CONCURRENT_TRANSACTIONS": "20", "PG_STATEMENT_TIMEOUT_MS": "30000" } } } }
Building and Running
-
Build the project:
npm run build -
Run the client:
node build/index.js
Configuration
Environment Variables
LLM: The language model provider to use (OPENAIorANTHROPIC)OPENAI_MODEL: The OpenAI model to use (e.g.,gpt-4o)ANTHROPIC_MODEL: The Anthropic model to use (e.g.,claude-3-5-sonnet-20241022)ANTHROPIC_API_KEY: Your Anthropic API keyOPENAI_API_KEY: Your OpenAI API keyMCP_CONFIG_PATH: Path to the MCP configuration file (optional, defaults to./mcp_config.json)
MCP Server Configuration
The mcp_config.json file defines the MCP servers to connect to. Each server entry includes:
command: The command to run the serverargs: Arguments to pass to the commandenv: Environment variables for the server (optional)
Cross-Platform Compatibility
The client automatically handles platform-specific differences:
- On Windows,
npxcommands are adjusted to usenpx.cmd - Python commands are adjusted based on the platform (
pythonon Windows,python3on Unix-like systems) - Environment variables are properly passed to child processes
License
MIT
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.