[mcp-server] Introduce a plugin system for custom MCP tools #5217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@L-Qun
Here's a design sketch for a plugin system for
@rushstack/mcp-server
.Basic ideas:
An MCP plugin is an NPM package with an
rush-mcp-plugin.json
manifest file in its root folder.Example: build-tests/rush-mcp-example-plugin/rush-mcp-plugin.json
The plugin can optionally define a JSON config file with a schema. Its name will be
<rush-repo>/common/config/rush-mcp/<plugin-name>.json
. This way each monorepo can configure its MCP plugins differently, for example different POC contact emails for each monorepo.@rushstack/mcp-server
manages loading of plugins: (1) ensure the autoinstaller is installed, (2) use the manifest to find the entry point, (3) if there is a config file, load it and validate its JSON schema, (4) callcreatePlugin()
to create the plugin class, (5) finally callonInitializeAsync()
so the plugin can initialize itself.It took me a while to realize that plugins can add/remove MCP tools interactively, as well as MCP resources etc. All the MCP API stuff will be exposed via
RushMcpPluginSession
. The plugin calls it likethis.session.registerTool({ toolName: 'state_capital' }, new StateCapitalTool(this));
.The key design requirements motivating
RushMcpPluginSession
:@rushstack/mcp-server
is a devDependency for plugins, NOT a regular dependency.import type
when importing from@rushstack/mcp-server
.zod
or@modelcontextprotocol/sdk
. This ensures multiple plugins can be loaded without doppelgangers or dependency hell, and it will also greatly improve the backwards compatibility story.@rushstack/mcp-server
should have a different goal, to provide a premade configure that "just works" for each monorepo, with minimal setup/understanding required by end users.The draft PR microsoft/rush-example#24 illustrates a configuration.
TODO:
[ ] Agree on the design
[ ] Implement the plugin loader
[ ] Convert existing MCP tools to use this model
[ ] Extract the
rush_docs
plugin into a build-tests example