Contextual MCP Server
A server for Retrieval-Augmented Generation (RAG) using the Contextual AI platform.
Contextual MCP Server
A Model Context Protocol (MCP) server that provides RAG (Retrieval-Augmented Generation) capabilities using Contextual AI. This server integrates with a variety of MCP clients. It provides flexibility in you can decide what functionality to offer in the server. In this readme, we will show integration with the both Cursor IDE and Claude Desktop.
Contextual AI now offers a hosted server inside the platform available at: https://mcp.app.contextual.ai/mcp/
After you connect to the server, you can use the tools, such as query, provided by the platform MCP server.
For a complete walkthrough, check out the MCP user guide.
Overview
An MCP server acts as a bridge between AI interfaces (Cursor IDE or Claude Desktop) and a specialized Contextual AI agent. It enables:
- Query Processing: Direct your domain specific questions to a dedicated Contextual AI agent
- Intelligent Retrieval: Searches through comprehensive information in your knowledge base
- Context-Aware Responses: Generates answers that are:
- Grounded in source documentation
- Include citations and attributions
- Maintain conversation context
Integration Flow
Cursor/Claude Desktop → MCP Server → Contextual AI RAG Agent
↑ ↓ ↓
└──────────────────┴─────────────┴─────────────── Response with citations
Prerequisites
- Python 3.10 or higher
- Cursor IDE and/or Claude Desktop
- Contextual AI API key
- MCP-compatible environment
Installation
- 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 .
Configuration
Configure MCP Server
The server requires modifications of settings or use. For example, the single_agent server should be customized with an appropriate docstring for your RAG Agent.
The docstring for your query tool is critical as it helps the MCP client understand when to route questions to your RAG agent. Make it specific to your knowledge domain. Here is an example:
A research tool focused on financial data on the largest US firms
or
A research tool focused on technical documents for Omaha semiconductors
The server also requires the following settings from your RAG Agent:
API_KEY: Your Contextual AI API keyAGENT_ID: Your Contextual AI agent ID
If you'd like to store these files in .env file you can specify them like so:
cat > .env << EOF
API_KEY=key...
AGENT_ID=...
EOF
The repo also contains more advance MPC servers for multi-agent systems or a document-agent.
AI Interface Integration
This MCP server can be integrated with a variety of clients. To use with either Cursor IDE or Claude Desktop create or modify the MCP configuration file in the appropriate location:
- First, find the path to your
uvinstallation:
UV_PATH=$(which uv)
echo $UV_PATH
# Example output: /Users/username/miniconda3/bin/uv
- Create the configuration file using the full path from step 1:
cat > mcp.json << EOF
{
"mcpServers": {
"ContextualAI-TechDocs": {
"command": "$UV_PATH", # make sure this is set properly
"args": [
"--directory",
"\${workspaceFolder}", # Will be replaced with your project path
"run",
"multi-agent/server.py"
]
}
}
}
EOF
- Move to the correct folder location, see below for options:
mkdir -p .cursor/
mv mcp.json .cursor/
Configuration locations:
- For Cursor:
- Project-specific:
.cursor/mcp.jsonin your project directory - Global:
~/.cursor/mcp.jsonfor system-wide access - For Claude Desktop:
- Use the same configuration file format in the appropriate Claude Desktop configuration directory
Environment Setup
This project uses uv for dependency management, which provides faster and more reliable Python package installation.
Usage
The server provides Contextual AI RAG capabilities using the python SDK, which can available a variety of commands accessible from MCP clients, such as Cursor IDE and Claude Desktop. The current server focuses on using the query command from the Contextual AI python SDK, however you could extend this to support other features such as listing all the agents, updating retrieval settings, updating prompts, extracting retrievals, or downloading metrics.
Example Usage
# In Cursor, you might ask:
"Show me the code for initiating the RF345 microchip?"
# The MCP client will:
1. Determine if this should be routed to the MCP Server
# Then the MCP server will:
1. Route the query to the Contextual AI agent
2. Retrieve relevant documentation
3. Generate a response with specific citations
4. Return the formatted answer to Cursor
Key Benefits
- Accurate Responses: All answers are grounded in your documentation
- Source Attribution: Every response includes references to source documents
- Context Awareness: The system maintains conversation context for follow-up questions
- Real-time Updates: Responses reflect the latest documentation in your datastore
Development
Modifying the Server
To add new capabilities:
- Add new tools by creating additional functions decorated with
@mcp.tool() - Define the tool's parameters using Python type hints
- Provide a clear docstring describing the tool's functionality
Example:
@mcp.tool()
def new_tool(param: str) -> str:
"""Description of what the tool does"""
# Implementation
return result
Limitations
- The server runs locally and may not work in remote development environments
- Tool responses are subject to Contextual AI API limits and quotas
- Currently only supports stdio transport mode
For all the capabilities of Contextual AI, please check the official documentation.
Verwandte Server
Higress AI-Search MCP Server
Provides an AI search tool to enhance AI model responses with real-time search results from various search engines using the Higress ai-search feature.
Crawleo MCP Server
Crawleo MCP - Web Search & Crawl for AI Enable AI assistants to access real-time web data through native tool integration. Two Powerful Tools: web.search - Real-time web search with flexible formatting Search from any country/language Device-specific results (desktop, mobile, tablet) Multiple output formats: Enhanced HTML (AI-optimized, clean) Raw HTML (original source) Markdown (formatted text) Plain Text (pure content) Auto-crawl option for full content extraction Multi-page search support web.crawl - Deep content extraction Extract clean content from any URL JavaScript rendering support Markdown conversion Screenshot capture Multi-URL support Features: ✅ Zero data retention (complete privacy) ✅ Real-time, not cached results ✅ AI-optimized with Enhanced HTML mode ✅ Global coverage (any country/language) ✅ Device-specific search (mobile/desktop/tablet) ✅ Flexible output formats (4 options) ✅ Cost-effective (5-10x cheaper than competitors) ✅ Simple Claude Desktop integration Perfect for: Research, content analysis, data extraction, AI agents, RAG pipelines, multi-device testing
PubMed MCP Server
A server for searching, retrieving, and analyzing articles from the PubMed database.
Local Flow
A minimal, local, GPU-accelerated RAG server for document ingestion and querying.
Knowledge Raven
Make your knowledge agent-ready. Connect docs from Confluence, Notion, GitHub, Dropbox, or Google Drive — any AI agent searches them via MCP.
mcpdoc
Access website documentation for AI search engines (llms.txt files) over MCP.
stooq-mcp
MCP server to fetch stock prices from stooq.com (Rust)
Kagi Search
Search the web using Kagi's search API
Rememberizer MCP Server for Common Knowledge
Access personal and team knowledge repositories, including documents and Slack discussions.
Chromium CodeSearch Tools
Search Chromium source code using advanced Code Search syntax.