Skip to content

feat(mcp): let embedders extend the /mcp server - #3495

Open
alan-bentley-pgh wants to merge 2 commits into
kagent-dev:mainfrom
alan-bentley-pgh:alan-bentley-pgh/mcpExtend
Open

alan-bentley-pgh wants to merge 2 commits into
kagent-dev:mainfrom
alan-bentley-pgh:alan-bentley-pgh/mcpExtend

Conversation

@alan-bentley-pgh

@alan-bentley-pgh alan-bentley-pgh commented Nov 2, 2026 •

Copy link
Copy Markdown

🤖 written by Claude (start)

This PR adds app.Options.MCPExtensions, which hands core's *mcp.Server to a program that runs core as a library, after core registers its own tools. The program can add tools, resources and middleware that share core's endpoint and authenticator.

Core's tools are not protected: the SDK replaces a name or URI that is registered twice.

Closes #3429


🤖 written by Claude (end)

Adds app.Options.MCPExtensions, a hook that runs after core registers its
tools. A program that runs core as a library can add tools, resources and
resource templates, which are served from the same endpoint behind the
same authenticator.

The hook gets a narrow registry rather than the MCP server. Startup fails
on a name, URI or URI template that core or an earlier call already
registered, and on input the registry rejects.

Refs kagent-dev#3429

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Alan Bentley <alanbentleypgh@gmail.com>
@github-actions github-actions Bot added the enhancement New feature or request label Nov 2, 2026
@alan-bentley-pgh

Copy link
Copy Markdown
Author

Open WebUI calling a tool added through the hook (extension_hello, from a scratch embedder build) beside core's list_agents.

reel-hook-1600.mp4

🤖 written by Claude

@alan-bentley-pgh
alan-bentley-pgh marked this pull request as ready for review November 2, 2026 20:58
@alan-bentley-pgh
alan-bentley-pgh requested a review from a team as a code owner November 2, 2026 20:58
Comment thread go/core/internal/mcp/extensions.go Outdated
err error
}

// newRegistry records what the server already serves by listing it through an

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frankly I think this is overcomplicated. Can we just expose the underlying server to the extension after it's done being created and let it do what it wants?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that seems like a simpler approach. I'll pass the created *mcp.Server to the hook after core registers its tools and drop the registry

MCPExtensions now receives the *mcp.Server after core registers its tools,
instead of a narrow registry. This drops the registry, the in-memory
listing of core's names and the panic wrapper.

Refs kagent-dev#3429

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Alan Bentley <alanbentleypgh@gmail.com>
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 2, 2026
@alan-bentley-pgh

Copy link
Copy Markdown
Author

Updated in 6089344a. The hook now gets the *mcp.Server after core registers its tools and removed the registry. cc @EItanya

reel-hook3-1600.mp4

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Let embedders extend the core /mcp server

2 participants