🔧 Chore Summary
Investigate, test, and validate ContextForge's support for the MCP notifications/tools/list_changed signal for dynamic tool discovery. While the NotificationService and MCPSessionPool integration code exists, it has not been end-to-end tested or validated against real MCP servers that emit these notifications. Additionally, the feature needs to be made more configurable (e.g., enable/disable per gateway, configurable debounce, admin UI controls).
Key questions:
- Does CF currently listen for
notifications/tools/list_changed (and resources/, prompts/) post-discovery?
- Does receiving this notification auto-trigger a
tools/list refresh to sync the registry?
- Is this behavior reliable, configurable, and observable?
🧱 Area Affected
⚙️ Context / Rationale
Current state of the code:
What needs validation:
- The
message_handler callback is passed to ClientSession, but it's unclear if the MCP SDK actually delivers ServerNotification objects for list_changed events through this callback in all transport modes (SSE, Streamable HTTP)
- The refresh path (
_refresh_gateway_tools_resources_prompts) needs to be tested end-to-end with a real server that dynamically adds/removes tools
- Edge cases: What happens if the notification arrives during an in-flight discovery? During pool cleanup? When multiple workers receive the same notification?
📋 Acceptance Criteria
🧩 Additional Context
Relevant files:
mcpgateway/services/notification_service.py — Core notification handling
mcpgateway/services/mcp_session_pool.py — Session pool integration
mcpgateway/services/gateway_service.py — Gateway refresh logic
mcpgateway/common/models.py — Data models
mcpgateway/cache/session_registry.py — Session registry
docs/docs/architecture/adr/034-centralized-notification-service.md — ADR for this feature
tests/unit/mcpgateway/services/test_notification_service.py — Existing unit tests (mock-based)
MCP Spec reference: The notifications/tools/list_changed signal is part of the MCP specification for dynamic tool discovery. When a server's available tools change, it should send this notification so clients can call tools/list to get the updated list.
🔧 Chore Summary
Investigate, test, and validate ContextForge's support for the MCP
notifications/tools/list_changedsignal for dynamic tool discovery. While theNotificationServiceandMCPSessionPoolintegration code exists, it has not been end-to-end tested or validated against real MCP servers that emit these notifications. Additionally, the feature needs to be made more configurable (e.g., enable/disable per gateway, configurable debounce, admin UI controls).Key questions:
notifications/tools/list_changed(andresources/,prompts/) post-discovery?tools/listrefresh to sync the registry?🧱 Area Affected
⚙️ Context / Rationale
Current state of the code:
mcpgateway/services/notification_service.py— ANotificationServiceexists with:GatewayCapabilitiesdataclass)create_message_handler()that returns a callback forClientSession_refresh_gateway_tools_resources_prompts()on theGatewayServiceinit_notification_service/get_notification_service)mcpgateway/services/mcp_session_pool.py— Integration points:_create_session()passesmessage_handler=message_handlertoClientSession(line ~1149)init_notification_service()with configurable debouncestart_pool_notification_service()wires up theGatewayServicereferenceregister_gateway_capabilities()/unregister_gateway()lifecycle managementWhat needs validation:
message_handlercallback is passed toClientSession, but it's unclear if the MCP SDK actually deliversServerNotificationobjects forlist_changedevents through this callback in all transport modes (SSE, Streamable HTTP)_refresh_gateway_tools_resources_prompts) needs to be tested end-to-end with a real server that dynamically adds/removes tools📋 Acceptance Criteria
notifications/tools/list_changedmessage_handlercallback with SSE transporttools/listand updates the tool registryget_metrics(), but verify integration with observability stack)🧩 Additional Context
Relevant files:
mcpgateway/services/notification_service.py— Core notification handlingmcpgateway/services/mcp_session_pool.py— Session pool integrationmcpgateway/services/gateway_service.py— Gateway refresh logicmcpgateway/common/models.py— Data modelsmcpgateway/cache/session_registry.py— Session registrydocs/docs/architecture/adr/034-centralized-notification-service.md— ADR for this featuretests/unit/mcpgateway/services/test_notification_service.py— Existing unit tests (mock-based)MCP Spec reference: The
notifications/tools/list_changedsignal is part of the MCP specification for dynamic tool discovery. When a server's available tools change, it should send this notification so clients can calltools/listto get the updated list.