Documentation
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:
1. Query Processing: Direct your domain specific questions to a dedicated Contextual AI agent
2. Intelligent Retrieval: Searches through comprehensive information in your knowledge base
3. 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 citationsPrerequisites
- Python 3.10 or higher
- Cursor IDE and/or Claude Desktop
- Contextual AI API key
- MCP-compatible environment
Installation
1. Clone the repository:
git clone https://github.com/ContextualAI/contextual-mcp-server.git
cd contextual-mcp-server2. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`3. 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 firmsor
A research tool focused on technical documents for Omaha semiconductorsThe 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 mcp.json str:
"""Description of what the tool does"""
# Implementation
return resultLimitations
- 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.
Similar MCP
Based on tags & features
Trending MCP
Most active this week