This MCP server integrates LiteLLM to handle text completions using OpenAI models, providing a standardized way to interact with Large Language Models through the Model Context Protocol.
You can install the MCP server with a simple pip command:
pip install mcp-server-litellm
To start the MCP server, use the following command:
mcp-litellm --host 127.0.0.1 --port 8080
This will launch the server on localhost port 8080. You can modify these parameters as needed for your specific setup.
The server can be configured using environment variables or command-line options:
# Set OpenAI API key
export OPENAI_API_KEY=your_api_key_here
# Then start the server
mcp-litellm --model gpt-3.5-turbo
The server supports several command-line options:
--host
: Host address to bind to (default: 127.0.0.1)--port
: Port to listen on (default: 8080)--model
: Default model to use (default: gpt-3.5-turbo)--log-level
: Set logging level (default: info)Once the server is running, you can make requests to it using any HTTP client:
import requests
import json
url = "http://127.0.0.1:8080/v1/completions"
headers = {"Content-Type": "application/json"}
data = {
"prompt": "Hello, world!",
"max_tokens": 100
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
print(result["choices"][0]["text"])
For production deployments, you may want to set additional parameters:
mcp-litellm --host 0.0.0.0 --port 8080 --model gpt-4 --log-level debug
To diagnose problems, check the server logs by running with increased verbosity:
mcp-litellm --log-level debug
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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.