feat: add McpPlugin protocol and entry_points discovery#10
Merged
Conversation
Plugins register via entry_points group 'ros2_medkit_mcp.plugins'. Plugin tools merged into list_tools() and call_tool() dispatch. Startup/shutdown lifecycle in server_stdio and server_http. Broken plugins logged and skipped.
There was a problem hiding this comment.
Pull request overview
This pull request adds a plugin system to enable extensibility of the MCP server. It introduces a McpPlugin Protocol that defines the interface for external packages to register additional MCP tools via Python's entry_points mechanism. The system integrates plugin discovery, lifecycle management (startup/shutdown), and tool dispatch into the existing server architecture.
Changes:
- Adds
McpPluginProtocol withlist_tools(),call_tool(),startup(), andshutdown()methods for plugin implementations - Implements
discover_plugins()function usingentry_points(group="ros2_medkit_mcp.plugins")for automatic plugin registration - Integrates plugin lifecycle and tool dispatch into both stdio and HTTP transport servers with proper error handling
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/ros2_medkit_mcp/plugin.py |
New module defining McpPlugin Protocol and discover_plugins() function for entry_points-based plugin discovery |
src/ros2_medkit_mcp/mcp_app.py |
Updates register_tools() and call_tool() to merge plugin tools with core tools and dispatch to plugins as fallback |
src/ros2_medkit_mcp/server_stdio.py |
Adds plugin discovery and lifecycle management (startup/shutdown) to stdio server entrypoint |
src/ros2_medkit_mcp/server_http.py |
Adds plugin discovery and lifecycle management (startup/shutdown) to HTTP server entrypoint |
tests/test_plugin_discovery.py |
New test file covering plugin discovery scenarios including successful discovery, empty state, and broken plugins |
- Fix ruff lint errors (import order, unused import, type annotation) - Build tool→plugin map at registration time for O(1) dispatch - Make plugin dispatch authoritative (first declaring plugin owns it) - Track successfully started plugins; only shutdown those on exit
5d6dc11 to
f84d24d
Compare
mfaferek93
reviewed
Feb 21, 2026
…otocol validation - Add tool name collision detection against built-in tools (TOOL_ALIASES) and inter-plugin duplicates during plugin tool registration - Extract start_plugins()/shutdown_plugins() helpers to plugin.py, removing duplicated loops from server_stdio.py and server_http.py - Add hasattr check in discover_plugins() to skip non-conforming plugins - Pass only started_plugins to setup_mcp_app (not all discovered) - Move setup_mcp_app into on_startup in server_http.py so plugin tools are only registered after successful startup - Add tests for dispatch, collision detection, and lifecycle helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
McpPluginProtocol class defining the interface for MCP server plugins (list_tools,call_tool,startup,shutdown)discover_plugins()using Pythonentry_points(groupros2_medkit_mcp.plugins) for automatic plugin registrationmcp_app.py,server_stdio.py, andserver_http.pyCloses #9
Test plan
tests/test_plugin_discovery.py- 3 tests covering discovery, broken plugin handling, empty state