fix(web): render the connected header when a modern server omits serverInfo (#1773)
A modern-era server/discover makes serverInfo optional (SHOULD, not MUST); a conforming modern server that omits it left initializeResult undefined, collapsing the entire connected header + tab bar so the server was uninspectable. Gate initializeResult on connectionStatus alone with a catalog-name fallback, and thread a serverInfoReported flag so the Connection Info modal reports the omission truthfully instead of presenting the inferred name as server-sent. Closes #1772.
This commit is contained in:
parent
da37692485
commit
820d38c438
1 changed files with 288 additions and 21 deletions
|
|
@ -3,7 +3,11 @@ import type {
|
|||
InitializeResult,
|
||||
} from "@modelcontextprotocol/client";
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { ConnectionInfoContent } from "./ConnectionInfoContent";
|
||||
import { expect, within } from "storybook/test";
|
||||
import {
|
||||
ConnectionInfoContent,
|
||||
SERVER_INFO_NOT_REPORTED_LABEL,
|
||||
} from "./ConnectionInfoContent";
|
||||
|
||||
const fullResult: InitializeResult = {
|
||||
protocolVersion: "2025-03-26",
|
||||
|
|
@ -75,6 +79,38 @@ export const ModernEra: Story = {
|
|||
},
|
||||
};
|
||||
|
||||
// A modern server that omitted the optional `_meta` serverInfo stamp (#1772).
|
||||
// `initializeResult.serverInfo` here is App's client-side catalog fallback, and
|
||||
// `serverInfoReported: false` tells the modal not to present it as server-sent —
|
||||
// Name and Version read "— (not reported by server)".
|
||||
export const ServerInfoNotReported: Story = {
|
||||
args: {
|
||||
initializeResult: {
|
||||
protocolVersion: "2026-07-28",
|
||||
// The catalog name App synthesizes; must NOT surface as the reported name.
|
||||
serverInfo: { name: "my-catalog-name", version: "" },
|
||||
capabilities: { tools: { listChanged: true } },
|
||||
},
|
||||
serverInfoReported: false,
|
||||
clientCapabilities: { roots: { listChanged: true } },
|
||||
transport: "streamable-http",
|
||||
protocolEra: "modern",
|
||||
// A real modern connection that skipped the `_meta` serverInfo stamp still
|
||||
// has a discover result — with `supportedVersions` + capabilities, just no
|
||||
// `serverInfo`. Including it makes the story accurate and shows the Discovery
|
||||
// section doesn't leak a name either.
|
||||
discoverResult: {
|
||||
supportedVersions: ["2026-07-28", "2025-11-25"],
|
||||
capabilities: { tools: { listChanged: true } },
|
||||
},
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
expect(canvas.queryByText("my-catalog-name")).not.toBeInTheDocument();
|
||||
expect(canvas.getAllByText(SERVER_INFO_NOT_REPORTED_LABEL)).toHaveLength(2);
|
||||
},
|
||||
};
|
||||
|
||||
export const MinimalCapabilities: Story = {
|
||||
args: {
|
||||
initializeResult: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue