Skip to main content
Glama
NitishGourishetty

Contextual MCP Server

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 citations

Related MCP server: RAG MCP Server

Prerequisites

  • 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-server
  1. Create and activate a virtual environment:

python -m venv .venv
source .venv/bin/activate  # On Windows, use `.venv\Scripts\activate`
  1. 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 key

  • AGENT_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:

  1. First, find the path to your uv installation:

UV_PATH=$(which uv)
echo $UV_PATH
# Example output: /Users/username/miniconda3/bin/uv
  1. 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
  1. 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.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

# 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

  1. Accurate Responses: All answers are grounded in your documentation

  2. Source Attribution: Every response includes references to source documents

  3. Context Awareness: The system maintains conversation context for follow-up questions

  4. Real-time Updates: Responses reflect the latest documentation in your datastore

Development

Modifying the Server

To add new capabilities:

  1. Add new tools by creating additional functions decorated with @mcp.tool()

  2. Define the tool's parameters using Python type hints

  3. 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.

Available Tools

1 tool
queryC

An enterprise search tool that can answer questions about any sort of knowledge base

ParametersJSON Schema
NameRequiredDescriptionDefault
promptYes

TDQS

C2.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully convey behavioral traits. It only states that the tool can answer questions, but does not disclose limitations, permissions, side effects, or whether it performs reads/writes. The minimal disclosure is insufficient for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise, but it is vague and does not add substantial value. It is front-loaded with the tool's purpose, but the vagueness detracts from its effectiveness. It could be more helpful without being longer.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one parameter, no output schema), the description should provide context about return format, error handling, or typical use cases. It only states the general function, leaving out important details that an agent needs to invoke the tool correctly and interpret results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage for its single required parameter 'prompt'. The description does not elaborate on how to structure the prompt, what types of questions are supported, or any constraints. This provides no added meaning beyond the parameter name.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool is an 'enterprise search tool that can answer questions about any sort of knowledge base', which clearly identifies its function (answering questions) and resource (knowledge base). It is not a tautology and distinguishes it implicitly from generic LLM queries, though it is somewhat broad. With no sibling tools, differentiation is not required.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, no prerequisites, and no context on appropriate prompts or knowledge base scope. It lacks explicit or implicit usage guidance beyond the general purpose.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev0.1.0
    • First observedquery

TDQS

C2.7/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of confusion or overlap between tools.

Naming Consistency5/5

A single tool name is inherently consistent; 'query' is a clear verb describing its action.

Tool Count2/5

The server claims to handle 'any sort of knowledge base' but provides only a generic search tool, which feels too limited for the broad scope.

Completeness2/5

Missing essential tools for managing knowledge bases (e.g., listing sources, retrieving documents, updating content), leaving agents with only a single query capability.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    C
    quality
    D
    maintenance
    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.
    1
    21
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables Claude Desktop to search custom knowledge bases using retrieval-augmented generation via a simple MCP tool.
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    Provides a unified context layer for AI agents, enabling ranked search, file management, context bundles, database queries, and connected source access through MCP, all scoped to organizational permissions with citations.
    -