Spaces:
Running
A newer version of the Gradio SDK is available:
6.2.0
Guardian Forge SSE Bridge π§ͺ
This bridge includes support for Server-Sent Events (SSE) to enable bidirectional communication and future auto-update capabilities.
π What's Different?
Standard Bridge (guardian-forge-mcp-bridge.js):
- β Simple, stable, tested
- β Works with all MCP clients
- β No SSE support
SSE Bridge (guardian-forge-mcp-bridge-sse.js):
- β‘ SSE support for notifications
- β Auto-reconnect on connection loss
- β Bidirectional communication (client β server)
- β Better long-term connection stability
- β οΈ Slightly more complex
π― Current Behavior
Tool Updates:
- You request a new tool in your MCP client
- You approve it in the dashboard at
/admin - Server sends
notifications/tools/list_changedβ Bridge forwards to client - Currently: You still need to restart Claude Desktop/Code to see the new tool
Why restart is needed: The MCP client (Claude Desktop/Code) doesn't yet auto-refresh when receiving notifications/tools/list_changed. The bridge correctly forwards the notification, but the client-side implementation isn't handling it yet.
Future: When MCP clients fully implement notification handling, new tools will appear automatically without restart.
π₯ Setup
Step 1: Configure MCP Client
Get your API key from the Guardian Forge dashboard Settings tab, then configure your MCP client:
Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"guardian-forge": {
"command": "node",
"args": ["/absolute/path/to/guardian-forge-mcp-bridge-sse.js"],
"env": {
"GUARDIAN_FORGE_API_KEY": "gf_your_key_here"
}
}
}
}
Claude Code (~/.claude.json on macOS/Linux, C:\Users\<username>\.claude.json on Windows):
{
"mcpServers": {
"guardian-forge": {
"command": "node",
"args": ["/absolute/path/to/guardian-forge-mcp-bridge-sse.js"],
"env": {
"GUARDIAN_FORGE_API_KEY": "gf_your_key_here"
}
}
}
}
Windows Example (Claude Desktop):
{
"mcpServers": {
"guardian-forge": {
"command": "node",
"args": ["C:\\Users\\YourName\\Downloads\\guardian-forge-mcp-bridge-sse.js"],
"env": {
"GUARDIAN_FORGE_API_KEY": "gf_your_key_here"
}
}
}
}
Windows Example (Claude Code - C:\Users\<username>\.claude.json):
{
"mcpServers": {
"guardian-forge": {
"command": "node",
"args": ["C:\\Users\\giova\\Downloads\\guardian-forge-mcp-bridge-sse.js"],
"env": {
"GUARDIAN_FORGE_API_KEY": "gf_your_key_here"
}
}
}
}
Step 2: Restart Your MCP Client
Watch the logs for:
[Guardian Forge Bridge SSE] Bridge started, connecting to Guardian Forge...
[Guardian Forge Bridge SSE] Client initialized - starting SSE connection for notifications
[Guardian Forge Bridge SSE] Connecting to SSE endpoint for notifications...
[Guardian Forge Bridge SSE] SSE connection established - listening for notifications
π How It Works
Architecture
ββββββββββββββββ
β MCP Client β
β (Claude Code)β
ββββββββ¬ββββββββ
β stdin/stdout (JSON-RPC)
β
ββββββββΌββββββββββββββββββββββββββββ
β SSE Bridge (Node.js) β
β βββββββββββββββ βββββββββββββββ β
β β POST β β GET (SSE) β β
β β Handler β β Listener β β
β ββββββββ¬βββββββ ββββββββ¬βββββββ β
β β β β
βββββββββββΌβββββββββββββββββΌβββββββββ
β β
β HTTP POST β SSE Stream
β (requests) β (notifications)
βΌ βΌ
βββββββββββββββββββββββββββββββ
β Guardian Forge Server β
β (HuggingFace Spaces) β
βββββββββββββββββββββββββββββββ
Message Flow
Client β Server (Requests):
Client sends: tools/list
β
Bridge POSTs JSON-RPC to /mcp
β
Server responds with tool list
β
Bridge forwards response to client
Server β Client (Notifications):
User approves tool in dashboard
β
Server sends SSE: notifications/tools/list_changed
β
Bridge receives via GET /mcp SSE stream
β
Bridge forwards notification to client stdout
β
Client auto-refreshes tool list
π Known Issues
SSE Connection Stability
- SSE connections may drop after long periods
- Bridge auto-reconnects after 5 seconds
- Look for "SSE connection closed" messages
Initial Connection
- SSE connection starts AFTER client sends
notifications/initialized - May take 1-2 seconds to establish
- SSE connection starts AFTER client sends
Firewall/Proxy
- SSE requires long-lived HTTP connections
- Some firewalls/proxies may close these connections
- Corporate networks may block SSE
π Debugging
Enable Verbose Logging
All logs go to stderr, so you can monitor:
# Run with stderr visible
node guardian-forge-mcp-bridge-sse.js 2>&1 | tee bridge.log
Look for These Messages
β Success:
[Guardian Forge Bridge SSE] SSE connection established - listening for notifications
β οΈ Warning:
[Guardian Forge Bridge SSE] SSE connection failed with status 401
[Guardian Forge Bridge SSE] Scheduling SSE reconnect in 5000ms
β Error:
[Guardian Forge Bridge SSE] SSE request error: connect ETIMEDOUT
Test Notifications Manually
- Connect the bridge
- Request a new tool via MCP client
- Approve it in dashboard at
/admin - Watch stderr for:
[Guardian Forge Bridge SSE] Received server notification: notifications/tools/list_changed - Check if tool appears in client without reconnecting
π Switching Between Bridges
To go back to the stable bridge:
{
"mcpServers": {
"guardian-forge": {
"command": "node",
"args": ["/path/to/guardian-forge-mcp-bridge.js"] // Remove -sse
}
}
}
π€ Feedback
This is experimental! Please report:
- Connection stability issues
- Missing notifications
- Performance problems
- Compatibility with different MCP clients
π Technical Details
SSE Implementation:
- Uses
https.get()withAccept: text/event-stream - Parses
data:lines from SSE stream - Forwards JSON-RPC notifications to stdout
- Auto-reconnects on connection loss
Notification Format:
{
"jsonrpc": "2.0",
"method": "notifications/tools/list_changed",
"params": {}
}
Capabilities Advertisement:
{
"capabilities": {
"tools": {
"listChanged": true // Tells client we support this!
}
}
}
β οΈ Production Use
Recommendation: Use the standard bridge for production until SSE bridge is thoroughly tested.
When to use SSE bridge:
- You want auto-updates
- You're willing to help test
- You don't mind occasional reconnections
- You can monitor logs for issues
When to use standard bridge:
- You need maximum stability
- You're okay with manual reconnection
- You're in a corporate network with proxy/firewall
- You're demoing Guardian Forge
Status: π§ͺ Experimental - Feedback Welcome!