Integrations
Enables environment-based configuration of API keys and server settings through .env file management
Supports development mode with automatic server reloading when code changes are detected
Provides access to OpenAI models (GPT) and DALL-E image generation through a unified API, supporting chat completions, legacy completions, and tool calling
Model Context Protocol (MCP) Server
A simple server implementation for the Model Context Protocol that provides a unified API for multiple AI model providers.
Features
- Unified API for multiple AI providers (Anthropic, OpenAI)
- 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
Installation
The setup script will guide you through configuring the necessary API keys:
ANTHROPIC_API_KEY
- For Claude modelsOPENAI_API_KEY
- For GPT models and DALL-E image generationSTABILITY_API_KEY
- For Stable Diffusion image generationGOOGLE_CSE_API_KEY
andGOOGLE_CSE_ID
- For web search functionalityBING_SEARCH_API_KEY
- For fallback web search
You can also manually edit the .env
file if you prefer.
MongoDB Setup
The MCP server uses MongoDB for data persistence. You have several options for setting up MongoDB:
Option 1: Automated Setup (Recommended)
Run the MongoDB setup script, which will guide you through the process:
This script will:
- Check if Docker is available
- Start MongoDB using Docker Compose (if available)
- Configure the connection in your .env file
- Verify the MongoDB connection
Option 2: Manual Docker Setup
The easiest way to get started with MongoDB is to use the included Docker Compose configuration:
MongoDB will be available at mongodb://mcpuser:mcppassword@localhost:27017/mcp-server
Mongo Express (web admin) will be available at http://localhost:8081
Option 3: Local MongoDB Installation
If you prefer to install MongoDB locally:
- Install MongoDB from https://www.mongodb.com/try/download/community
- Start the MongoDB service
- Update your
.env
file with:Copy
Option 4: MongoDB Atlas (Cloud)
For production use, MongoDB Atlas is recommended:
- Create an account at https://www.mongodb.com/cloud/atlas
- Create a new cluster
- Set up a database user and whitelist your IP address
- Get your connection string and update your
.env
file:Copy
Database Migration
To migrate existing data to MongoDB:
This script will:
- Migrate tool definitions to MongoDB
- Migrate configurations (like API keys) to MongoDB
- Import any backup data if available
Usage
Start the server
The server will be running at http://localhost:3000 (or the port you specified in .env).
Startup Options
- Standard Start (
npm start
):- Checks if API keys are configured
- Prompts for setup if no keys are found
- Recommended for first-time users
- Development Mode (
npm run dev
):- Uses nodemon for auto-reload on code changes
- Still performs environment checks
- Best for development
- Quick Start (
npm run quick-start
):- Bypasses all environment checks
- Starts the server immediately
- Useful when you know your configuration is correct
- PM2 Production Mode (
npm run pm2:start:prod
):- Runs the server using the PM2 process manager
- Automatically restarts if the server crashes
- Optimized for production environments
- Bypasses environment checks
Using PM2 Process Manager
The server can be run with PM2, a production process manager for Node.js applications. PM2 provides features like:
- Process management (restart on crash)
- Log management
- Performance monitoring
- Load balancing (for multiple instances)
PM2 Commands
The PM2 configuration is stored in ecosystem.config.js
. You can modify this file to change:
- Process name
- Environment variables
- Memory limits
- Deployment configuration
- Number of instances (for load balancing)
API Endpoints
POST /mcp/:provider
Make requests to AI models through a unified API.
URL Parameters:
provider
: The AI provider to use (anthropic
oropenai
)
Request Body:
OR (Legacy format):
Response: Returns the raw response from the provider's API.
GET /tools/available
Get a comprehensive list of all available tools with detailed information.
Query Parameters:
format
- Response format:json
(default),yaml
,table
, orhtml
category
- Filter tools by category (optional)enabled
- Filter by enabled status:true
(default) orfalse
search
- Search for tools by name, description, or tagsprovider
- Filter tools by provider (e.g.,openai
,google
)limit
- Maximum number of tools to return (for pagination)offset
- Offset for pagination (default: 0)
Response (JSON format):
GET /health
Health check endpoint that returns status 200 if the server is running.
Data Management
Database Backups
You can create and manage database backups:
Testing the Database Connection
To verify your MongoDB setup:
Example Clients
Command Line Client
A test client is included in src/client.js
. To run it:
Web Client
A simple web interface is available at http://localhost:3000 when the server is running. You can use this to test the API directly from your browser.
Available Tools
The MCP server provides a tools discovery endpoint that allows users and AI agents to programmatically list all available tools:
Tools Discovery
GET /tools/available
- Lists all available tools with detailed information.
- Supports multiple formats: JSON, YAML, HTML, and ASCII table
- Provides filtering by category, provider, and search terms
- Includes detailed metadata and usage examples for each tool
Example usage:
Web Search Tools
The server includes built-in web search and retrieval tools:
- Web Search (
/tools/web/search
)- Search the web for information on a given query
- Parameters:
query
(required),limit
(optional) - Requires:
GOOGLE_CSE_API_KEY
andGOOGLE_CSE_ID
environment variables - Falls back to
BING_SEARCH_API_KEY
if Google search fails
- Web Content (
/tools/web/content
)- Retrieve and extract content from a specific URL
- Parameters:
url
(required),useCache
(optional)
- Web Batch (
/tools/web/batch
)- Retrieve content from multiple URLs in parallel
- Parameters:
urls
(required array),useCache
(optional)
Image Generation Tools
The server also includes image generation, editing, and variation tools:
- Generate Image (
/tools/image/generate
)- Generate an image based on a text prompt
- Parameters:
prompt
(required): Detailed description of the imageprovider
(optional):openai
orstability
(defaults toopenai
)options
(optional): Provider-specific options
- Edit Image (
/tools/image/edit
)- Edit an existing image with a text prompt
- Parameters:
imagePath
(required): Path to the image to editprompt
(required): Description of the edit to makemaskPath
(optional): Path to a mask image
- Create Image Variation (
/tools/image/variation
)- Create a variation of an existing image
- Parameters:
imagePath
(required): Path to the image to create variations of
Note: To use these tools, you need to set API keys in your
.env
file:
- For OpenAI images:
OPENAI_API_KEY
- For Stability AI images:
STABILITY_API_KEY
- For Web Search:
GOOGLE_CSE_API_KEY
andGOOGLE_CSE_ID
Tool Integration with AI Models
The MCP server automatically handles tool calling and execution with AI models. When a model decides to use a tool, the server:
- Executes the requested tool with the provided parameters
- Returns the tool's response to the model
- The model can then incorporate the tool's response into its final answer
Tool Discovery for AI Models
AI models can use the /tools/available
endpoint to discover what tools are available and how to use them. This is particularly useful for:
- Dynamic tool discovery during runtime
- Self-documentation for AI agents
- Enabling AI systems to adapt to available capabilities
Example system prompt for AI models:
Example Tool Usage
See the /examples
directory for sample code demonstrating tool usage.
Adding New Providers or Tools
Adding New AI Providers
To add new AI providers:
- Add the provider's SDK to the project
- Create a new handler function in
server.js
- Add a new case in the main route handler
Adding New Tools
To add new tools to the server:
- Create a new tool implementation in the
/src/tools
directory - Add the tool definition to
tool-definitions.js
- Update the tool execution functions in
server.js
- Add new API endpoints for direct tool usage (if needed)
License
ISC
This server cannot be installed
A unified API server that enables interaction with multiple AI model providers like Anthropic and OpenAI through a consistent interface, supporting chat completions, tool calling, and context handling.
Related MCP Servers
- -securityAlicense-qualityThis server facilitates the invocation of AI models from providers like Anthropic, OpenAI, and Groq, enabling users to manage and configure large language model interactions seamlessly.Last updated -4PythonMIT License
- -security-license-qualityAn open standard server implementation that enables AI assistants to directly access APIs and services through Model Context Protocol, built using Cloudflare Workers for scalability.Last updated -TypeScript
- -securityFlicense-qualityA modern AI service proxy that enables interaction with multiple AI providers (Anthropic Claude, OpenAI) through a unified API, deployed globally using Cloudflare Workers.Last updated -13TypeScript
- AsecurityFlicenseAqualityA Model Context Protocol server that enables AI assistants to interact with the Omi API for retrieving and creating conversations and memories for users.Last updated -4TypeScript