Sponsored by Deepsite.site

MCPchat

Created By
postfix8 months ago
MCPchat is terminal-based LLM chat client supporting multiple Model Context Protocol (MCP) servers with real-time server management and dynamic model switching.
Content

MCPchat

MCPchat is terminal-based LLM chat client supporting multiple Model Context Protocol (MCP) servers with real-time server management and dynamic model switching.

MCPChat

A powerful terminal-based chat application that connects to multiple Model Context Protocol (MCP) servers, enabling seamless interaction with various LLM providers through a unified interface.

Node.js Version TypeScript

Features

  • 🌐 Multi-Server Support: Connect to multiple MCP servers simultaneously
  • 🔄 Dynamic Model Switching: Switch between different models and servers on the fly
  • Supported models: Gemini, OpenAI, Local ollama
  • 🔍 Real-time Health Monitoring: Automatic server health checks and status updates
  • 💾 Session Management: Maintain chat history and context across conversations
  • 🎨 Interactive CLI: User-friendly terminal interface with color-coded messages
  • 🛡️ Type Safety: Full TypeScript support with Zod schema validation
  • 📝 Comprehensive Logging: Detailed logging system for debugging and monitoring

Prerequisites

  • Node.js >= 18.0.0
  • npm or yarn
  • Access to one or more MCP servers

Installation

# Clone the repository
git clone https://github.com/postfix/mcpchat.git
cd mcpchat

# Install dependencies
npm install

# Copy environment file and configure
cp .env.example .env

# Build the project
npm run build

Configuration

Edit the .env file with your MCP server details and API keys:

# MCP Server Configurations
MCP_SERVER_1_URL=http://localhost:8080
MCP_SERVER_1_NAME=local-ollama
MCP_SERVER_1_API_KEY=optional_key_1

MCP_SERVER_2_URL=http://remote-server:8080
MCP_SERVER_2_NAME=remote-mcp
MCP_SERVER_2_API_KEY=optional_key_2

# Logging
LOG_LEVEL=info

Usage

Start the application:

npm start

Available Commands

  • /switch - Switch to a different server or model
  • /clear - Clear chat history
  • /status - Show current connection status
  • /help - Display available commands
  • /exit - Exit the application

Development

# Run in development mode
npm run dev

# Run linting
npm run lint

# Run tests
npm run test

Project Structure

mcpchat/
├── src/
│ ├── config/ # Configuration management
│ ├── mcp/ # MCP server handling
│ ├── chat/ # Chat session management
│ ├── utils/ # Utilities and helpers
| ├── cli/ # CLI interface
│ └── index.ts # Application entry point
├── tests/ # Test files
├── .env.example # Example environment variables
├── .gitignore # Git ignore rules
├── package.json # Project dependencies
└── tsconfig.json # TypeScript configuration

Architecture

MCPChat is built with a modular architecture focusing on:

  • Server Management: Handles connections to multiple MCP servers with real-time health monitoring
  • Chat Sessions: Manages conversation context and history
  • CLI Interface: Provides an intuitive terminal-based user interface
  • Configuration: Handles environment-based configuration with validation
  • Logging: Comprehensive logging system for debugging and monitoring

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Error Handling

The application includes comprehensive error handling:

  • Server connection failures
  • API response errors
  • Configuration validation
  • Runtime errors

All errors are logged and displayed appropriately in the CLI.

Logging

Logs are stored in:

  • error.log - Error-level messages
  • combined.log - All log messages

Log levels can be configured in the .env file.

Security

  • API keys are stored in environment variables
  • Server connections use secure protocols
  • No sensitive data is logged

License

This project is licensed under the BSD-3 License

Acknowledgments

Support

For support, please open an issue in the GitHub repository or contact the maintainers.


Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Amap Maps高德地图官方 MCP Server
CursorThe AI Code Editor
Playwright McpPlaywright MCP server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
WindsurfThe new purpose-built IDE to harness magic
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Tavily Mcp
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
ChatWiseThe second fastest AI chatbot™
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
DeepChatYour AI Partner on Desktop
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Serper MCP ServerA Serper MCP Server
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code