Skip to content

Option to support declarative tool registration activated by version (e.g. "beta") #1557

Open

Description

@CharlieDigital

Is your feature request related to a problem? Please describe.

Currently, there is no clear way to adding new endpoints under test and keeping those from the broader user audience.

This makes incremental rollouts of new tools challenging because it is not possible to easily have some users opt in progressively to receive new features for stability testing.

Describe the solution you'd like

  • When tools are registered, allow it to be registered with a version
  • Spitballing:
    • Version specification: accept route match (*/vnext/*) or header (x-mcp-version: vnext)
    • Example: [McpServerTool(Name = "my_tool", VersionHeader = "x-mcp-version", VersionMatch = "vnext")]
  • This sets up the filter in the middleware automatically and checks incoming headers against the toolset metadata, automatically removing ones that target specific versions; effectively, it says client must transmit the header to see this tool.

Describe alternatives you've considered

Current workaround is to directly manipulate the ToolCollection dynamically:

server.WithListToolsHandler(
    async (context, cancellationToken) =>
    {
        // Resolve HttpContext via DI
        var httpContext = context
            .Services?.GetRequiredService<IHttpContextAccessor>()
            .HttpContext;

        // Check for the specific header
        bool betaEnabled =
            httpContext?.Request.Headers.ContainsKey("x-biblio-enable-beta") ?? false;

        if (!betaEnabled)
        {
            var betaTools =
                context.Server?.ServerOptions?.ToolCollection?.Where(tool =>
                    tool.ProtocolTool.Title?.Contains("(BETA)") ?? false
                )
                ?? [];

            foreach (var tool in betaTools.ToList())
            {
                // 👇 Active removal
                context?.Server?.ServerOptions?.ToolCollection?.Remove(tool);
            }
        }

        return new ListToolsResult
        {
            Tools = [], // Empty; these are additional tools.
        };
    }
);

Additional context

Similar to these issues:

Activity

  1. added
    P3Nice to haves, rare edge cases
    ready for workHas enough information to start
    on Jul 19, 2026
  2. jeffhandley commented on Jul 19, 2026

    @jeffhandley
    Contributor

    Related: #1216 covers the static, endpoint-based side of version-based tool registration (namespace -> /v1//v2), complementing the runtime header-gating proposed here. Cross-linking so the two are designed together rather than in isolation.

  3. added this to the 2.x milestone on Jul 27, 2026
  4. trey-herrington commented on Aug 31, 2026

    @trey-herrington

    I'd like to work on this one. Gonna try to write up a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesenhancementNew feature or requestready for workHas enough information to start

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions