Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .claude/skills/test-servers/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ row, never by the caller's category.
process:
- **A script.** `scripts/smoke-web-elicitation.mjs` spawns it directly;
`scripts/lib/mcp-app-flow.mjs` (`startMcpAppServer`) does it for
`smoke:web:app`, `smoke:web:tabs` and `pack:verify`. These are automated and
`smoke:web:app`, `smoke:web:tabs`, `smoke:web:events` and `pack:verify`.
These are automated and
config-driven, and the whole of this skill applies to them. ⚠️ **Not every
smoke is here** — `smoke:cli` and `smoke:tui` use the two shapes above and
pick no config at all.
Expand Down
6 changes: 3 additions & 3 deletions .claude/skills/testing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ ways to depend on one, and they need different halves of that skill:
override, so if the case needs a specific tool set it is an in-process HTTP
test instead.
- **A config-driven web smoke, or `pack:verify` → spawned composable HTTP.**
`smoke:web:elicitation`, `smoke:web:app`, `smoke:web:tabs` and `pack:verify`
all spawn `server-composable.js --config <name>.json`. **The showcase-config
`smoke:web:elicitation`, `smoke:web:app`, `smoke:web:tabs`,
`smoke:web:events` and `pack:verify` all spawn `server-composable.js --config <name>.json`. **The showcase-config
and protocol-era guidance applies to you in full** — being automated does
not exempt a smoke from it.

Expand Down Expand Up @@ -189,7 +189,7 @@ Storybook play functions (`test:storybook`) → the published-tarball check
across the tiers rather than along them.** Needing `test-servers/`: the web
integration tests **that drive one**, the out-of-process CLI tests, the smokes
that connect (`smoke:cli`, `smoke:web:app`, `smoke:web:elicit`,
`smoke:web:tabs`), `pack:verify`, and **`smoke:tui`** — which never asserts a
`smoke:web:tabs`, `smoke:web:events`), `pack:verify`, and **`smoke:tui`** — which never asserts a
round trip but calls `ensureTestServers({ requires: ["stdio"] })` and hands the
built fixture to the TUI as its catalog's stdio command. Not needing it: the
pure tests inside the same integration project, the connecting tests that
Expand Down
29 changes: 24 additions & 5 deletions clients/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,23 @@ Components live under `src/components/` in four layers, smallest to largest:

| Layer | Count | What it is |
| ----------- | ----- | ------------------------------------------------------------------------------ |
| `elements/` | ~48 | Leaf presentational pieces (badges, buttons, toggles) over Mantine primitives. |
| `groups/` | ~64 | Composite pieces (cards, panels, modals, control bars). |
| `screens/` | ~11 | Full tab screens (Tools, Resources, Servers, monitoring screens…). |
| `elements/` | ~51 | Leaf presentational pieces (badges, buttons, toggles) over Mantine primitives. |
| `groups/` | ~73 | Composite pieces (cards, panels, modals, control bars). |
| `screens/` | ~12 | Full tab screens (Tools, Resources, Servers, monitoring screens…). |
| `views/` | 1 | `InspectorView` — the top-level layout that composes the screens. |

