MCP Server Documentation¶
This directory contains documentation for all 3 MCP (Model Context Protocol) servers in src/mcp/.
Overview¶
MCP servers provide standardized access to Bast AI services through the Model Context Protocol, enabling integration with AI assistants and agent frameworks.
MCP Servers¶
| Server | Version | Description | Dependencies |
|---|---|---|---|
| base | 0.1.1 | Abstract base for MCP servers | fastmcp, openai-agents |
| mongo | 0.1.1 | MongoDB operations via MCP | bast-ai-mongo |
| ontology | 0.1.1 | Ontology/knowledge graph access | bast-ai-graphrag |
Architecture¶
┌─────────────────────────────────────────┐
│ MCP Clients │
│ (Claude, OpenAI Agents, Custom) │
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ bast-ai-mcp-base │
│ (FastMCP, Common Utilities) │
└─────────────────────────────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ bast-ai-mcp- │ │ bast-ai-mcp- │
│ mongo │ │ ontology │
└─────────────────┘ └─────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ bast-ai-mongo │ │ bast-ai-graphrag│
└─────────────────┘ └─────────────────┘
Base MCP Server¶
The bast-ai-mcp-base provides:
- FastMCP integration (v2.10+)
- Common MCP patterns
- OpenAI agents support for testing
- Configuration management integration
Dependencies¶
| Package | Version | Purpose |
|---|---|---|
| bast-ai-config | - | Configuration |
| fastmcp | ^2.10 | MCP framework |
| openai-agents | 0.2.2 | Agent testing |
MCP MongoDB Server¶
Provides MongoDB operations through MCP:
Available Tools¶
| Tool | Description |
|---|---|
find_documents |
Query documents with filters |
insert_document |
Insert new document |
update_document |
Update existing document |
delete_document |
Delete document |
aggregate |
Run aggregation pipeline |
count_documents |
Count matching documents |
Usage Example¶
# MCP client calling MongoDB server
result = await mcp_client.call_tool(
"find_documents",
{
"collection": "users",
"filter": {"status": "active"},
"limit": 10
}
)
MCP Ontology Server¶
Provides knowledge graph access through MCP:
Available Tools¶
| Tool | Description |
|---|---|
query_entities |
Search for entities |
get_relationships |
Get entity relationships |
traverse_graph |
Navigate knowledge graph |
search_concepts |
Semantic concept search |
Usage Example¶
# MCP client calling ontology server
result = await mcp_client.call_tool(
"query_entities",
{
"query": "machine learning",
"entity_types": ["concept", "topic"],
"limit": 5
}
)
Running MCP Servers¶
Development¶
# Run MongoDB MCP server
pants run src/mcp/mongo:main
# Run Ontology MCP server
pants run src/mcp/ontology:main
With Claude Desktop¶
Add to claude_desktop_config.json:
{
"mcpServers": {
"bast-mongo": {
"command": "python",
"args": ["-m", "bast_ai_mcp_mongo.main"],
"env": {
"MONGO_URI": "mongodb://localhost:27017"
}
}
}
}
Testing¶
Integration Tests¶
Each MCP server has integration tests in integration/:
client.py- Client-side testsmcp_server.py- Server-side tests
# Run integration tests
pants run src/mcp/mongo/integration/client.py
pants run src/mcp/ontology/integration/mcp_server.py
Issues & Improvements¶
Current Issues¶
- Limited tool coverage: Not all MongoDB/GraphRAG features exposed
- No authentication: MCP servers lack built-in auth
- Missing streaming: Large results aren't streamed
Suggested Improvements¶
- Expand tool coverage: Add more MongoDB and ontology operations
- Add authentication: Implement API key or token auth
- Response streaming: Stream large result sets
- Rate limiting: Add per-client rate limits
- Caching: Add result caching for repeated queries
- Metrics: Add Prometheus metrics endpoint
Maintainer¶
- Chiranjeevi G (chiranjeevi.g@cygnenoircyber.com) - All MCP servers