Contextual MCP
Contextual MCP Server provides Retrieval-Augmented Generation (RAG) for accurate, context-aware AI responses with source citations. It integrates with Cursor IDE and Claude Desktop for domain-specific question answering.
How to Install and Use Contextual MCP
If you want to use Contextual MCP, a powerful server that connects AI tools like Cursor IDE or Claude Desktop to a special Contextual AI agent, this guide will help you install and start it quickly. Follow each step below for a smooth setup.
Prerequisites Before Installation
First, make sure your computer is ready. You need Python 3.10 or higher installed because Contextual MCP runs on Python. Also, having Cursor IDE or Claude Desktop will help you interact with the MCP server. Lastly, get your Contextual AI API key, which is necessary to connect to the AI agent.
Step 1: Download Contextual MCP
Begin by downloading the project files. Open your terminal or command prompt and run this command:
git clone https://github.com/ContextualAI/contextual-mcp-server.git
cd contextual-mcp-server
This will copy the server code to your computer and switch to the correct folder.
Step 2: Set Up a Virtual Environment
To keep your computer tidy, create a virtual environment for the project. This lets you keep the settings separate.
On Mac or Linux, type:
python -m venv .venv
source .venv/bin/activate
On Windows, use:
python -m venv .venv
.venv\Scripts\activate
Now you are inside the isolated environment for Contextual MCP.
Step 3: Install Needed Packages
With the virtual environment active, install the extra tools the server needs by running:
pip install -e .
This command gets all the required Python packages from the project.
Step 4: Configure Your MCP Server
Next, you need to set your API key and agent ID, so Contextual MCP knows who you are and what agent to use. You can do this by creating a .env file inside the project folder.
Run this:
cat > .env << EOF
API_KEY=your_contextual_ai_api_key_here
AGENT_ID=your_agent_id_here
EOF
Replace the placeholders with your actual API key and agent ID.
Step 5: Connect Contextual MCP to AI Tools
To make your Cursor IDE or Claude Desktop talk to Contextual MCP, create a configuration file.
First, find where the uv command is located:
UV_PATH=$(which uv)
echo $UV_PATH
This shows the full path to uv.
Now create the mcp.json 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 right folder, for example:
mkdir -p .cursor
mv mcp.json .cursor/
This makes the configuration available for Cursor IDE.
Step 6: Start Using Contextual MCP
Now you can ask questions through your MCP client (like Cursor or Claude Desktop). For example, in Cursor IDE, you might type:
Show me the code for initiating the RF345 microchip?
Here’s what happens:
- Cursor decides if your question should go to Contextual MCP.
- Contextual MCP sends it to the Contextual AI agent.
- The agent looks through your documentation.
- It sends back a clear answer with citations.
- The answer appears right in your client.
Summary
You have installed Contextual MCP by:
- Cloning the GitHub repo
- Creating and activating a Python virtual environment
- Installing dependencies
- Setting your API key and agent ID in a
.envfile - Configuring your AI interface (Cursor IDE or Claude Desktop)
- Asking questions that are processed by your custom AI agent
This setup ensures you receive accurate, context-aware responses based on your latest documents, complete with source references. Enjoy exploring your data with Contextual MCP!