This MCP server provides a standardized interface for interacting with Ollama services through the Model Context Protocol. It simplifies API calls to Ollama while providing structured responses and intelligent guidance for Language Learning Models.
Before getting started, make sure you have:
# Install uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create and activate virtual environment
uv venv
source .venv/bin/activate # Linux/macOS
# or
.venv\Scripts\activate # Windows
# Install dependencies
uv pip install .
The server uses a config.json
file for configuration:
{
"ollama": {
"host": "http://localhost:11434", // Ollama service address
"timeout": 30, // Request timeout (seconds)
"user_agent": "Ollama_MCP_Guidance/1.0" // Request identifier
},
"api_doc": {
"max_length": 8000, // Maximum document content length
"file_path": "ollama-api.md" // API documentation path
}
}
Since Cursor MCP needs to execute a single command from the default command line environment, it's recommended to create a custom run script.
Create an ollama-mcp-cli
file (for macOS/Linux):
#!/bin/bash
# Project path configuration
PROJECT_PATH="your_project_path/Ollama_MCP_Guidance"
if [ ! -d "$PROJECT_PATH" ]; then
echo "Error: Project directory not found at $PROJECT_PATH"
exit 1
fi
# Run the program
cd "$PROJECT_PATH"
source .venv/bin/activate # Activate uv virtual environment
python ollama_mcp_server.py "$@"
Set script permissions:
chmod +x ollama-mcp-cli
Note: Windows users should create an
ollama-mcp-cli.bat
file with appropriate adjustments.
/full_path/ollama-mcp-cli
Tip: If you place the script in your system's executable path (like
/usr/local/bin/
), you can simply use:ollama-mcp-cli
result = await get_ollama_list()
response = await simple_chat(
model="llama2",
prompt="Hello, please introduce yourself"
)
embeddings = await post_generate_embeddings(
model="nomic-embed-text",
text=["This is a sample text"]
)
Endpoint | Method | Description | Features | Tool Name |
---|---|---|---|---|
- | - | Project starter guide | - Smart project navigation ✨ - Personalized feature recommendations 🎯 - Best practices guidance 💡 |
get_started_guide |
/api/version |
GET | Get Ollama server version | - Single response ✅ - Includes build info ✅ |
get_ollama_version |
/api/tags |
GET | Get list of installed models | - Complete response ✅ - Includes model metadata ✅ |
get_ollama_list |
/api/ps |
GET | View running models | - Real-time status ✅ - Resource usage data ✅ |
get_running_models |
/api/show |
POST | Get detailed model information | - Detailed mode ✅ - Complete configuration info ✅ |
post_show_model |
/api/chat |
POST | Conversational interaction | - Streaming output ❌ - Multi-turn dialogue ❌ - System prompts ❌ - Image input ❌ |
simple_chat |
/api/generate |
POST | Basic text generation | - Streaming output ❌ - Context management ❌ - Raw mode ❌ - Model JSON output ❌ - Tool JSON wrapping ✅ |
simple_generate |
/api/embed |
POST | Generate text vector representations | - Batch processing ✅ - Fixed dimension output ✅ |
post_generate_embeddings |
/api/embeddings |
POST | Generate text vector representations (deprecated) | - Batch processing ✅ - Fixed dimension output ✅ - Replaced by /api/embed ⚠️ |
post_generate_embeddings |
Basic Functionality Limitations
Management Function Limitations
/api/copy
)/api/pull
)/api/delete
)Experimental Features
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.