modelcontextprotocol / modelcontextprotocol/go-sdk

Proposal: provide a Server.SetTools method

Open
#639 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs community feedback
Dominant language
Go
Stars
5.1k
Forks
543
Avg merge
1d 17h
Merged PRs (30d)
37

Description

Description

The design document clearly states that one of the differences between the official SDK and Mark3Labs mcp-go is that only Server.AddTools is provided and that the rest of Tool-management functions are deemed unnecessary:

https://github.com/modelcontextprotocol/go-sdk/blob/9ef2b2742ea1b6fed83b8ae40a96d0006e45d739/design/design.md?plain=1#L670

There are also some comments in the code regarding the batch notification of tool changes:

https://github.com/modelcontextprotocol/go-sdk/blob/9ef2b2742ea1b6fed83b8ae40a96d0006e45d739/mcp/server.go#L229-L235

Problem

The AddTool logic allows for an upsert (adding or replacing) of a tool based on the name.

However, this seems insufficient when we want to completely replace the list of available tools.
The problems are mainly two:

  • The additional pressure on the client for each tool addition (a new notification is sent for each).
  • The requirement to track the tools that have been exposed in the server in case we no longer want to expose one of them.

In the Kubernetes MCP Server we require this functionality to be able to replace the complete tool list that is exposed to the client, which at some point be more more restricted.
This forces us to first remove all the tools and then add them again.

Alternatives

At the moment we've implemented the workaround in our repository by tracking the tools and doing the removal and then the addition:

https://github.com/containers/kubernetes-mcp-server/blob/b4c20f9265c42556d1f26f504a3aac68c88ea2ca/pkg/mcp/mcp.go#L129-L166

This works, but if others find it useful I think it might be better to provide the feature in the SDK itself.

Additional Context

I actually created the original SetTools method in the mcp-go repository, the reasoning exposed in the PR is the same for this feature request:

https://github.com/mark3labs/mcp-go/pull/24

Kubernetes MCP Server related issues and PRs:

If you're interested on this feature I can work on its implementation.

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

Read design/design.md at the tool-management section and mcp/server.go around the tool-change notification comments. Compare the existing AddTool behavior with the workaround in pkg/mcp/mcp.go from the linked Kubernetes MCP Server. Done means the SDK can replace the exposed tool list without requiring callers to track and remove tools individually.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.