Skip to content

Inspector should disconnect when server shuts down and/or refuses connections #601

@odrobnik

Description

@odrobnik

After a connection has been established, I shut down the server. The UI doesn't recognize the disconnection.

You still see the Reconnect and Disconnect buttons.

In the console you see tons of messages like this:

Error from MCP server: SseError: SSE error: TypeError: fetch failed: connect ECONNREFUSED ::1:8080, connect ECONNREFUSED 127.0.0.1:8080, connect EHOSTUNREACH fe80::1:8080 - Local (:::55056), connect ECONNREFUSED 192.168.1.142:8080, connect EHOSTUNREACH fe80::479:f5e1:f09e:ee06:8080 - Local (:::55059), connect EHOSTUNREACH fe80::16:546c:57d:64cb:8080 - Local (:::55061), connect EHOSTUNREACH fe80::5cff:b3ff:fe65:8cdf:8080 - Local (:::55062), connect ECONNREFUSED fda0:15a6:9edc:444e:10da:5b53:d2a6:2bac:8080
    at _eventSource.onerror (file:///Users/oliver/.npm/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js:85:31)
    at EventSource.scheduleReconnect_fn (file:///Users/oliver/.npm/_npx/5a9d879542beca3a/node_modules/eventsource/dist/index.js:248:53)
    at file:///Users/oliver/.npm/_npx/5a9d879542beca3a/node_modules/eventsource/dist/index.js:98:174
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: undefined,
  event: {
    type: 'error',
    message: 'TypeError: fetch failed: connect ECONNREFUSED ::1:8080, connect ECONNREFUSED 127.0.0.1:8080, connect EHOSTUNREACH fe80::1:8080 - Local (:::55056), connect ECONNREFUSED 192.168.1.142:8080, connect EHOSTUNREACH fe80::479:f5e1:f09e:ee06:8080 - Local (:::55059), connect EHOSTUNREACH fe80::16:546c:57d:64cb:8080 - Local (:::55061), connect EHOSTUNREACH fe80::5cff:b3ff:fe65:8cdf:8080 - Local (:::55062), connect ECONNREFUSED fda0:15a6:9edc:444e:10da:5b53:d2a6:2bac:8080',
    code: undefined,
    defaultPrevented: false,
    cancelable: false,
    timeStamp: 502389.422084
  }
}

I would expect for the UI to show the connection has having been disconnected.

When the server comes back up again, then the connection gets reestablished, but the problem with this is that since this is a new session, there is no information about client capabilities from the initialized notification. So I don't know on the server if the client has sampling, roots or elicitation support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions