Re-land MCP server library and codegen tool#31
Merged
Conversation
Adds pkg/mcpserver (MCP-over-HTTP wrapper around gqlgen executors) and cmd/mcpgen (code generator that reads @mcptool directives from GraphQL schemas and emits Go tool definitions). Features: - Context + version propagation through New() - WithTools / WithCondensedSchema / WithStateless / WithMaxQuerySize / WithTokenVerifier / WithLogger options - Built-in {prefix}_get_schema + {prefix}_query tools per service - Pre-warmed schema introspection cache - Bearer token auth middleware (opt-in) - Prometheus metrics: mcp_tool_calls_total, mcp_tool_duration_seconds - Condensed SDL generation for LLM-friendly schema summaries - Full tool annotations (readOnly, destructive hints) - Dual logging: zerolog (infra) + slog (MCP SDK convention) Consumer integration pattern: h, err := mcpserver.New(ctx, mcpserver.NewGQLGenExecutor(es), "DIMO <name>", version, prefix, mcpserver.WithTools(graph.MCPTools), mcpserver.WithCondensedSchema(graph.CondensedSchema)) Downstream PRs wire this into identity-api, telemetry-api, fetch-api.
cloudevent v1.0.x predates v0.2.x chronologically (v0.2.7 released 2026-04-13 vs v1.0.4 on 2026-03-10). Go's MVS selects the higher semver, which pulls in the older API without RawEventID, breaking downstream consumers (fetch-api) that rely on the field. Pin here so MVS consistently picks v0.2.7.
5 tasks
Fix CI lint failures: check json.Unmarshal return, wrap resp.Body.Close in deferred func to ignore error explicitly, and drop a staticcheck SA9003 empty-branch in condensed_sdl paragraph loop.
This was referenced Apr 18, 2026
mcpgen: stronger self-evident filtering (drop-entirely vs strip-only prefixes, morphological stems), global + per-category legend-fold on signal table, scalar description trim. mcpserver: remove dead introspection loadSchema path. WithCondensedSchema is now required; New() no longer takes a ctx arg. Shrinks downstream LLM context by ~18%.
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.
Summary
Re-lands
pkg/mcpserver+cmd/mcpgen. The original PR #25 was merged on 2026-03-26 butmainwas subsequently force-reset back todc13a15— the merge commit1419fc7is not in main's history, so the code is effectively absent.This PR ports the richer version (SDK v1.4.1, condensed SDL codegen, full option set, complete test coverage) rather than the slimmed-down
96a839cthat was briefly on main.What's included
pkg/mcpserver/— MCP-over-HTTP wrapper around gqlgen executorsNew(ctx, exec, name, version, prefix, opts...)with functional options{prefix}_get_schema+{prefix}_querytoolsWithTokenVerifier)mcp_tool_calls_total,mcp_tool_duration_secondscmd/mcpgen/— reads@mcpTooldirectives from.graphqls, emits Go tool definitions + condensed SDLConsumer wiring (downstream PRs)
Downstream PRs already in flight:
Test plan
go build ./...cleango test ./...green (mcpserver + mcpgen)v0.1.0after merge