Skip to content

refactor(registry/types): swap mcp-go import for mcpcompat shim#154

Merged
JAORMX merged 1 commit into
mainfrom
refactor/registry-types-mcpcompat-shim
Jul 7, 2026
Merged

refactor(registry/types): swap mcp-go import for mcpcompat shim#154
JAORMX merged 1 commit into
mainfrom
refactor/registry-types-mcpcompat-shim

Conversation

@JAORMX

@JAORMX JAORMX commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Stop registry/types from importing github.com/mark3labs/mcp-go/mcp directly. Switch both files that reference it to import the mcpcompat/mcp shim (aliased as mcp), whose Tool type is a type alias for mcpgo.Tool — identical type, wire-compatible, source-compatible. This was the last non-shim import of mcp-go in the module.

Unblocks stacklok/toolhive#5729 from carrying mcp-go as a transitive indirect dep.

What changed

Two import-path swaps, zero call-site logic changes:

  • registry/types/publisher_provided_types.go"github.com/mark3labs/mcp-go/mcp"mcp "github.com/stacklok/toolhive-core/mcpcompat/mcp" (sole usage: ToolDefinitions []mcp.Tool).
  • registry/types/registry_types.go — same swap (usages: ToolDefinitions []mcp.Tool, the GetToolDefinitions() []mcp.Tool interface method, and its BaseServerMetadata implementation).

Because mcpcompat/mcp.Tool is a type alias for mcpgo.Tool, all struct tags, JSON marshaling, and the swaggerignore:"true" tag remain identical. The gci linter regrouped the imports so the shim now sits with the other stacklok/toolhive-core imports rather than the third-party block.

What did NOT change

  • mcpcompat/mcp/alias.go is untouched — it remains the single intentional chokepoint that references mcp-go (per its own doc.go).
  • go.mod/go.sum unchanged — go mod tidy made no change. mcp-go stays as a direct dep because the mcpcompat/mcp shim still references it. That's expected and acceptable per the task: the goal is to remove the non-shim import, not the shim itself.
  • No test files in registry/types imported mcp-go directly, so none needed swapping.

Verification

  • go build ./... — clean
  • go vet ./... — clean
  • go test ./registry/types/... ./mcpcompat/... — passes (the wire-format golden tests in mcpcompat pin the JSON shape; unaffected since the type is unchanged)
  • task (lint + test) — green, 0 lint issues
  • Invariant holds: grep -rln "github.com/mark3labs/mcp-go" --include="*.go" . | grep -v "_test.go" | grep -v "mcpcompat/" returns nothing.

Stop registry/types from importing github.com/mark3labs/mcp-go/mcp
directly. Switch both publisher_provided_types.go and registry_types.go
to import the mcpcompat/mcp shim (aliased as `mcp`), whose Tool type is
a type alias for mcpgo.Tool — identical type, wire-compatible,
source-compatible. Zero call-site changes.

This was the last non-shim import of mcp-go in the module; the only
remaining reference is the intentional chokepoint in mcpcompat/mcp/alias.go.

Unblocks stacklok/toolhive#5729 from carrying mcp-go as a transitive
indirect dep.
@JAORMX JAORMX force-pushed the refactor/registry-types-mcpcompat-shim branch from f64c326 to 97f3c4b Compare July 7, 2026 11:39
@JAORMX JAORMX merged commit 536dc85 into main Jul 7, 2026
5 checks passed
@JAORMX JAORMX deleted the refactor/registry-types-mcpcompat-shim branch July 7, 2026 11:42
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.

2 participants