What is Model Context Protocol (MCP) Server?
A modular server implementing the Model Context Protocol for AI services, supporting multiple transport options (stdio, TCP, WebSocket) and dynamic AI service selection (Claude, OpenAI, mock). It is built with SOLID principles for maintainability and extensibility, and is intended for developers building AI-powered tools and applications.
How to use Model Context Protocol (MCP) Server?
Install by cloning the repository, creating a virtual environment, and running pip install -e .. Configure API keys in the .env file (or via command‑line flags). Run with python mcp_server.py for stdio mode, add --tcp for TCP mode, or --websocket for WebSocket mode. Example clients are provided in the examples/ directory.
Key features of Model Context Protocol (MCP) Server
- Multiple AI services: Claude, OpenAI, and mock.
- Dynamic per‑request AI service selection.
- Three transport modes: stdio, TCP, and WebSocket.
- Compliant JSON‑RPC 2.0 interface.
- Real‑time response streaming for supported transports.
- Easy extension with custom handlers, services, and transports.
Use cases of Model Context Protocol (MCP) Server
- Command‑line AI assistants using stdio transport.
- Network‑based AI tools (e.g., chatbots) over TCP.
- Real‑time browser applications via WebSocket.
- Testing AI integrations without external API calls (mock service).
- Multi‑service AI systems that switch between providers per query.
评论