Expand description
Model Context Protocol (MCP) HTTP handlers.
Exposes Materialize data products to AI agents via JSON-RPC 2.0 over HTTP POST.
Β§Endpoints
/api/mcp/agents- User data products for customer AI agents/api/mcp/observatory- System catalog (mz_*) for troubleshooting
Β§Tools
Agents: get_data_products, get_data_product_details, query
Observatory: query_system_catalog
Data products are discovered via mz_internal.mz_mcp_data_products system view.
ModulesΒ§
- error_
codes π - JSON-RPC 2.0 error codes.
StructsΒ§
- Capabilities π
- Client
Info π - Content
Block π - GetData
Product πDetails Params - Initialize
Params π - Initialize
Result π - McpError π
- McpRequest π
- JSON-RPC 2.0 request. Requests have
id; notifications donβt. - McpResponse π
- Query
Params π - Query
System πCatalog Params - Server
Info π - Table
Reference πCollector - Collects table references from SQL AST with their schema qualification.
- Tool
Content πResult - Tool
Definition π - Tools
List πResult
EnumsΒ§
- McpEndpoint
Type π - McpMethod π
- MCP method variants with their associated parameters.
- McpRequest
Error π - MCP request errors, mapped to JSON-RPC error codes.
- McpResult π
- Typed MCP response results.
- Tools
Call πParams - Tool call parameters, deserialized via adjacently tagged enum.
Serde maps
nameto the variant andargumentsto the variantβs data.
ConstantsΒ§
- DISCOVERY_
QUERY π
FunctionsΒ§
- execute_
query π - execute_
sql π - Execute SQL via
execute_requestfrom sql.rs. - get_
data_ πproduct_ details - get_
data_ πproducts - handle_
initialize π - handle_
mcp_ agents - Agents endpoint: exposes user data products.
- handle_
mcp_ πmethod - handle_
mcp_ observatory - Observatory endpoint: exposes system catalog (mz_*) only.
- handle_
mcp_ πrequest - handle_
mcp_ πrequest_ inner - handle_
tools_ πcall - handle_
tools_ πlist - query_
system_ πcatalog - validate_
readonly_ πquery - Validates query is a single SELECT, SHOW, or EXPLAIN statement.
- validate_
system_ πcatalog_ query - Validates query references only mz_* system catalog tables.