Skip to content

Dynamic Refresh of MCP servers and Tool Health Status#1507

Merged
crivetimihai merged 23 commits intomainfrom
notify_gateway_status_change
Nov 27, 2025
Merged

Dynamic Refresh of MCP servers and Tool Health Status#1507
crivetimihai merged 23 commits intomainfrom
notify_gateway_status_change

Conversation

@kevalmahajan
Copy link
Copy Markdown
Member

@kevalmahajan kevalmahajan commented Nov 26, 2025

🐛 Bug-fix PR

📌 Summary

Closes #464 and #1506

The health status of MCP servers and tools is automatically updated in the UI in real time, without requiring a manual page reload. This is achieved through a centralized event service that handles the publishing and subscription of events. These events are streamed to the UI as server-sent events, allowing the status of MCP servers and tools to be refreshed automatically based on the latest health checks.

🔁 Reproduction Steps

  1. Open the Context Forge Gateway UI.
  2. Stop your MCP server that is added in the gateway, so that health checks fail, and the MCP server is tagged as Offline.
  3. Check the logs that the MCP server is tagged as offline but in UI that is not reflected in real time.
  4. After current changes, the status is reflected real time when the server is offline and when it comes back online.

🐞 Root Cause

Previously, the UI relied on manual refresh to update the health status of MCP servers and tools. There was no mechanism to propagate real-time updates from the backend to the frontend, leading to stale health information.

💡 Fix Description

  1. Introduced a centralized event service to publish and subscribe to server and tool health events.
  2. The event service sends server-sent events (SSE) to the UI.
  3. The UI listens for these events and updates the health status of MCP servers and tools in real time.
  4. This design eliminates the need for a manual page reload and ensures health status is always up to date based on backend checks.

🧪 Verification

Check Command Status
Lint suite make lint
Unit tests make test
Coverage ≥ 90 % make coverage
Manual regression no longer fails steps / screenshots

📐 MCP Compliance (if relevant)

  • Matches current MCP spec
  • No breaking change to MCP clients

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets/credentials committed

kevalmahajan and others added 22 commits November 27, 2025 20:03
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai crivetimihai force-pushed the notify_gateway_status_change branch from a3d81b3 to 21771f7 Compare November 27, 2025 20:34
@crivetimihai
Copy link
Copy Markdown
Member

Freezes on doctest somewhere, working on it.

The test was setting tool_service._event_subscribers but ToolService
now delegates event publishing to _event_service. Updated to set
_event_service._event_subscribers and force local mode.

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai crivetimihai merged commit 93bf8cf into main Nov 27, 2025
45 checks passed
@crivetimihai crivetimihai deleted the notify_gateway_status_change branch November 27, 2025 21:41
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
* health check status update with events

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* event service

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* fix events notifications

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* use centralized event service

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* updated docstrings and doctests

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* added comments

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* linting

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* minor update

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* using centralized event service for prompts

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* event service updated

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* minor change

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* linting

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* updated event generator

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* resolved pylint issues

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* update test cases

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* update test case

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* fix tests

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* fix doctests

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* docstring coverage

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* web linting

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* minor flake8 fix

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>

* Linting

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* fix: update test to use EventService subscriber list

The test was setting tool_service._event_subscribers but ToolService
now delegates event publishing to _event_service. Updated to set
_event_service._event_subscribers and force local mode.

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][UI]: MCP Server Active status not updated on shutdown

2 participants