Implement mcp-hmr: Hot Module Reloading for Model Context Protocol servers#20
Implement mcp-hmr: Hot Module Reloading for Model Context Protocol servers#20
Conversation
Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
PR Change SummaryIntroduced the mcp-hmr package for hot module reloading in Model Context Protocol servers, enhancing development efficiency.
Added Files
How can I customize these reviews?Check out the Hyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add |
1 similar comment
PR Change SummaryIntroduced the mcp-hmr package for hot module reloading in Model Context Protocol servers, enhancing development efficiency.
Added Files
How can I customize these reviews?Check out the Hyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add |
Co-authored-by: CNSeniorious000 <74518716+CNSeniorious000@users.noreply.github.com>
5a6f396 to
6dc27a0
Compare
|
This PR introduces
mcp-hmr, a new package that brings Hot Module Reload capabilities to Model Context Protocol (MCP) servers, similar to howuvicorn-hmrprovides HMR for ASGI applications.Problem Statement
When developing MCP servers, traditional reload mechanisms restart the entire server process on any code change. This approach has significant drawbacks:
Solution
MCP-HMR provides incremental reloading that updates only what changed while preserving long-lived state. Key differences from traditional approaches:
Implementation
Core Components
Reactive Registry (
registry.py): Uses hmr's fine-grained reactivity to track MCP tools and resourcesSmart Reloader (
reloader.py): ExtendsSyncReloaderwith MCP-specific logic for capability change detection and state preservationProtocol Integration (
notifications.py): Sends capability change notifications to MCP clients when supportedCLI Interface (
cli.py): Providesmcp-hmrcommand with uvicorn-hmr-like optionsUsage Example
Key Features
Testing
The implementation includes comprehensive verification:
Integration
The package follows the existing workspace patterns:
pyproject.tomlThis implementation leverages hmr's existing reactive infrastructure while providing MCP-specific functionality, enabling efficient development workflows for MCP server authors.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.