Every screen and element has a `*.stories.tsx` (see [Storybook](#storybook)). Styling follows the Mantine-first rules in [`AGENTS.md`](../../AGENTS.md) — theme variants and component props over CSS, `--inspector-*` tokens over raw colors.
Every screen and element has a `*.stories.tsx` (see [Storybook](#storybook)).

## The Events tab

The **Events** tab ([#3030](https://github.com/modelcontextprotocol/inspector/issues/3030)) inspects a server's [Events extension](https://modelcontextprotocol.io/extensions/events/overview) (`io.modelcontextprotocol/events`, SEP-3415). It is shown only on a **modern-era** connection to a server that advertises the extension; a legacy connection never shows it, even when the server declares the key, because the client never sends `events/*` there.

- **Event types** (`EventControls`): `events/list`, with each type's description and a badge per advertised delivery mode, following `notifications/events/list_changed` and the paginated-lists setting like the Tools list. Types excluded for invalid `x-mcp-header` annotations are listed below with the reason.
- **Subscribe form** (`EventDetailPanel`): the type's `inputSchema` and `payloadSchema`, the `Mcp-Name` and `Mcp-Param-*` headers its requests carry, an argument form generated from `inputSchema` by the shared `SchemaForm`, a mode picker limited to the type's advertised modes, and `maxAgeMs` plus `maxEvents` (poll) or `heartbeatMs` (push).
- **Subscriptions** (`EventSubscriptionCard`): mode, state (starting, active, reconnecting, terminated, stopped), current cursor, granted heartbeat or `nextPollMs`, tallies including gaps and errors, the last error and how a termination was handled, with Stop, Resume and Remove.
- **Occurrences** (`EventLogPanel`): newest first, each occurrence's `data` rendered as **inert JSON text only** (payloads are untrusted), with a payload-schema validation badge, interleaved with the gap, error, reconnect and termination markers.

The subscriptions and the log are the core subscription engine's (`EventSubscriptionsState`); the screen only renders them. **Webhook** management is a later phase ([#3031](https://github.com/modelcontextprotocol/inspector/issues/3031)): the mode picker is built from `SUBSCRIBABLE_DELIVERY_MODES` in `src/utils/eventsUtils.ts` (`poll`, `push`), so a webhook-only type still lists with its badge but explains that it cannot be subscribed to here yet. Styling follows the Mantine-first rules in [`AGENTS.md`](../../AGENTS.md) — theme variants and component props over CSS, `--inspector-*` tokens over raw colors.

## Load testing (`#2911`)

Expand Down Expand Up @@ -115,12 +126,14 @@ Nothing _enforces_ the boundary — no path alias keys off it, and the coverage

## Core tab automation contract

The Tools, Resources, Prompts and Skills screens each expose a `data-testid` plus a
The Tools, Resources, Prompts, Skills and Events screens each expose a `data-testid` plus a
small set of `data-*` attributes, so a headless driver can `waitForSelector` on
a deterministic signal rather than on visible copy. `scripts/smoke-web-tabs.mjs`
drives the first three of those four against `test-servers/configs/web-tabs-http.json`
([#2148](https://github.com/modelcontextprotocol/inspector/issues/2148)); Skills
publishes the same contract but is not smoked yet ([#2234](https://github.com/modelcontextprotocol/inspector/issues/2234)).
`scripts/smoke-web-events.mjs` drives Events against `test-servers/configs/events-modern-http.json`
([#3030](https://github.com/modelcontextprotocol/inspector/issues/3030)).
Treat them as a public contract, for the same reason as the Apps ones below:

| Attribute | Where | Meaning |
Expand All @@ -142,6 +155,12 @@ Treat them as a public contract, for the same reason as the Apps ones below:
| `data-skill-count` | on `skills-screen` | Entries accumulated from `skills/list`. |
| `data-skill-page-count` | on `skills-screen` | Pages the last `skills/list` walk took — a **separate** fact from the count, and the one that shows pagination actually happened. |
| `data-testid="skill-manifest"` | detail pane | The selected skill's resource manifest. Absent for a `resources: "dynamic"` skill, which has no manifest to render. |
| `data-testid="events-screen"` | Events root | The element carrying the three attributes below ([#3030](https://github.com/modelcontextprotocol/inspector/issues/3030)). |
| `data-event-count` | on `events-screen` | Event types listed (`events/list`, after exclusions). |
| `data-subscription-count` | on `events-screen` | Subscriptions in the engine's registry, live or not. |
| `data-log-count` | on `events-screen` | Entries in the occurrence log, every subscription's. |
| `data-testid="event-subscription"` | each subscription | One per subscription, with `data-status` = `starting` / `active` / `reconnecting` / `terminated` / `stopped`. |
| `data-testid="event-log-entry"` | each log entry | One per log entry, with `data-kind` = `event` / `gap` / `error` / `reconnect` / `terminated`. |

Why attributes rather than text: a smoke that waited on a label fails the next
time the label is reworded, which is noise rather than signal — and it fails as
Expand Down
51 changes: 51 additions & 0 deletions clients/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import type {
ServerListProps,
ShellProps,
SkillsPanelProps,
EventsPanelProps,
TasksPanelProps,
ToolsPanelProps,
} from "./components/views/InspectorView/types";
Expand Down Expand Up @@ -484,6 +485,14 @@ function App() {
skillsPageCount,
skillsLoadError,
refreshSkills,
eventsPagination,
excludedEventTypes,
eventsListChanged,
clearEventsListChanged,
refreshEvents,
loadEventsPage,
eventSubscriptions,
eventLog,
subscriptions,
subscriptionStreamState,
messages,
Expand Down Expand Up @@ -930,6 +939,8 @@ function App() {
onLoadMoreTools,
onLoadMorePrompts,
onLoadMoreResources,
onRefreshEvents,
onLoadMoreEvents,
} = useServerCommands({
sessionRef,
servers,
Expand Down Expand Up @@ -964,6 +975,10 @@ function App() {
loadToolsPage,
loadPromptsPage,
loadResourcesPage,
eventsPagination,
refreshEvents,
clearEventsListChanged,
loadEventsPage,
lastPersistedSettings,
applyLiveServerSettings,
updateServerSettings,
Expand Down Expand Up @@ -1101,6 +1116,14 @@ function App() {
loadedPages: resourcesPagination.loadedPages,
onLoadMore: onLoadMoreResources,
};
const eventsPaginationControls: ListPaginationControlsProps = {
paginated: eventsPagination.paginated,
onPaginatedChange: onTogglePaginatedLists,
canLoadMore: eventsPagination.canLoadMore,
loadedPages: eventsPagination.loadedPages,
loaded: eventsPagination.loaded,
onLoadMore: onLoadMoreEvents,
};

// Clear / Export / Replay for the four log-ish views (Logs, Protocol,
// Network, Console), plus the Protocol per-section variants.
Expand Down Expand Up @@ -1973,6 +1996,33 @@ function App() {
: {}),
};

// Events (SEP-3415, #3030). The subscription engine is per session, so the
// actions read the live one; with none (between sessions) a subscribe has
// nothing to run on and says so, and the rest have nothing to act on.
const eventSubscriptionsState = stores?.eventSubscriptionsState ?? null;
const eventsPanelProps: EventsPanelProps = {
eventTypes: eventsPagination.items,
excludedEventTypes,
eventsListChanged,
eventsLoadError: eventsPagination.error,
eventsPagination: eventsPaginationControls,
eventSubscriptions,
eventLog,
eventsUi: ui.eventsUi,
onEventsUiChange: setUi.setEventsUi,
onRefreshEvents,
onSubscribeEvent: (eventType, options) => {
if (!eventSubscriptionsState) throw new Error("Not connected.");
eventSubscriptionsState.subscribe(eventType, options);
},
onStopEventSubscription: (id) => eventSubscriptionsState?.stop(id),
onResumeEventSubscription: (id) => {
eventSubscriptionsState?.resubscribe(id);
},
onRemoveEventSubscription: (id) => eventSubscriptionsState?.remove(id),
onClearEventLog: () => eventSubscriptionsState?.clearLog(),
};

const tasksPanelProps: TasksPanelProps = {
tasks,
progressByTaskId,
Expand Down Expand Up @@ -2047,6 +2097,7 @@ function App() {
resources={resourcesPanelProps}
apps={appsPanelProps}
skills={skillsPanelProps}
events={eventsPanelProps}
tasks={tasksPanelProps}
logs={logsPanelProps}
protocol={protocolPanelProps}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { DeliveryModeBadge } from "./DeliveryModeBadge";

const meta: Meta<typeof DeliveryModeBadge> = {
title: "Elements/DeliveryModeBadge",
component: DeliveryModeBadge,
};

export default meta;
type Story = StoryObj<typeof DeliveryModeBadge>;

export const Poll: Story = { args: { mode: "poll" } };
export const Push: Story = { args: { mode: "push" } };
export const Webhook: Story = { args: { mode: "webhook" } };
export const UnknownMode: Story = { args: { mode: "carrier-pigeon" } };
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, it, expect } from "vitest";
import { renderWithMantine, screen } from "../../../test/renderWithMantine";
import { DeliveryModeBadge } from "./DeliveryModeBadge";

describe("DeliveryModeBadge", () => {
it.each(["poll", "push", "webhook"])("renders the %s mode", (mode) => {
renderWithMantine(<DeliveryModeBadge mode={mode} />);
expect(screen.getByText(mode)).toBeInTheDocument();
});

it("renders a mode named after an Object member as an unknown one", () => {
renderWithMantine(<DeliveryModeBadge mode="constructor" />);
expect(screen.getByText("constructor")).toBeInTheDocument();
});

it("still renders a mode this client does not know", () => {
renderWithMantine(<DeliveryModeBadge mode="carrier-pigeon" />);
expect(screen.getByText("carrier-pigeon")).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Badge } from "@mantine/core";
import { filledBadgeColor } from "../filledBadgeColor";

export interface DeliveryModeBadgeProps {
/**
* A delivery mode from an event type's `delivery` (SEP-3415). A string
* rather than the three known modes: a server may advertise one this client
* does not know, and the list still shows it (in gray) rather than hiding it.
*/
mode: string;
}

// A Map, not an object literal: the mode is server-controlled, and a name like
// `constructor` or `__proto__` must miss rather than hit an inherited member.
const COLOR_BY_MODE: ReadonlyMap<string, string> = new Map([
["poll", "blue"],
["push", "teal"],
["webhook", "grape"],
]);

const ModeBadge = Badge.withProps({
variant: "filled",
autoContrast: true,
size: "sm",
// Mode names are lowercase protocol literals; keep their casing.
tt: "none",
});

/**
* Badge naming one Events delivery mode (`poll`, `push`, `webhook`), one
* distinct color each so an event type's offer reads at a glance in the list.
* Filled + `autoContrast` like the other semantic badges, for WCAG AA.
*/
export function DeliveryModeBadge({ mode }: DeliveryModeBadgeProps) {
return (
<ModeBadge color={filledBadgeColor(COLOR_BY_MODE.get(mode) ?? "gray")}>
{mode}
</ModeBadge>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { EventSubscriptionStatusBadge } from "./EventSubscriptionStatusBadge";

const meta: Meta<typeof EventSubscriptionStatusBadge> = {
title: "Elements/EventSubscriptionStatusBadge",
component: EventSubscriptionStatusBadge,
};

export default meta;
type Story = StoryObj<typeof EventSubscriptionStatusBadge>;

export const Starting: Story = { args: { status: "starting" } };
export const Active: Story = { args: { status: "active" } };
export const Reconnecting: Story = { args: { status: "reconnecting" } };
export const Terminated: Story = { args: { status: "terminated" } };
export const Stopped: Story = { args: { status: "stopped" } };
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, it, expect } from "vitest";
import type { EventSubscriptionStatus } from "@inspector/core/mcp/state/eventSubscriptionsState.js";
import { renderWithMantine, screen } from "../../../test/renderWithMantine";
import { EventSubscriptionStatusBadge } from "./EventSubscriptionStatusBadge";

describe("EventSubscriptionStatusBadge", () => {
const statuses: EventSubscriptionStatus[] = [
"starting",
"active",
"reconnecting",
"terminated",
"stopped",
];

it.each(statuses)("renders %s", (status) => {
renderWithMantine(<EventSubscriptionStatusBadge status={status} />);
expect(screen.getByText(status)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Badge } from "@mantine/core";
import type { EventSubscriptionStatus } from "@inspector/core/mcp/state/eventSubscriptionsState.js";
import { filledBadgeColor } from "../filledBadgeColor";

export interface EventSubscriptionStatusBadgeProps {
status: EventSubscriptionStatus;
}

const statusColor: Record<EventSubscriptionStatus, string> = {
starting: "blue",
active: "green",
reconnecting: "yellow",
terminated: "red",
stopped: "gray",
};

const FilledBadge = Badge.withProps({
variant: "filled",
autoContrast: true,
});

/**
* The state of one Events subscription (SEP-3415, #3030): starting, active,
* reconnecting, terminated by the server, or stopped by the user. The
* TaskStatusBadge treatment, so the two read alike.
*/
export function EventSubscriptionStatusBadge({
status,
}: EventSubscriptionStatusBadgeProps) {
return (
<FilledBadge color={filledBadgeColor(statusColor[status])}>
{status}
</FilledBadge>
);
}
Loading