MCP Server Configuration

MDDB has a built-in MCP (Model Context Protocol) server implementing the 2025-11-25 specification. This document covers all MCP configuration options.

โ†’ LLM client setup (Claude, Cursor, ChatGPT, Ollama) | โ†’ Custom YAML tools

Transports

TransportEndpointSpec VersionStatus
Stdiostdin/stdout2025-11-25Default for Claude Desktop
Streamable HTTPPOST/GET/DELETE /mcp2025-11-25Recommended for remote
SSE (legacy)GET /sse + POST /message2024-11-05Backward compatible

All transports run on the MCP port (default: 9000, configurable via MDDB_MCP_ADDR).

Streamable HTTP (Recommended)

curl -X POST http://localhost:9000/mcp \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' 

Client Configuration

{ "mcpServers": { "mddb": { "transport": "streamable-http", "url": "http://localhost:9000/mcp" } }
}

Environment Variables

Core

Env VarDefaultDescription
MDDB_MCP_ENABLEDtrueEnable MCP HTTP server
MDDB_MCP_ADDR:9000MCP HTTP listen address
MDDB_MCP_PORT9000MCP HTTP port (alternative to ADDR)
MDDB_MCP_STDIOfalseRun in MCP stdio mode (replaces HTTP/gRPC)
MDDB_MCP_DOMAINโ€”Server hostname for Panel config generation
MDDB_MCP_MODEโ€”Access mode override: read, write, or wr (inherits MDDB_MODE)

Server Info

Env VarDefaultDescription
MDDB_MCP_SERVER_NAMEmddbdServer name in MCP initialize response
MDDB_MCP_SERVER_DESCRIPTIONโ€”Server description
MDDB_MCP_SERVER_VENDORโ€”Vendor name
MDDB_MCP_SERVER_HOMEPAGEโ€”Homepage URL
MDDB_MCP_INSTRUCTIONSโ€”System prompt for LLM โ€” guidance on how to use this server

Tools

Env VarDefaultDescription
MDDB_MCP_CONFIGโ€”Path to YAML file with custom tool definitions
MDDB_MCP_BUILTIN_TOOLStrueSet to false to hide all 67 built-in tools (only custom tools exposed)

API Key Authentication

Env VarDefaultDescription
MDDB_MCP_API_KEY_ENABLEDfalseRequire API key for MCP HTTP access
MDDB_MCP_API_KEYSโ€”Static keys: key1:name1,key2:name2 (defined at startup)
MDDB_MCP_API_KEY_CACHE_TTL60sCache TTL for dynamic key lookups

Two sources of keys:

  • Static โ€” MDDB_MCP_API_KEYS env var (defined at startup, no restart needed to validate)
  • Dynamic โ€” REST API (/v1/mcp/keys) stored in BoltDB, persists across restarts, managed without downtime

Clients authenticate via:

  • X-API-Key: <key> header
  • Authorization: Bearer <key> header
  • ?api_key=<key> query parameter (for SSE connections)
docker run -d \ -e MDDB_MCP_API_KEY_ENABLED=true \ -e "MDDB_MCP_API_KEYS=sk-prod:claude-prod,sk-dev:cursor-dev" \ -p 9000:9000 \ tradik/mddb:latest

Dynamic Key Management API

Keys stored in internal BoltDB bucket (_mcp_api_keys). Requires admin auth when MDDB_AUTH_ENABLED=true.

curl -X POST http://localhost:11023/v1/mcp/keys \ -H "Authorization: Bearer <admin-token>" \ -d '{"name": "claude-prod", "expiresAt": 0}' curl http://localhost:11023/v1/mcp/keys \ -H "Authorization: Bearer <admin-token>" curl -X DELETE http://localhost:11023/v1/mcp/keys \ -H "Authorization: Bearer <admin-token>" \ -d '{"key": "mcp_a1b2c3d4e5f6..."}' curl -X POST http://localhost:11023/v1/mcp/keys/disable \ -H "Authorization: Bearer <admin-token>" \ -d '{"key": "mcp_a1b2c3d4e5f6..."}'

Key features:

  • TTL support โ€” expiresAt Unix timestamp (0 = never expires)
  • Disable without delete โ€” revoke instantly, keep for audit
  • Cache โ€” lookups cached for MDDB_MCP_API_KEY_CACHE_TTL (default 60s), auto-invalidated on create/delete/disable
  • Panel UI โ€” manage keys from the web panel (LLM Connections โ†’ API Keys tab)

Rate Limiting

