Skip to content

feat(bazaar): add MCP resource type support to Go SDK#1967

Open
avidreder wants to merge 3 commits intox402-foundation:mainfrom
avidreder:feat/golang-bazaar-mcp
Open

feat(bazaar): add MCP resource type support to Go SDK#1967
avidreder wants to merge 3 commits intox402-foundation:mainfrom
avidreder:feat/golang-bazaar-mcp

Conversation

@avidreder
Copy link
Copy Markdown
Contributor

Summary

  • Add MCP tool discovery extension types (McpInput, McpTransport, McpDiscoveryInfo, DeclareMcpDiscoveryConfig) to the shared types package and re-export from bazaar
  • Add DeclareMcpDiscoveryExtension() for servers to declare MCP tool resources with tool name, input schema, transport, description, and example
  • Update DiscoveryInfo.UnmarshalJSON to discriminate type: "mcp" from HTTP inputs, enabling correct JSON round-trips
  • Add MCP bypass in EnrichDeclaration() so MCP extensions pass through without HTTP method narrowing or dynamic route extraction
  • Extend DiscoveredResource with ToolName field and update both ExtractDiscoveredResourceFromPaymentPayload and ExtractDiscoveredResourceFromPaymentRequired to handle MCP extraction
  • Achieves parity with the TypeScript and Python SDKs for MCP bazaar resource support

Test plan

  • All existing HTTP bazaar tests pass (no regressions)
  • TestDeclareMcpDiscoveryExtension — full config, minimal config, missing toolName/inputSchema errors, transport variants
  • TestValidateDiscoveryExtension_MCP — schema validation passes for MCP extensions
  • TestDiscoveryInfoUnmarshalJSON_MCP — JSON round-trip correctly produces McpInput
  • TestExtractDiscoveredResourceFromPaymentPayload_MCP — v2 MCP extension in PaymentPayload extracts ToolName
  • TestExtractDiscoveredResourceFromPaymentRequired_MCP — v2 MCP in PaymentRequired
  • TestBazaarResourceServerExtension_MCP — EnrichDeclaration passes MCP through unchanged (including with dynamic route context)
  • TestExtractDiscoveryInfoFromExtension_MCP — direct extraction from MCP extension
  • Full SDK test suite: go test ./... passes

🤖 Generated with Claude Code

Add MCP tool discovery extensions to the bazaar package, achieving
parity with the TypeScript and Python SDKs. Servers can now declare
MCP tool discovery extensions alongside HTTP resources, and facilitators
can detect and extract them from payment payloads.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions bot added go sdk Changes to core v2 packages labels Apr 8, 2026
avidreder and others added 2 commits April 8, 2026 14:46
Co-Authored-By: Claude <noreply@anthropic.com>
…e tests

- Fix transport schema enum to include both valid values (streamable-http,
  sse) instead of only the provided value, matching TypeScript SDK behavior
- Fix doc.go examples to use bazaar.BAZAAR.Key() instead of bazaar.BAZAAR
- Inline createMcpDiscoveryExtension into DeclareMcpDiscoveryExtension
- Add negative validation tests for wrong type and empty toolName
- Add edge case tests for whitespace-only toolName and invalid transport

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go sdk Changes to core v2 packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant