A high-performance MCP (Model Context Protocol) server for documentation management and AI-powered assistance with any type of technical documentation.
Agent Docs is a flexible documentation server that provides AI-powered assistance across various technical domains. It combines:
- MCP Protocol Support - Standardized AI assistant integration
- Vector Search - Semantic search through any documentation using embeddings
- Configurable Tools - Customizable toolset for different documentation types
- Multi-format Support - JSON-RPC and HTTP transport layers
- Production Ready - Docker containerization and Kubernetes deployment
This project is organized as a Rust workspace with specialized crates:
mcp/: Main MCP server implementation with HTTP transportdb/: PostgreSQL database layer with pgvector integrationembed/: OpenAI embedding client for vector operationsloader/: Data loading and ingestion pipeline
- Configurable MCP Tools - Extensible toolset for any documentation type
- Vector Embeddings - Semantic search through custom documentation
- Batch Processing - Efficient document processing with cost optimization
- Real-time Updates - Live documentation synchronization
- Health Monitoring - Comprehensive metrics and observability
- Multi-Domain Support - APIs, protocols, frameworks, and technical docs
- Rust 1.70+
- PostgreSQL 15+ with pgvector extension
- Docker (for containerized deployment)
-
Clone the repository
git clone https://github.com/5dlabs/agent-docs.git cd agent-docs -
Set up the database
# Create PostgreSQL database with pgvector createdb agent_docs psql agent_docs -c "CREATE EXTENSION vector;"
-
Configure environment
cp .env.example .env # Edit .env with your database URL and API keys -
Run the server
cargo run -p mcp --bin http_server
The server will start on http://localhost:3001 with health checks available at /health.
Build an image with the included Dockerfile and run it with your environment:
docker build -t agent-docs .
docker run --rm -p 3001:3001 \
--env-file .env \
-v $(pwd)/tools.json:/app/tools.json:ro \
agent-docsNote: The container expects DATABASE_URL and (optionally) OPENAI_API_KEY. See .env.example.
Key variables used by the server and helpers:
DATABASE_URL: PostgreSQL connection string (required)OPENAI_API_KEY: OpenAI API key for embeddings (optional if embeddings are not used locally)PORTorMCP_PORT: Server port (defaults to 3001)MCP_HOST: Bind address (defaults to 0.0.0.0)RUST_LOG: Logging level (e.g.,info,doc_server=debug)MCP_ENABLE_SSE: Enable experimental SSE onGET /mcpwhen set to1ortrue(defaults to disabled;GET /mcpreturns 405). This keeps acceptance tests green while allowing opt-in SSE during development.- Note: When enabled, the SSE stream now relays per-session responses and periodic keepβalives.
MCP_ALLOWED_ORIGINS: Comma-separated list of allowed origins for POST security checks (default allows localhost variants only). Example:https://cursor.sh,https://your.domainMCP_STRICT_ORIGIN_VALIDATION: Iftrue, enforce scheme + allowβlist checks onOriginheader for POST (default:true). Set tofalseto be permissive for native clients that sendOrigin: null.MCP_REQUIRE_ORIGIN_HEADER: Iftrue, requireOriginheader on all POST requests (default:false).MCP_LOCALHOST_ONLY: Iftrue, restrict server bind validation to localhost (default:true). Has effect when usingMcpServer::serve.TOOLS_CONFIG_PATHorTOOLS_CONFIG: Path or inline JSON for tool configurationLOADER_BIN: Path to the loader binary (defaults to/app/loaderin container)CLAUDE_BINARY_PATH: Path to Claude Code binary (defaults toclaude)
The server requires PostgreSQL with the pgvector extension for vector operations:
-- Enable required extensions
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "vector";The server implements the Model Context Protocol for AI assistant integration:
// Tool discovery
POST /mcp
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}
// Tool execution
POST /mcp
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "your_doc_query",
"arguments": {
"query": "search term or question",
"docType": "your_doc_type",
"limit": 10
}
}
}The server provides an asynchronous endpoint to ingest a GitHub repository using the bundled loader binary and Claude Code for intelligent discovery.
See also: docs/llm-roles.md for the clear separation of LLM responsibilities.
-
POST
/ingest/intelligent- Body:
{ "url": "https://github.com/org/repo", "doc_type": "<required>" } - Returns:
{ "job_id": "<uuid>" } - Behavior: enqueues ingestion and returns immediately. The
doc_typeyou supply is enforced for DB insertion.
- Body:
-
GET
/ingest/jobs/{job_id}- Returns:
{ status: queued|running|succeeded|failed, started_at, finished_at, error? }
- Returns:
Requirements
DATABASE_URLmust be set for the serverLOADER_BINdefaults to/app/loaderCLAUDE_BINARY_PATHdefaults toclaude
- Claude Code: used only for intelligent document ingestion and discovery (repo analysis and strategy). No fallback to OpenAI.
- OpenAI: used only for embeddings and batch/vector operations (search, similarity). Not used for ingestion/discovery.
For details, refer to docs/llm-roles.md.
Example
curl -s -X POST http://localhost:3001/ingest/intelligent \
-H 'Content-Type: application/json' \
-d '{"url":"https://github.com/cilium/cilium","doc_type":"cilium","yes":true}'
# => { "job_id": "8ab7b0a8-β¦" }
curl -s http://localhost:3001/ingest/jobs/8ab7b0a8-β¦
# => { "status": "running", β¦ }The loader binary performs on-host ingestion. Claude Code only proposes a plan; loader executes it.
-
Intelligent (Claude-guided):
- Server calls discovery to analyze the repo and generate a plan, then executes steps (typically
git cloneβloader cliβloader database). LOADER_BINcan point to a packaged loader binary used for plan execution.
- Server calls discovery to analyze the repo and generate a plan, then executes steps (typically
-
CLI (direct parse):
cargo run -p loader -- cli <path> --extensions md,rs,txt,json,yaml,toml --recursive -o ./out- Parses files with the UniversalParser and writes
DocPageJSON to the output directory. Used by analyzer-generated plans.
-
Database (load JSON docs):
cargo run -p loader -- database --input-dir ./out --doc-type <type> --source-name <name> --yes- Inserts previously emitted JSON docs into PostgreSQL.
Note: Legacy github and web subcommands were removed. Use the intelligent ingest endpoint for repo ingestion and the CLI for local parsing.
The system is highly configurable and can work with any type of documentation. Tools are defined in the tools.json configuration file, allowing you to:
- Query Tools: Search and retrieve information from documentation
- Management Tools: Add, remove, and manage documentation sources
- Custom Documentation Types: Support any documentation format or source
Tools are configured in tools.json with the following structure:
{
"tools": [
{
"name": "your_doc_query",
"docType": "your_doc_type",
"title": "Your Documentation Query",
"description": "Search your custom documentation...",
"enabled": true,
"metadataHints": {
"supported_formats": ["markdown", "html", "pdf"],
"supported_categories": ["api", "guides", "examples"],
"custom_metadata": "any additional configuration"
}
}
]
}The system supports various documentation sources:
- API Documentation (OpenAPI, GraphQL, REST APIs)
- Code Documentation (Rust crates, libraries, frameworks)
- Technical Documentation (architecture, deployment, operations)
- Protocol Documentation (blockchain, networking, standards)
- Educational Content (tutorials, guides, best practices)
- Query Tools (
*_query) - Search documentation by type - Management Tools (
add_*,remove_*,list_*) - Manage content - Status Tools (
check_*_status) - System health and statistics
Each tool can be:
- β Enabled/Disabled individually
- β Configured with custom metadata hints
- β Extended with new documentation types
- β Monitored for performance and usage
To add support for new documentation types:
- Define the tool in
tools.json:
{
"name": "kubernetes_query",
"docType": "kubernetes",
"title": "Kubernetes Documentation Query",
"description": "Search Kubernetes documentation and best practices",
"enabled": true,
"metadataHints": {
"supported_formats": ["markdown", "yaml"],
"supported_categories": ["pods", "services", "deployments", "configmaps"],
"supported_versions": ["v1.24+", "latest"]
}
}- Configure data ingestion for your documentation source
- Restart the server to load the new configuration
- Test the new tool via MCP protocol
The system automatically creates:
- Query tool:
kubernetes_query - Management tools:
add_kubernetes,remove_kubernetes,list_kubernetes - Status tool:
check_kubernetes_status
# Build production image
docker build -t agent-docs:latest .
# Run container
docker run -p 3001:3001 \
-e DATABASE_URL="postgresql://..." \
-e OPENAI_API_KEY="..." \
agent-docs:latestThe project includes production-ready Kubernetes manifests:
# Deploy to Kubernetes
kubectl apply -f k8s/
# Check deployment status
kubectl get pods -l app=doc-serverGitHub Actions workflow provides:
- Automated Testing - Unit and integration tests
- Code Quality - Clippy linting and formatting
- Security Scanning - Vulnerability assessment
- Docker Build - Multi-platform image building
- Kubernetes Deployment - Automatic rollout updates
# Health endpoint
curl http://localhost:3001/health
# Metrics endpoint
curl http://localhost:3001/metrics# View application logs
kubectl logs -l app=doc-server
# Follow logs in real-time
kubectl logs -f -l app=doc-servercargo test# Run with database
TEST_DATABASE_URL="postgresql://..." cargo test --test integration# Run performance benchmarks
./scripts/performance-benchmark.sh
# Cost validation
./scripts/cost-validation.shβββ mcp/ # Main MCP server
β βββ src/
β β βββ bin/ # Server binaries
β β βββ handlers/ # Request handlers
β β βββ tools/ # MCP tool implementations
β β βββ transport/ # HTTP transport layer
β βββ tests/ # Integration tests
βββ db/ # Database layer
βββ embed/ # Embedding service
βββ llm/ # LLM client
βββ loader/ # Data ingestion
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Ensure CI passes
- Submit a pull request
# Format code
cargo fmt
# Lint code
cargo clippy --workspace --all-targets --all-features -- -D warnings
# Run tests with coverage
cargo llvm-cov --workspace --all-features --lcov --output-path lcov.infoThis project is licensed under the terms specified in the LICENSE file.
For issues and questions:
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: See
docs/directory for detailed guides
See CHANGELOG.md for version history and updates.
Test PR Note: This is a test pull request to verify CI/CD deployment conditions.
Built with β€οΈ using Rust