Supports configuration of API keys and agent IDs through environment variables stored in a .env file.
Allows connection to a repository containing the MCP server code, which can be cloned and customized for domain-specific RAG capabilities.
Uses the Contextual AI Python SDK to provide RAG capabilities, query processing, and potential extension to other features like agent management and retrieval settings.
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.
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
Prerequisites
- Python 3.10 or higher
- Cursor IDE and/or Claude Desktop
- Contextual AI API key
- MCP-compatible environment
Installation
- Clone the repository:
- Create and activate a virtual environment:
- Install dependencies:
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:
or
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:
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
uv
installation:
- Create the configuration file using the full path from step 1:
- Move to the correct folder location, see below for options:
Configuration locations:
- For Cursor:
- Project-specific:
.cursor/mcp.json
in your project directory - Global:
~/.cursor/mcp.json
for 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
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:
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.
This server cannot be installed
A Model Context Protocol server that provides Retrieval-Augmented Generation capabilities using Contextual AI, enabling AI interfaces like Cursor IDE and Claude Desktop to query domain-specific knowledge with context-aware responses and source citations.
Related MCP Servers
- -securityFlicense-qualityA Model Context Protocol server utilizing Claude AI for generating intelligent queries and offering documentation assistance based on API documentation analysis.Last updated -33TypeScript
- AsecurityFlicenseAqualityA Model Context Protocol server that enables AI models to interact with SourceSync.ai's knowledge management platform for managing documents, ingesting content from various sources, and performing semantic searches.Last updated -25543
- AsecurityFlicenseAqualityA Model Context Protocol server that enhances Claude in Cursor AI with advanced reasoning capabilities including Monte Carlo Tree Search, Beam Search, R1 Transformer, and Hybrid Reasoning methods.Last updated -813TypeScript
- -securityFlicense-qualityA comprehensive Model Context Protocol server that provides AI assistants with direct access to Semantic Scholar's academic database, enabling advanced paper discovery, citation analysis, author research, and AI-powered recommendations.Last updated -4Python