Skip to content

feat: add McpPlugin protocol and entry_points discovery#10

Merged
bburda merged 4 commits intomainfrom
feat/mcp-plugin-system
Feb 22, 2026
Merged

feat: add McpPlugin protocol and entry_points discovery#10
bburda merged 4 commits intomainfrom
feat/mcp-plugin-system

Conversation

@bburda
Copy link
Contributor

@bburda bburda commented Feb 19, 2026

Summary

  • Adds McpPlugin Protocol class defining the interface for MCP server plugins (list_tools, call_tool, startup, shutdown)
  • Adds discover_plugins() using Python entry_points (group ros2_medkit_mcp.plugins) for automatic plugin registration
  • Integrates plugin lifecycle and tool dispatch into mcp_app.py, server_stdio.py, and server_http.py

Closes #9

Test plan

  • Verify existing 47 tools still work without any plugins installed
  • Install an external package with a plugin entry point and verify its tools appear
  • Run tests/test_plugin_discovery.py - 3 tests covering discovery, broken plugin handling, empty state

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.
Copilot AI review requested due to automatic review settings February 19, 2026 16:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 McpPlugin Protocol with list_tools(), call_tool(), startup(), and shutdown() methods for plugin implementations
  • Implements discover_plugins() function using entry_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

@bburda bburda self-assigned this Feb 19, 2026
@bburda bburda requested a review from mfaferek93 February 19, 2026 17:17
@bburda bburda added the enhancement New feature or request label Feb 19, 2026
- 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
Copilot AI review requested due to automatic review settings February 19, 2026 17:28
@bburda bburda force-pushed the feat/mcp-plugin-system branch from 5d6dc11 to f84d24d Compare February 19, 2026 17:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Copy link

@mfaferek93 mfaferek93 left a comment

Choose a reason for hiding this comment

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

Looks good, just minor comments

…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
@mfaferek93 mfaferek93 self-requested a review February 22, 2026 08:51
Copy link

@mfaferek93 mfaferek93 left a comment

Choose a reason for hiding this comment

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

LGTM!

@bburda bburda merged commit c0d5aef into main Feb 22, 2026
3 checks passed
@bburda bburda deleted the feat/mcp-plugin-system branch February 22, 2026 10:32
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.

Add plugin system for MCP server extensibility

3 participants