-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Implement automatic hot-reload capability for the MCP server that detects changes in context.yaml configuration files and dynamically updates tools, prompts, and resources without requiring server restart.
Problem Statement
Current Behavior
When the MCP server starts, it loads the configuration from context.yaml once during initialization:
// src/McpServer/ActionsBootloader.php
ServerRunnerInterface::class => function (
McpConfig $config,
ServerRunner $factory,
ConfigLoaderInterface $loader,
) {
$loader->load(); // ← Configuration loaded ONCE at startup
// ...
}After this initial load, any changes to context.yaml (adding new tools, modifying prompts, updating resources) are not reflected in the running server until a full restart.
User Pain Points
- Workflow Disruption: Developers must manually restart the MCP server every time they add or modify tools in
context.yaml - Client Reconnection: MCP clients (Claude Desktop, Cursor, VS Code, etc.) lose their connection and must re-initialize
- Context Loss: Ongoing conversations in AI assistants may lose context due to server restart
- Development Friction: Rapid iteration on custom tools becomes tedious
Use Case Example
A developer is building a custom MCP tool for their project:
# context.yaml
tools:
- id: my-custom-tool
name: my-tool
description: "Does something useful"
command:
name: php
args: ["artisan", "my:command"]They realize they need to add another tool. Currently, they must:
- Edit
context.yaml - Stop the MCP server
- Restart the MCP server
- Wait for client reconnection
- Re-establish conversation context
With hot-reload, steps 2-5 would be eliminated.
Proposed Solution
Overview
Implement a ConfigWatcher system that:
- Monitors
context.yamland all imported configuration files for changes - Detects modifications using efficient file watching mechanisms
- Parses only the changed sections of configuration
- Updates the appropriate registries (tools, prompts, resources)
- Emits MCP protocol notifications to inform connected clients
MCP Protocol Support
The MCP specification already supports dynamic list updates through notifications:
| Notification | Purpose |
|---|---|
notifications/tools/list_changed |
Informs clients that available tools have changed |
notifications/prompts/list_changed |
Informs clients that available prompts have changed |
notifications/resources/list_changed |
Informs clients that available resources have changed |
These notifications are already implemented in the schema:
PhpMcp\Schema\Notification\ToolListChangedNotificationPhpMcp\Schema\Notification\PromptListChangedNotificationPhpMcp\Schema\Notification\ResourceListChangedNotification
The Mcp\Server\Registry already has the infrastructure to emit list_changed events:
// vendor/llm/mcp-server/src/Protocol.php
$this->registry->on('list_changed', function (string $listType): void {
$this->handleListChanged($listType);
});Metadata
Metadata
Assignees
Labels
Type
Projects
Status