Observed since 21 Oct, 10:14 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
MCP (Model Context Protocol) Server for AI Cogence RAG Backend
This MCP (Model Context Protocol) server exposes the AI Cogence backend's RAG capabilities, knowledge base, and chat functionality to AI assistants like Claude. It allows AI tools to directly query your knowledge base, perform semantic searches, and manage chat sessions.
rag_query - Query the RAG system with natural language questions
semantic_search - Perform vector similarity search
load_markdown_content - Index markdown files into the knowledge base
/content directorylist_chat_sessions - View all chat sessions
get_session_messages - Retrieve conversation history
search_knowledge_base - Keyword-based search
get_analytics - System usage statistics
Content Resources (cogence://content/*)
/backend/content/Knowledge Base (cogence://knowledge-base)
Chat History (cogence://chat-history)
cd /Users/infoobjects/Documents/Projects/ai-cogence-web/backend
source venv/bin/activate
pip install mcp
python mcp_server.py --help
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"ai-cogence-backend": {
"command": "python",
"args": [
"/Users/infoobjects/Documents/Projects/ai-cogence-web/backend/mcp_server.py"
],
"env": {
"PYTHONPATH": "/Users/infoobjects/Documents/Projects/ai-cogence-web/backend"
}
}
}
}
cd /Users/infoobjects/Documents/Projects/ai-cogence-web/backend
source venv/bin/activate
python mcp_server.py
The server runs on stdio and communicates via JSON-RPC 2.0.
{
"tool": "rag_query",
"arguments": {
"question": "What services does AI Cogence offer?",
"session_id": "optional-session-id"
}
}
Response:
{
"answer": "AI Cogence offers RAG implementation, AI strategy consulting, fine-tuning services...",
"sources": [
{"content": "...", "metadata": {...}},
{"content": "...", "metadata": {...}}
],
"session_id": "...",
"timestamp": "2025-10-08T10:30:00"
}
{
"tool": "semantic_search",
"arguments": {
"query": "machine learning consulting",
"top_k": 5
}
}
Response:
{
"query": "machine learning consulting",
"results": [
{
"content": "Our AI strategy consulting helps businesses...",
"metadata": {"source": "ai-strategy-consulting.md"},
"similarity": 0.89
},
...
],
"count": 5
}
{
"tool": "load_markdown_content",
"arguments": {
"collection_name": "cogence_content"
}
}
{
"tool": "get_analytics",
"arguments": {
"time_range": "week"
}
}
Response:
{
"time_range": "week",
"total_queries": 245,
"unique_sessions": 87,
"timestamp": "2025-10-08T10:30:00"
}
URI: cogence://knowledge-base
Response:
{
"total_chunks": 1234,
"total_sources": 45,
"total_sessions": 87,
"timestamp": "2025-10-08T10:30:00"
}
URI: cogence://content/about-us.md
Response: (Full markdown content)
Once configured, Claude can automatically:
User: "What do you know about AI Cogence's services?"
Claude: (Internally calls rag_query tool)
"AI Cogence offers several services including RAG implementation, AI strategy consulting, and fine-tuning services for enterprises..."
User: "Show me recent chat sessions"
Claude: (Internally calls list_chat_sessions tool)
"Here are the recent chat sessions: [lists sessions with timestamps]"
┌─────────────────────┐
│ AI Assistant │
│ (Claude/etc) │
└──────────┬──────────┘
│ MCP Protocol
│ (JSON-RPC)
┌──────────▼──────────┐
│ MCP Server │
│ mcp_server.py │
├─────────────────────┤
│ • Tools │
│ • Resources │
│ • Prompts │
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ Backend Services │
├─────────────────────┤
│ • RAG Engine │
│ • LangGraph │
│ • PostgreSQL/pgvector│
│ • OpenAI Embeddings │
└─────────────────────┘
The server logs to stdout with INFO level by default. Key events logged:
View logs:
python mcp_server.py 2>&1 | tee mcp_server.log
# Check if PostgreSQL is running
brew services list | grep postgres
# Test database connection
psql -h localhost -p 5432 -U $(whoami) -d postgres
# Ensure virtual environment is activated
source venv/bin/activate
# Install missing dependencies
pip install -r requirements.txt
pip install mcp
The MCP server uses stdio, not network ports, so no port conflicts should occur.
.env@mcp_server.list_tools()
async def list_tools() -> list[Tool]:
return [
# ... existing tools ...
Tool(
name="my_new_tool",
description="Description of what it does",
inputSchema={
"type": "object",
"properties": {
"param": {"type": "string", "description": "Parameter description"}
},
"required": ["param"]
}
)
]
@mcp_server.call_tool()
async def call_tool(name: str, arguments: Any) -> Sequence[TextContent]:
if name == "my_new_tool":
return await handle_my_new_tool(arguments)
@mcp_server.list_resources()
async def list_resources() -> list[Resource]:
return [
# ... existing resources ...
Resource(
uri="cogence://my-resource",
name="My Resource",
mimeType="application/json",
description="Description of the resource"
)
]
Required in .env:
# Database
DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
# OpenAI
OPENAI_API_KEY=sk-...
# Optional
LOG_LEVEL=INFO
For issues or questions:
python mcp_server.py 2>&1 | grep ERRORtail -f backend.logcurl http://localhost:5025/healthSame as parent project.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.0 | 8 Oct 2025 | 21 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 10:14 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:5b71a1d13ed864a9d1b9752a6ce829844f81901ed4dd5dc580d5ddb54ec2a0e3