Skip to content

Add MCP server endpoint at /mcp#177

Open
zer0stars wants to merge 1 commit intomainfrom
feat/mcp-server
Open

Add MCP server endpoint at /mcp#177
zer0stars wants to merge 1 commit intomainfrom
feat/mcp-server

Conversation

@zer0stars
Copy link
Copy Markdown
Member

Summary

Adds an MCP (Model Context Protocol) endpoint at /mcp so LLM-based agents can discover and query the identity API via the standard MCP Streamable HTTP transport.

What's new

  • /mcp endpoint — Serves MCP tools backed by the existing GraphQL API. Executes queries internally (no network hop) with full dataloader support.
  • @mcpTool directive — Annotates commonly used queries in the GraphQL schema. The codegen tool reads these to generate typed shortcut tools.
  • No auth required — identity-api is a public read API, so the MCP handler is mounted without auth middleware (same as /query).

MCP tools exposed

Tool Description
identity_get_schema Returns the GraphQL schema via introspection
identity_query Executes arbitrary GraphQL queries
identity_get_vehicle Look up a vehicle by token ID or DID
identity_list_vehicles List vehicles with optional filters

Dependencies

  • Requires server-garage#25 (pkg/mcpserver + cmd/mcpgen)
  • Uses go mod replace for local development — will be updated to a tagged version after server-garage is merged

Files changed

  • graph/schema/directives.graphqls@mcpTool directive definition
  • graph/schema/vehicle.graphqls@mcpTool annotations on vehicle and vehicles queries
  • graph/mcp_tools_gen.go — Generated tool definitions (via mcpgen)
  • graph/resolver.go — Added //go:generate mcpgen directive
  • gqlgen.ymlmcpTool: skip_runtime: true
  • cmd/identity-api/main.go — Mount MCP handler at /mcp

Test plan

  • Builds cleanly
  • Existing tests unaffected
  • Smoke test /mcp endpoint locally with MCP client
  • Verify identity_get_schema returns introspection data
  • Verify identity_get_vehicle returns vehicle data

@zer0stars zer0stars requested a review from elffjs as a code owner March 25, 2026 15:58
@zer0stars zer0stars force-pushed the feat/mcp-server branch 3 times, most recently from 7910f8f to 1a53a2a Compare March 26, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant