feat(server): add MCP server for telemetry analysis#236
Draft
mbrobbel wants to merge 2 commits into
Draft
Conversation
Expose the query-engine analyzer surface over the Model Context Protocol so agents can connect to a running quent server and explore telemetry. The MCP server is generic over `UiAnalyzer` and reuses the existing `ServiceState` (analyzer + timeline caches), so out-of-repo analyzers get it for free. It is gated behind a new `mcp` feature on `quent-query-engine-server`, alongside the existing `swagger`/`ui` features. Two transports: - HTTP: a streamable-HTTP service mounted at `/mcp` on the Axum analyzer router. rmcp's loopback-only Host allowlist (a DNS-rebinding guard) is kept by default; non-local deployments opt in via `QUENT_MCP_ALLOWED_HOSTS` (comma-separated hosts, or `*` to disable). When CORS is enabled the layer also allows the MCP session/protocol and SSE-resume headers. - stdio: `serve_stdio` plus a `quent-simulator-mcp` example binary. Tools mirror the REST endpoints (list_engines, get_engine, list_query_groups, list_queries, get_query, single_timeline) and add agent-friendly summaries (engine_overview, plan_tree, slowest_operators). The simulator example shares importer/lister setup between its HTTP and stdio binaries via a new `lib.rs`; `default-run` keeps `cargo run` on the HTTP server when the `mcp` feature adds a second binary. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expose the query-engine analyzer surface over the Model Context Protocol so agents can connect to a running quent server and explore telemetry.
The MCP server is generic over
UiAnalyzerand reuses the existingServiceState(analyzer + timeline caches), so out-of-repo analyzers get it for free. It is gated behind a newmcpfeature onquent-query-engine-server, alongside the existingswagger/uifeatures.Two transports:
/mcpon the Axum analyzer router. rmcp's loopback-only Host allowlist (a DNS-rebinding guard) is kept by default; non-local deployments opt in viaQUENT_MCP_ALLOWED_HOSTS(comma-separated hosts, or*to disable). When CORS is enabled the layer also allows the MCP session/protocol and SSE-resume headers.serve_stdioplus aquent-simulator-mcpexample binary.Tools mirror the REST endpoints (list_engines, get_engine, list_query_groups, list_queries, get_query, single_timeline) and add agent-friendly summaries (engine_overview, plan_tree, slowest_operators).
The simulator example shares importer/lister setup between its HTTP and stdio binaries via a new
lib.rs;default-runkeepscargo runon the HTTP server when themcpfeature adds a second binary.