Env VarDefaultDescription
MDDB_MCP_RATE_LIMIT_ENABLEDfalseEnable per-client rate limiting
MDDB_MCP_RATE_LIMIT_REQUESTS100Max requests per window
MDDB_MCP_RATE_LIMIT_WINDOW60Window duration in seconds
MDDB_MCP_RATE_LIMIT_BURST20Burst allowance above limit
MDDB_MCP_RATE_LIMIT_BYipRate limit key: ip, api_key, or session

Response headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset. Returns 429 Too Many Requests with Retry-After header when exceeded.

Request Logging

Env VarDefaultDescription
MDDB_MCP_LOGGING_ENABLEDfalseEnable structured JSON audit logs
MDDB_MCP_LOGGING_LEVELinfoLog level: debug, info, warn, error

Logs are written to stderr in JSON format:

{"timestamp":"2026-03-26T10:30:00Z","method":"POST","path":"/mcp","status":200,"duration_ms":45,"client_ip":"1.2.3.4","key_name":"claude-prod","session_id":"abc123","user_agent":"claude-code/1.0"}

Access Modes

Each protocol can have its own read/write mode:

Env VarProtocolDefault
MDDB_MODEGlobalwr
MDDB_API_MODEHTTP/REST + GraphQLinherits global
MDDB_GRPC_MODEgRPCinherits global
MDDB_MCP_MODEMCP (all transports)inherits global
MDDB_HTTP3_MODEHTTP/3 (QUIC)inherits global

In read-only mode:

  • Built-in tools with readOnlyHint=true (search, stats, list, export) โ†’ allowed
  • Built-in tools with writes/deletes โ†’ blocked with error
  • Custom tools with read-only actions (semantic_search, search_documents, full_text_search) โ†’ allowed
  • Custom tools with write actions โ†’ blocked
docker run -d \ -e MDDB_MCP_MODE=read \ -e MDDB_MCP_BUILTIN_TOOLS=false \ -e MDDB_MCP_API_KEY_ENABLED=true \ -e "MDDB_MCP_API_KEYS=sk-public:external" \ -e MDDB_MCP_RATE_LIMIT_ENABLED=true \ -e MDDB_MCP_RATE_LIMIT_REQUESTS=60 \ -e MDDB_MCP_LOGGING_ENABLED=true \ -e MDDB_MCP_CONFIG=/app/tools.yml \ tradik/mddb:latest

Protocol Features (2025-11-25)

FeatureDescription
Tool AnnotationsreadOnlyHint, destructiveHint, idempotentHint, openWorldHint on all tools
Structured OutputoutputSchema on 9 key tools for client-side validation
5 Promptsanalyze-collection, search-help, summarize-collection, import-guide, rag-pipeline
CompletionAutocomplete for collection names and prompt arguments
Logginglogging/setLevel with RFC 5424 levels (debug โ†’ emergency)
Progress Tokensnotifications/progress for long-running operations
Cursor Paginationtools/list and resources/list
Notificationsnotifications/initialized, notifications/cancelled
Memory RAG Tools6 tools for conversational memory: start session, add message, recall, summarize, list sessions, history

Memory RAG Tools

Built-in MCP tools for conversational memory and RAG:

ToolDescriptionWrite?
memory_start_sessionStart a new conversation sessionYes
memory_add_messageAdd a message (auto-embedded)Yes
memory_recallSemantic/hybrid/keyword recall across sessionsNo
memory_summarizeGenerate and store session summaryYes
memory_list_sessionsList sessions with filtersNo
memory_session_historyGet chronological message historyNo

Example: Agent with Memory

// 1. Start session
{"name": "memory_start_session", "arguments": {"user_id": "user-1", "scenario": "support"}} // 2. Store messages as conversation progresses
{"name": "memory_add_message", "arguments": {"session_id": "abc...", "role": "user", "content": "How do I use vector search?"}}
{"name": "memory_add_message", "arguments": {"session_id": "abc...", "role": "assistant", "content": "Use POST /v1/vector-search..."}} // 3. In a future session, recall relevant context
{"name": "memory_recall", "arguments": {"query": "vector search usage", "user_id": "user-1", "top_k": 5, "include_content": true}} // 4. Summarize when done
{"name": "memory_summarize", "arguments": {"session_id": "abc..."}}

Built-in Prompts

PromptArgumentsDescription
analyze-collectioncollection (required)Document count, metadata keys, content patterns, suggestions
search-helpuse_case (required)Which search method to use for your use case
summarize-collectioncollection (required), limitTopic overview, themes, distribution
import-guidesource (required)Step-by-step import from wordpress/url/file/api/scraping
rag-pipelinecollection (required), modelRAG pipeline design with embedding and search strategy

โ† Back to README | โ†’ LLM Connections | โ†’ Custom Tools