How dremio/dremio-mcp works
Project Type & Purpose
• This is a Python‐based CLI application that implements an MCP (Model Context Protocol) server.
• It sits between an LLM frontend (e.g., Claude Desktop) and Dremio’s REST API (and optionally Prometheus).
• It exposes “tools” (data pattern discovery, introspection, metrics) via MCP messages.
Main Components
A. External Clients & Services
1. LLM Frontend (Claude Desktop)
2. Dremio Engine (REST API)
3. Prometheus (optional)
B. CLI & Entry Point
1. uv / Typer CLI
2. Commands: run, config, tools
C. MCP Server Core
1. Transport Layer (src/dremioai/api/transport.py) – handles JSON MCP messages over STDIN/STDOUT or HTTP.
2. Protocol Router – dispatches messages to tool implementations.
D. Tool Implementations (src/dremioai/tools/tools.py)
1. Data Patterns
2. Self-Introspection
3. Prometheus Metrics
E. API Clients
1. Dremio API modules (src/dremioai/api/dremio/*.py)
2. OAuth2 (src/dremioai/api/oauth2.py)
3. Prometheus client (src/dremioai/api/prometheus/vm.py)
F. Configuration & Utilities
1. Settings loader (src/dremioai/config/settings.py)
2. Tool registry (src/dremioai/config/tools.py)
3. Logging (src/dremioai/log.py)
G. Framework Adapters (for testing/integration)
1. LangChain adapter (src/dremioai/servers/frameworks/langchain/*.py)
2. BeeAI adapter (src/dremioai/servers/frameworks/beeai/*.py)
Relationships & Data Flow
• Claude → MCP Server Core (MCP JSON requests)
• MCP Core → Transport → Protocol Router → Tool implementation
• Tool → API Client → Dremio or Prometheus
• API response → Tool logic → MCP response → Claude
• Config/Settings used by CLI and MCP Core at startup
• Framework Adapters wrap the MCP Core for local/testing harnesses
Architectural Patterns & Principles
• Modular layering: CLI → Protocol/Transport → Tools → API Clients → External Services
• Plugin‐style tool registration (register new MCP tools via tools.py)
• Separation of concerns: each API domain in its own module, config isolated
• Adapters for different agent frameworks (LangChain, BeeAI)
Don’t Overthink—Capture Everything
• Break the server into as many logical components as you see in the file tree.
• Even small modules (e.g., src/dremioai/api/util.py) can be shown as utilities.
• The more explicit you are, the easier it is to see extension points and data flows.