Skip to content

Fix stdio MCP sources having 0 tools#1122

Open
grfwings wants to merge 5 commits into
RhysSullivan:mainfrom
grfwings:fix-stdio-mcp
Open

Fix stdio MCP sources having 0 tools#1122
grfwings wants to merge 5 commits into
RhysSullivan:mainfrom
grfwings:fix-stdio-mcp

Conversation

@grfwings

Copy link
Copy Markdown
Contributor

Currently, the MCP UI disables “Add connection” for stdio integrations because stdio exposes no auth methods. That means there is integration, but no connection, therefore 0 tools.

With this change the stdio MCP integrations now automatically create the default no-auth connection (org/default, template none) during mcp.addServer, which triggers normal tool discovery and persists tools under tools.<slug>.org.default.*.

@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes stdio MCP sources having 0 tools by automatically creating a default org/default no-auth connection when a stdio server is added, retrieved, or reconfigured, and backfills the connection in getServer for any existing stdio integration that has no connections.

  • Adds ensureDefaultStdioConnection helper called from addServer, getServer, and configureServer for stdio transports; handles the concurrent-creation race with a UniqueViolationErrorrefresh arm.
  • Updates the addServer tool description to clarify that stdio servers self-connect and no manual connections.create step is needed.
  • Adds three focused integration tests covering connection creation, tool discovery, and the backfill path.

Confidence Score: 3/5

The core auto-connection logic is sound, but the getServer tool execute handler now silently propagates a failure type it didn't produce before.

The getServer execute handler lacks a catchTag for McpConnectionError, which ensureDefaultStdioConnection can now emit for stdio servers during backfill. Any connection creation failure on a getServer call for a stdio slug will surface as a raw Effect error to the caller instead of a graceful ToolResult.fail.

packages/plugins/mcp/src/sdk/plugin.ts — specifically the getServer tool execute handler around line 1283.

Important Files Changed

Filename Overview
packages/plugins/mcp/src/sdk/plugin.ts Introduces ensureDefaultStdioConnection for auto-creating org/default no-auth connections on stdio servers in addServer, getServer, and configureServer; the getServer tool execute handler is missing a McpConnectionError catch that the new code path can now produce.
packages/plugins/mcp/src/sdk/plugin.test.ts Adds three new tests covering default connection creation on addServer, tool discovery for stdio, and backfill via getServer; fixture cleanup uses Effect.acquireRelease correctly.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Agent
    participant addServer
    participant ensureDefaultStdioConnection
    participant connections

    Agent->>addServer: "addServer({ transport: "stdio", ... })"
    addServer->>connections: integrations.register(slug, config)
    addServer->>ensureDefaultStdioConnection: (integration, slug)
    ensureDefaultStdioConnection->>connections: "connections.list({ integration })"
    alt No existing connections
        ensureDefaultStdioConnection->>connections: "connections.create(org/default, template=none)"
        alt UniqueViolationError (race)
            ensureDefaultStdioConnection->>connections: connections.refresh(org/default)
        end
    end
    addServer-->>Agent: "{ slug }"

    Agent->>getServer: getServer(slug)
    getServer->>connections: integrations.get(slug)
    alt "config.transport === "stdio""
        getServer->>ensureDefaultStdioConnection: backfill if 0 connections
    end
    getServer-->>Agent: integration record
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Agent
    participant addServer
    participant ensureDefaultStdioConnection
    participant connections

    Agent->>addServer: "addServer({ transport: "stdio", ... })"
    addServer->>connections: integrations.register(slug, config)
    addServer->>ensureDefaultStdioConnection: (integration, slug)
    ensureDefaultStdioConnection->>connections: "connections.list({ integration })"
    alt No existing connections
        ensureDefaultStdioConnection->>connections: "connections.create(org/default, template=none)"
        alt UniqueViolationError (race)
            ensureDefaultStdioConnection->>connections: connections.refresh(org/default)
        end
    end
    addServer-->>Agent: "{ slug }"

    Agent->>getServer: getServer(slug)
    getServer->>connections: integrations.get(slug)
    alt "config.transport === "stdio""
        getServer->>ensureDefaultStdioConnection: backfill if 0 connections
    end
    getServer-->>Agent: integration record
Loading

Comments Outside Diff (1)

  1. packages/plugins/mcp/src/sdk/plugin.ts, line 1283-1288 (link)

    P1 McpConnectionError unhandled in getServer execute handler

    getServer now calls ensureDefaultStdioConnection for stdio servers, which can fail with McpConnectionError. The execute handler has no catchTag for it, so any connection-creation failure during backfill on a stdio slug propagates as a raw Effect error instead of a graceful ToolResult.fail. The probeEndpoint handler shows the correct fix: pipe through Effect.catchTag("McpConnectionError", ({ message, transport }) => Effect.succeed(mcpToolFailure("mcp_connection_failed", message, { transport }))).

Reviews (3): Last reviewed commit: "Backfill existing stdio MCP with zero co..." | Re-trigger Greptile

Comment thread packages/plugins/mcp/src/sdk/plugin.ts Outdated
Griffin Evans added 2 commits June 24, 2026 15:42
…onect as org/default with template none; Add UniqueViolationError in stdio connection path
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.

1 participant