Model Context Protocol (MCP) Server logo

Model Context Protocol (MCP) Server

by infinyte

The Model Context Protocol (MCP) Server provides a unified API for multiple AI model providers. It simplifies integration and management of various AI models within a single application.

View on GitHub

Last updated: N/A

What is Model Context Protocol (MCP) Server?

The MCP Server is a server implementation for the Model Context Protocol. It acts as a unified API layer, allowing developers to interact with multiple AI model providers (e.g., Anthropic, OpenAI) through a single, consistent interface.

How to use Model Context Protocol (MCP) Server?

To use the MCP Server, first clone the repository and install the dependencies using npm install. Then, run the interactive setup script (npm run setup) to configure API keys. Configure MongoDB using one of the provided options. Finally, start the server using npm start or one of the other startup options. Interact with the server through the API endpoints, such as /mcp/:provider for making requests to AI models and /tools/available for discovering available tools.

Key features of Model Context Protocol (MCP) Server

  • Unified API for multiple AI providers

  • Support for chat completions and legacy completions

  • Tool calling support

  • Context/system message handling

  • Environment-based configuration

  • MongoDB database for persistence and state management

  • Tool execution history and analytics

Use cases of Model Context Protocol (MCP) Server

  • Building AI-powered applications that leverage multiple AI models

  • Creating a consistent interface for interacting with different AI providers

  • Implementing tool calling functionality for AI models

  • Managing context and system messages for AI models

FAQ from Model Context Protocol (MCP) Server

How do I add a new AI provider?

Add the provider's SDK, create a handler function in server.js, and add a case in the main route handler.

How do I add a new tool?

Create a new tool implementation in /src/tools, add the tool definition to tool-definitions.js, update the tool execution functions in server.js, and add new API endpoints if needed.

What API keys do I need to configure?

You need API keys for the AI providers you want to use (e.g., ANTHROPIC_API_KEY, OPENAI_API_KEY). You may also need keys for web search (GOOGLE_CSE_API_KEY, GOOGLE_CSE_ID, BING_SEARCH_API_KEY) and image generation (STABILITY_API_KEY).

How do I run the server in production?

Use the PM2 process manager with the npm run pm2:start:prod command. This ensures the server restarts automatically if it crashes and is optimized for production environments.

How do I discover available tools?

Use the GET /tools/available endpoint. It supports multiple formats (JSON, YAML, HTML) and provides filtering by category, provider, and search terms.