This MCP server (Model Context Protocol) provides a standardized API access layer for various AI models, offering a consistent interface for model interaction while handling authentication and monitoring. It simplifies working with different AI providers by providing a unified way to access their capabilities.
git clone https://github.com/yourusername/mcp-server-sandbox.git
cd mcp-server-sandbox
npm install
.env
file in the root directory:# Server configuration
PORT=3000
NODE_ENV=development
# Database configuration
MONGODB_URI=mongodb://localhost:27017/mcp-server
# Optional Redis configuration
REDIS_URL=redis://localhost:6379
# Authentication (replace with your actual keys)
JWT_SECRET=your-secret-key
npm start
The server's behavior can be customized through the .env
file. Key configurations include:
PORT
: The port on which the server listens (default: 3000)NODE_ENV
: Environment setting (development
, production
, or test
)LOG_LEVEL
: Logging verbosity (error
, warn
, info
, http
, debug
)Edit the config/providers.js
file to configure which AI model providers you want to enable:
module.exports = {
openai: {
enabled: true,
apiKey: process.env.OPENAI_API_KEY,
models: ['gpt-3.5-turbo', 'gpt-4']
},
anthropic: {
enabled: true,
apiKey: process.env.ANTHROPIC_API_KEY,
models: ['claude-2', 'claude-instant-1']
},
// Add more providers as needed
}
POST /auth/login
Request body:
{
"username": "user",
"password": "password"
}
Response:
{
"token": "your-jwt-token"
}
POST /v1/completions
Headers:
Authorization: Bearer your-jwt-token
Request body:
{
"model": "gpt-3.5-turbo",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello, how are you?" }
],
"temperature": 0.7,
"max_tokens": 100
}
# First authenticate
curl -X POST http://localhost:3000/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"user","password":"password"}'
# Then make a request with the received token
curl -X POST http://localhost:3000/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-jwt-token" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
}'
// Authentication
async function authenticate() {
const response = await fetch('http://localhost:3000/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: 'user', password: 'password' })
});
const data = await response.json();
return data.token;
}
// Model completion
async function getCompletion(token) {
const response = await fetch('http://localhost:3000/v1/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify({
model: 'gpt-3.5-turbo',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the capital of France?' }
]
})
});
return await response.json();
}
// Usage
async function main() {
const token = await authenticate();
const completion = await getCompletion(token);
console.log(completion);
}
Server logs are available in the console and also written to the logs
directory if enabled in your configuration. You can adjust the log level in your .env
file:
LOG_LEVEL=debug
The server provides a health endpoint to verify it's running correctly:
GET /health
Response:
{
"status": "ok",
"uptime": 3600,
"version": "1.0.0"
}
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mcp-server-sandbox" '{"command":"npx","args":["-y","mcp-server-sandbox"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mcp-server-sandbox": {
"command": "npx",
"args": [
"-y",
"mcp-server-sandbox"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mcp-server-sandbox": {
"command": "npx",
"args": [
"-y",
"mcp-server-sandbox"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect