Skip to content

feat(mark3labs): add adapter for mark3labs/mcp-go [AP-14]#7

Closed
RobertoIskandarani wants to merge 1 commit into
mainfrom
robertoiskandarani/ap-14-build-adapter-for-mark3labsmcp-go
Closed

feat(mark3labs): add adapter for mark3labs/mcp-go [AP-14]#7
RobertoIskandarani wants to merge 1 commit into
mainfrom
robertoiskandarani/ap-14-build-adapter-for-mark3labsmcp-go

Conversation

@RobertoIskandarani

Copy link
Copy Markdown

Summary

  • New module github.com/authplane/go-sdk/mark3labs — Authplane adapter for mark3labs/mcp-go, parallel to the existing official-SDK adapter at go-sdk/mcp/. Mirrors the Python authplane-fastmcp package referenced as the example in the ticket.
  • Surface: Adapter, NewAdapter, AuthMiddleware, HTTPContextFunc (bridges claims into the mark3labs per-tool-call context via server.WithHTTPContextFunc(...)), ProtectedResourceMetadataHandler, ClaimsFromContext/TokenFromContext, TokenExchange, ConsentElicitationError, typed URLElicitationError.
  • Closes AP-14.

Note: opened against AuthPlane/go-sdk because AuthPlaneLabs/go-sdk currently has forking disabled and grants the author READ-only — once write access or forking is enabled there, this can move over.

Design notes

  • Bearer parsing & WWW-Authenticate done directly in AuthMiddleware — no auth.RequireBearerToken shim needed, since mark3labs/mcp-go doesn't use it. Header is RFC 6750 §3.1 quoted from the start (no quoter post-processor), and error_description is sanitised so verifier messages can't inject extra header lines.
  • Context bridge: adapter.HTTPContextFunc() is paired with server.WithHTTPContextFunc(...) to forward claims/token from the HTTP request context into the per-tool-call MCP context (without this option mark3labs/mcp-go gives tool handlers a fresh ctx).
  • URL elicitation caveat: mark3labs/mcp-go coerces every error returned from a tool handler to JSON-RPC -32603 (INTERNAL_ERROR); custom codes like -32042 don't propagate. Documented prominently in docs/user-guide.md §7.2 and demo/README.md, alongside the recommended IsError: true CallToolResult workaround — same trade-off the Python FastMCP adapter calls out.
  • PRM: we mount our own ProtectedResourceMetadataHandler instead of mark3labs' built-in server.WithProtectedResourceMetadata(...) so the PRM JSON stays byte-identical across Authplane adapters.

Module / workspace changes

  • New module go-sdk/mark3labs/ registered in go.work.
  • go.work Go floor bumped 1.25.0 → 1.25.5 (mark3labs/mcp-go v0.54.0 requires >= 1.25.5). Sibling modules (core, http, mcp) continue to build and pass tests.

Test plan

  • cd mark3labs && go build ./... — clean
  • cd mark3labs && go vet ./... — clean
  • cd mark3labs && go test ./... — 27 tests passing (bearer parsing, claims injection, ES256, expired/missing tokens, PRM, introspection regression, HTTPContextFunc bridge, consent→elicitation mapping, MarshalData payload shape)
  • Sibling modules unaffected: core, http, mcp all green after the go.work bump
  • Manual run of demo/ against the local authserver (reviewer)

🤖 Generated with Claude Code

Mirrors the python-sdk authplane-fastmcp package: a parallel adapter for
the popular community Go MCP library, alongside the existing official-SDK
adapter at go-sdk/mcp/. Validates JWTs, serves RFC 9728 PRM, bridges
verified claims into the per-tool-call MCP context via HTTPContextFunc,
and maps RFC 8693 consent errors to URLElicitationError (with a
documented propagation caveat for mark3labs/mcp-go's tool error coercion).

- pkg/authplanemark3labs: Adapter, AuthMiddleware, HTTPContextFunc, PRM
  handler, ClaimsFromContext/TokenFromContext, TokenExchange,
  ConsentElicitationError, URLElicitationError
- demo/: calculator service using mark3labs/mcp-go server + adapter
- README.md + docs/user-guide.md
- go.work: register module, bump go floor to 1.25.5 (mark3labs/mcp-go
  v0.54.0 requires it)

27 tests, all green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@RobertoIskandarani
RobertoIskandarani requested a review from a team as a code owner May 19, 2026 20:28
@RobertoIskandarani
RobertoIskandarani deleted the robertoiskandarani/ap-14-build-adapter-for-mark3labsmcp-go branch May 19, 2026 20:29
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