Skip to content

feat(mcp): expose MCP server status across all protocols - #133

Open
Million-mo wants to merge 6 commits into
Leoyzen:develop/agenticfrom
Million-mo:feat/mcp-server-status
Open

feat(mcp): expose MCP server status across all protocols#133
Million-mo wants to merge 6 commits into
Leoyzen:develop/agenticfrom
Million-mo:feat/mcp-server-status

Conversation

@Million-mo

Copy link
Copy Markdown
Collaborator

Summary

Implements Phase 1 of issue #132 — read-only MCP server status visibility across all protocols.

Previously, when an MCP server disconnected (subprocess crash, network failure, timeout), clients had no way to detect it. They could only observe tool call failures or tools disappearing from the list, with no way to distinguish "server not connected" from "tool not supported."

This PR exposes MCPResourceProvider.get_status() (which already existed but was only used by GET /mcp) through three additional protocol surfaces:

Changes

1. MCPStatus model enhancement (models/mcp.py)

  • Added server_type: str field to expose transport type (stdio/sse/http/acp)

2. OpenCode route (config_routes.py)

  • New GET /config/mcp-servers endpoint following the existing /config/* route convention
  • Returns the same data as GET /mcp but at a discoverable config-adjacent path

3. MCP protocol resource (mcp_server/server.py)

  • New agentpool://mcp-servers/status FastMCP resource
  • Clients can read it via resources/read to get JSON with all server statuses
  • Uses pool.mcp.get_mcp_providers()provider.get_status() chain

4. ACP initialize metadata (acp_agent.py)

  • initialize response now includes field_meta.mcp_servers array
  • Each entry: {name, status, display_name, server_type, error}
  • Clients get MCP server status at handshake time without extra round-trips

5. Converter update (converters.py)

  • to_mcp_status() now passes through server_type from MCPServerStatus

Verification

  • ruff check — all checks passed
  • ruff format --check — all files formatted
  • mypy — no issues found in 5 source files
  • 260 relevant tests passed (config routes, route discovery, ACP RPC, MCP server, MCP routes)

Closes #132

Add read-only MCP server connection status visibility so clients can
detect when MCP servers are connected, disconnected, or failed.

Changes:
- Add server_type field to MCPStatus model (transport type: stdio/sse/http/acp)
- Add GET /config/mcp-servers OpenCode route (complements existing GET /mcp)
- Add agentpool://mcp-servers/status MCP resource for MCP protocol clients
- Include mcp_servers metadata in ACP initialize response via field_meta
- Update to_mcp_status() converter to pass through server_type

Closes Leoyzen#132

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces features to expose MCP server connection statuses, including a new GET /config/mcp-servers endpoint, an agentpool://mcp-servers/status resource, and metadata inclusion during agent initialization. Feedback suggests adding a guard check for state.agent is None in the new endpoint to prevent potential AttributeError crashes, and explicitly checking pool.mcp is not None in acp_agent.py to ensure type safety.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/agentpool_server/opencode_server/routes/config_routes.py
Comment thread src/agentpool_server/acp_server/acp_agent.py Outdated
- config_routes: guard state.agent is None before calling get_mcp_server_info()
- acp_agent: explicitly check pool.mcp is not None for type safety
This line was inadvertently included in the previous commit via a
stash pop artifact. It causes Import Linter CI to fail because
TYPE_CHECKING imports are excluded from analysis, making many
ignore_imports entries no longer match.
- test_config_routes: 3 tests for GET /config/mcp-servers (statuses,
  agent None guard, multiple servers with server_type)
- test_mcp_status_resource: 2 tests for agentpool://mcp-servers/status
  FastMCP resource (JSON output, empty when no providers)
- test_acp_initialize_mcp_meta: 2 tests for ACP initialize field_meta
  (mcp_servers populated, None when no providers)
Same fix as PR Leoyzen#128 — replace openai:gpt-4o-mini with TestModelConfig
so the test doesn't need real API credentials in CI.
@Million-mo

Copy link
Copy Markdown
Collaborator Author

Unit tests failure is a flaky test (test_queued_steer_messages_become_next_turn_prompts) — passes locally. Re-running CI.

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.

feat(mcp): MCP server status visibility for clients

1 participant