This Python-based MCP server provides a powerful way to add RAG (Retrieval-Augmented Generation) capabilities to development environments by connecting AI interfaces like Cursor IDE and Claude Desktop to a specialized Contextual AI agent.
Clone the repository:
git clone https://github.com/ContextualAI/contextual-mcp-server.git
cd contextual-mcp-server
Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`
Install dependencies:
pip install -e .
The server requires some configuration before use, particularly for the single_agent server.
Customize the docstring for your RAG Agent to help MCP clients understand when to route questions to your agent. For example:
A research tool focused on financial data on the largest US firms
or
A research tool focused on technical documents for Omaha semiconductors
Configure your Contextual AI credentials by setting these values:
API_KEY
: Your Contextual AI API keyAGENT_ID
: Your Contextual AI agent IDYou can store these in an .env
file:
cat > .env << EOF
API_KEY=key...
AGENT_ID=...
EOF
To integrate with Cursor IDE or Claude Desktop:
Find the path to your uv
installation:
UV_PATH=$(which uv)
echo $UV_PATH
# Example output: /Users/username/miniconda3/bin/uv
Create an MCP configuration file:
cat > mcp.json << EOF
{
"mcpServers": {
"ContextualAI-TechDocs": {
"command": "$UV_PATH",
"args": [
"--directory",
"\${workspaceFolder}",
"run",
"multi-agent/server.py"
]
}
}
}
EOF
Move this file to the appropriate location:
mkdir -p .cursor/
mv mcp.json .cursor/
Configuration locations:
.cursor/mcp.json
in your project directory or ~/.cursor/mcp.json
for global accessThe MCP server provides access to Contextual AI's RAG capabilities from compatible clients like Cursor IDE and Claude Desktop.
When you ask a question in your AI interface:
In Cursor IDE or Claude Desktop, you might ask:
Show me the code for initiating the RF345 microchip?
The system will route this question through your MCP server to the Contextual AI agent, which will search your documentation and provide a detailed, cited response.
For complete details on Contextual AI capabilities, check the official documentation.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "ContextualAI-TechDocs" '{"command":"$UV_PATH","args":["--directory","${workspaceFolder}","run","multi-agent/server.py"]}'
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": {
"ContextualAI-TechDocs": {
"command": "$UV_PATH",
"args": [
"--directory",
"${workspaceFolder}",
"run",
"multi-agent/server.py"
]
}
}
}
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": {
"ContextualAI-TechDocs": {
"command": "$UV_PATH",
"args": [
"--directory",
"${workspaceFolder}",
"run",
"multi-agent/server.py"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect