Learning MCP is a FastAPI-based RAG (Retrieval-Augmented Generation) system with MCP (Model Context Protocol) integration. It provides semantic search over PDF/JSON documentation and AutoGen-powered API planning capabilities.
- Main README - Project overview, quickstart, and basic usage
- Search & RAG Features - Semantic search, vector embeddings, and retrieval capabilities
- AutoGen Multi-Agent Planner - How the
plan_api_calltool uses Planner + Critic agents for API planning - Cloudflare AI Gateway - Gateway configuration, BYOK setup, and Dynamic Routing
- Search & RAG Features - Vector search architecture, chunking strategies, embedding backends
- MCP Testing Guide - FastMCP in-memory testing, HTTP testing, and test organization
- Tests README - Test structure, running tests, and coverage
- Read the Main README for setup instructions
- Configure your
.envfile (see Main README) - Run with Docker:
docker compose up --build
- Semantic Search: Vector-based document search with Qdrant
- Multi-Agent Planning: AutoGen Planner + Critic for API call generation
- Profile System: Per-profile configurations for different API documentation sets
- MCP Integration: Tools exposed via Model Context Protocol for AI agents
MCP Server (Port 8013)
POST /mcp- MCP HTTP transport endpoint- MCP Tools:
search_docs- Semantic search over documentationlist_profiles- Available documentation profilesplan_api_call- Generate API calls from natural language (AutoGen)
Job Server (Port 8014)
POST /ingest/jobs- Start document ingestion jobGET /jobs- List all ingestion jobsGET /jobs/{job_id}- Get job status
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP Tools (FastMCP on port 8013) β
β - search_docs β
β - list_profiles β
β - plan_api_call β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Core Services β
β ββββββββββββββββ βββββββββββββββββ ββββββββββββββββ β
β β Embeddings β β Vector DB β β AutoGen β β
β β (CF/Ollama) β β (Qdrant) β β Agents β β
β ββββββββββββββββ βββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Job Server (FastAPI on port 8014) β
β - Background ingestion β
β - Job status tracking β
β - SQLite job database β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Profiles are defined in config/learning.yaml:
profile-name:
documents:
- type: pdf
path: /app/data/docs.pdf
chunking:
max_tokens: 1200
overlap: 200
embedding:
dim: 384
backend:
primary: cloudflare
fallback: ollama
vectordb:
collection: profile-name
distance: Cosine
autogen_hints:
endpoint:
allow: ".*"
forbid: []
templates:
read:
method: GET
write:
method: POST
require_example_in_evidence: trueKey variables (see .env):
# Embedding
CF_ACCOUNT_ID=...
CF_API_TOKEN=...
OLLAMA_HOST=http://host.docker.internal:11434
# Vector DB
VECTOR_DB_URL=http://vector-db:6333
# AutoGen (optional)
USE_AUTOGEN=1
AUTOGEN_BACKEND=groq
GROQ_API_KEY=gsk_...
OPENAI_BASE_URL=https://gateway.ai.cloudflare.com/v1/.../compat
CF_GATEWAY_TOKEN=...# Via API
curl -X POST http://localhost:8014/ingest/jobs \
-H "Content-Type: application/json" \
-d '{"profile": "my-profile", "truncate": true}'
# Check status
curl http://localhost:8014/jobs/{job_id}# Using FastMCP client
from fastmcp import Client
import asyncio
async def search():
async with Client("http://localhost:8013/mcp") as client:
result = await client.call_tool(
"search_docs",
arguments={
"q": "how to configure wifi",
"profile": "dahua-camera",
"top_k": 5
}
)
print(result)
asyncio.run(search())# Using MCP tool
async with Client("http://localhost:8013/mcp") as client:
result = await client.call_tool(
"plan_api_call",
arguments={
"goal": "get job status",
"profile": "informatica-cloud"
}
)
# Returns: {"status": "ok", "plan": {...}, "confidence": 0.9}# Run all tests
docker compose exec learning-mcp pytest
# Run with coverage
docker compose exec learning-mcp pytest --cov=src
# Run integration tests only
docker compose exec learning-mcp pytest tests/integration/
# Run specific test
docker compose exec learning-mcp pytest tests/integration/test_mcp_client_e2e.py -vSee MCP Testing Guide for details.
- Add profile to
config/learning.yaml - Place documents in
data/your-profile/ - Run ingestion:
POST /ingest/jobs - Test search: Use
search_docsMCP tool
- Create loader in
src/learning_mcp/{type}_loader.py - Return
List[Chunk]whereChunk = {"text": str, "metadata": dict} - Register in
document_loaders._LOADER_BY_TYPE - Add to profile YAML:
documents: [{type: your_type, path: ...}]
- Edit system messages in
autogen_planner.py - Adjust profile
autogen_hintsin YAML - Test with different confidence thresholds
- Monitor logs:
docker compose logs -f learning-mcp
- Check port 8013 is accessible
- Verify
/mcpendpoint responds:curl http://localhost:8013/mcp - Check Docker logs:
docker compose logs learning-mcp
- Test with
/debug/embedendpoint - Check
OLLAMA_HOSTorCF_API_TOKENis correct - Verify dimension matches:
profile.embedding.dim== model output
- Check if documents are ingested:
GET /config/profile/{name} - Verify chunk size appropriate for content
- Try different embedding models
- Increase
top_kfor more results
- Check suggested_queries in response
- Run those queries with
search_docsmanually - Verify documentation has concrete examples
- Adjust
require_example_in_evidencein profile
- FastMCP Documentation: https://gofastmcp.com/
- AutoGen Documentation: https://microsoft.github.io/autogen/
- Qdrant Documentation: https://qdrant.tech/documentation/
- Model Context Protocol: https://modelcontextprotocol.io/
See Main README for contribution guidelines.
See Main README for license information.