stacklok / stacklok/toolhive

mcpcompat shim advertises only {logging:{}} instead of capabilities.tools and capabilities.resources

Open
#5,769 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Context

While writing regression tests for the mcp-go → go-sdk migration (#5742), a critical capability advertisement regression was discovered in github.com/stacklok/toolhive-core/mcpcompat v0.0.27.

Finding

A spec-compliant client initializing against vMCP receives capabilities: {"logging":{}} in the initialize result. The capabilities.tools and capabilities.resources fields are absent.

This is because per-session tool registration (via SetSessionTools) happens AFTER the initialize response is constructed — the OnRegisterSession hook fires after the response is written. The server-level advertised capabilities never reflect the per-session tools/resources.

Impact: Clients that gate tools/list on the presence of capabilities.tools (as the MCP spec allows) will see zero tools. This is a critical regression — it breaks spec-compliant clients.

This is tracked as finding U1 in stacklok/toolhive-core#156.

Regression test coverage

  • TestRegression_InitializeAdvertisesToolsAndResourcesCapabilities in pkg/vmcp/server/capability_regression_test.go — pins the current (broken) behavior with documented assertions. When the shim is fixed, the assertions should be flipped to verify capabilities ARE advertised.

MCP spec reference

MCP 2025-11-25 §"Capabilities": the initialize result's capabilities object must advertise tools and resources when the server supports them.

Acceptance criteria

When the shim is fixed:

  • The initialize response should include capabilities.tools (non-nil) and capabilities.resources (non-nil) when the server has tools/resources
  • The regression test should be updated to assert the correct behavior

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with pkg/vmcp/server/capability_regression_test.go and TestRegression_InitializeAdvertisesToolsAndResourcesCapabilities, then trace mcpcompat's SetSessionTools and OnRegisterSession timing around construction of the initialize response. Update the regression assertions so the response includes non-nil capabilities.tools and capabilities.resources when tools and resources are available.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.