Commit graph inspector/client
Author SHA1 Message Date
Ola Hungerford
edbe2f84f3
Merge branch 'main' into claude/issue-1028-20260121-1235 2026-01-23 08:03:27 -07:00
Cliff Hall
7ef0971c81
Add Tasks support (#1013)
* ### client/src/App.tsx

- Imports:
  - Added: `Task` and `GetTaskResultSchema` to the same import block.
  - UI Icons: Added `ListTodo` from `lucide-react` to the icon imports.
  - Components: Added `TasksTab` import beside `ToolsTab`.
  - Config utils: Added `getMCPTaskTtl` to the config utils import block.

- State additions:
  - `const [tasks, setTasks] = useState<Task[]>([]);`
  - Extended `errors` state to include a `tasks` key: `tasks: null,`
  - `const [selectedTask, setSelectedTask] = useState<Task | null>(null);`
  - `const [isPollingTask, setIsPollingTask] = useState(false);`
  - `const [nextTaskCursor, setNextTaskCursor] = useState<string | undefined>();`

- Hook: `useConnection({...})` return value usage extended
  - Added destructured functions: `cancelTask: cancelMcpTask` and `listTasks: listMcpTasks` from the custom hook.

- Notification handling:
  - In `onNotification`, added:
    - If `method === "notifications/tasks/list_changed"`, call `listTasks()` (voided).
    - If `method === "notifications/tasks/status"`, treat `notification.params` as a `Task` and update `tasks` state: replace if exists by `taskId`, otherwise prepend. Also update `selectedTask` if it’s the same `taskId`.

- Tab routing:
  - When computing valid tabs, added `tasks` when server declares capability: `...(serverCapabilities?.tasks ? ["tasks"] : []),`
  - When choosing a default tab, added a branch to fall back to `"tasks"` if neither resources/prompts/tools are present but tasks are.

- Effect for Tasks tab:
  - When `mcpClient` is connected and `activeTab === "tasks"`, invoke `listTasks()`.

- Tools → task-augmented calls integration in `callTool`:
  - Parameter signature supports `runAsTask?: boolean` (already present in this file), but now:
    - If `runAsTask` is true, augment the `tools/call` request’s `params` with a `task` object: `{ task: { ttl: getMCPTaskTtl(config) } }`.
  - Use a permissive result schema for tool call: `sendMCPRequest(request, z.any(), "tools")` to avoid version-mismatch schema issues.
  - Task reference detection introduced:
    - `isTaskResult` helper checks for a nested `task` object with `taskId` (i.e., `response.task.taskId`).
  - When task is detected:
    - Set `isPollingTask(true)`.
    - Immediately set a temporary `toolResult` that includes text content “Task created: … Polling for status…” and `_meta` with `"io.modelcontextprotocol/related-task": { taskId }`.
    - Start a polling loop:
      - Delay 1s between polls.
      - Call `tasks/get` with `GetTaskResultSchema` for status.
      - If status is `completed`: call `tasks/result` with `z.any()` to retrieve the final result and set it as `toolResult`; call `listTasks()`.
      - If status is `failed` or `cancelled`: set an error `toolResult` content that includes the status + `statusMessage`; call `listTasks()`.
      - Else (still running): update `toolResult` content with current `status`/`statusMessage` and preserve `_meta` related-task.
    - After loop, set `isPollingTask(false)`.
  - When not a task response, set `toolResult` directly from response (cast to `CompatibilityCallToolResult`).

- Tasks list + cancel helpers in App:
  - `listTasks`: uses `listMcpTasks(nextTaskCursor)` from the hook, updates `tasks`, `nextTaskCursor`, and clears `errors.tasks`.
  - `cancelTask`: calls `cancelMcpTask(taskId)`, updates `tasks` array by `taskId`, updates `selectedTask` if it matches, and clears `errors.tasks`.

- UI integration:
  - Added a `TabsTrigger` for “Tasks” with `<ListTodo />` icon, disabled unless server supports tasks.
  - Added `<TasksTab />` to the main `TabsContent` block, passing: `tasks`, `listTasks`, `clearTasks`, `cancelTask`, `selectedTask`, `setSelectedTask`, `error={errors.tasks}`, `nextCursor={nextTaskCursor}`.
  - Passed `isPollingTask={isPollingTask}` and `toolResult` into `ToolsTab` so the Tools tab can show the live “Polling Task…” state and block reruns while polling.

Note: The raw diff is long; the key hunks align with the above bullet points (imports, state, notifications, tab wiring, request augmentation, polling loop, UI additions).

---

### client/src/components/ToolsTab.tsx

- Props shape changed:
  - Added `isPollingTask?: boolean` prop in the destructured props and in the prop types.
  - The `callTool` callback signature is now `(name, params, metadata?, runAsTask?) => Promise<void>` (runAsTask added earlier; test updates elsewhere reflect this).

- Local state additions:
  - `const [runAsTask, setRunAsTask] = useState(false);`

- Reset behavior:
  - When switching tools (`useEffect` on `selectedTool`), reset `runAsTask(false)`.
  - When clearing the list in `ListPane.clearItems`, also call `setRunAsTask(false)`.

- UI additions:
  - New checkbox control block to toggle “Run as task”:
    - Checkbox `id="run-as-task"`, bound to `runAsTask`, with `onCheckedChange` → `setRunAsTask(checked)`.
    - Label “Run as task”.
  - Run button disabling conditions expanded to include `isPollingTask`.
  - Run button text shows spinner with conditional label:
    - If `isToolRunning || isPollingTask` → show spinner and text `isPollingTask ? "Polling Task..." : "Running..."`.

- Call invocation change:
  - When clicking “Run Tool”, the `callTool` is invoked with `(selectedTool.name, params, metadata?, runAsTask)`.

- ToolResults relay:
  - Passes `isPollingTask` to `<ToolResults />`.

---

### client/src/components/ToolResults.tsx

- Props shape changed:
  - Added optional prop: `isPollingTask?: boolean`.

- Task-running banner logic:
  - Extracts related task from the tool result’s `_meta["io.modelcontextprotocol/related-task"]` if present.
  - Computes `isTaskRunning` as `isPollingTask ||` a text-heuristic against `structuredResult.content` entries that contain text like “Polling” or “Task status”.
  - Header “Tool Result:” now conditionally shows:
    - `Error` (red) if `isError` is true, else
    - `Task Running` (yellow) if `isTaskRunning`, else
    - `Success` (green).

No other changes to validation or rendering of content blocks.

---

### client/src/components/TasksTab.tsx (new file)

- A brand new tab to list and inspect tasks.
- Key elements:
  - Imports `Task` type and multiple status icons.
  - `TaskStatusIcon` component maps task `status` to an icon and color.
  - Main `TasksTab` props: `tasks`, `listTasks`, `clearTasks`, `cancelTask`, `selectedTask`, `setSelectedTask`, `error`, `nextCursor`.
  - Left column (`ListPane`): lists tasks, shows status icon, `taskId`, `status`, and last update time; button text changes to “List More Tasks” if `nextCursor` present; disables button if no cursor and list non-empty.
  - Right column:
    - Shows error `Alert` if `error` prop provided.
    - If a task is selected: header with `Task Details`, a Cancel button when `status === "working"` (shows a spinner while cancelling), and a grid of task fields: Status (with colored label and icon), Last Updated, Created At, TTL (shows “Infinite” if `ttl === null`, otherwise shows numeric with `s` suffix), optional Status Message, and full task JSON via `JsonView`.
    - If no task is selected: centered empty state with a “Refresh Tasks” button.

---

### client/src/lib/hooks/useConnection.ts

- Imports added from `@modelcontextprotocol/sdk/types.js`:
  - `ListTasksResultSchema`, `CancelTaskResultSchema`, `TaskStatusNotificationSchema`.

- Client capabilities on `connect`:
  - Added `tasks: { list: {}, cancel: {} }` into the `clientCapabilities` passed to `new Client(...)`.

- Notification handling setup:
  - The hook’s notification schema registration now includes the `TaskStatusNotificationSchema` in the `setNotificationHandler` list so the app receives `notifications/tasks/status`.

- New hook functions:
  - `cancelTask(taskId: string)` sends `tasks/cancel` with `CancelTaskResultSchema`.
  - `listTasks(cursor?: string)` sends `tasks/list` with `ListTasksResultSchema`.

- Exports:
  - Returned object now includes `cancelTask` and `listTasks`.

---

### client/src/utils/configUtils.ts

- Added a new getter:
  - `export const getMCPTaskTtl = (config: InspectorConfig): number => { return config.MCP_TASK_TTL.value as number; };`

---

### client/src/lib/configurationTypes.ts

- `InspectorConfig` type extended with a new item:
  - `MCP_TASK_TTL: ConfigItem;`
  - Includes descriptive JSDoc about default TTL in milliseconds for newly created tasks.

---

### client/src/lib/constants.ts

- `DEFAULT_INSPECTOR_CONFIG` extended with a default for task TTL:
  - Key: `MCP_TASK_TTL`
  - Label: `"Task TTL"`
  - Description: `"Default Time-to-Live (TTL) in milliseconds for newly created tasks"`
  - Default `value: 60000`
  - `is_session_item: false`

---

### client/src/components/__tests__/ToolsTab.test.tsx

- Expectations updated due to new `callTool` signature (4th arg `runAsTask`). Everywhere the test asserts a `callTool` invocation, an additional trailing `false` argument was added to reflect the default state when the box isn’t checked.
  - Examples of added trailing `false` at various assertion points (line offsets from diff): after calls around prior lines 132, 157, 193, 236, 257, 279, 297, 818, 1082 (now passing 4 arguments: name, params, metadata-or-undefined, false).

---

### Additional notes

- The Tasks feature is wired end-to-end:
  - Client capability declaration (list/cancel)
  - Notification handler for `notifications/tasks/status`
  - Tools call augmentation with `task` `{ ttl }`
  - Polling loop using `tasks/get` and `tasks/result`
  - UI feedback in Tools and dedicated Tasks tab
  - Configurable TTL via new config item and getter

* Fix issue where displayed task on task tab was not updated when task completes, leaving the cancel task button available.

* Handle button the same when input_requred or working state

* ### What changed
- Added **receiver-side (client-side) Tasks support** to the Inspector client for task-augmented **server → client** requests.
- When the server sends `sampling/createMessage` or `elicitation/create` with `params.task`, the client now:
  - Creates a local task and immediately returns a `CreateTaskResult` (`{ task: ... }`).
  - Runs the underlying user-driven flow asynchronously.
  - Updates task state to `completed` / `failed` and makes the final payload available via `tasks/result`.
- Implemented server polling handlers backed by the local task store:
  - `tasks/get`
  - `tasks/result` (blocks until payload is ready)
  - `tasks/list`
  - `tasks/cancel`
- Advertises task-augmented request capabilities via `capabilities.tasks.requests.sampling.createMessage` and `capabilities.tasks.requests.elicitation.create` when the corresponding callbacks are provided.
- Emits best-effort `notifications/tasks/status` updates as local task status changes.

* Fix review requests.

* In the ToolsTab, when a tool call results in an elicitation request, the app automatically switches to the elicitation tab, and once submitted, switches back to the ToolsTab to view the result of the tool call.

However, when a tool call results in a sampling request, it does not switch automatically to the SamplingTab and when the sampling request form is submitted it does not automatically switch back to the ToolsTab to view the result of the tool call.

These changes make the sampling use case work like the elicitation one. Tests were added.
2026-01-22 21:40:59 -07:00
claude[bot]
7f6e5792b2 Bump version to 0.19.0 across all packages
- Updated version in root package.json
- Updated version in cli/package.json
- Updated version in client/package.json
- Updated version in server/package.json
- Updated workspace dependencies in root package.json
- Updated package-lock.json via npm install

Co-authored-by: Ola Hungerford <olaservo@users.noreply.github.com>
2026-01-21 12:37:36 +00:00
Copilot
da684d0a9d
Update LICENSE and package.json for Linux Foundation transition (#1018)
* Initial plan

* Update LICENSE to Apache 2.0 + MIT + CC-BY-4.0 hybrid license for Linux Foundation transition

Co-authored-by: olaservo <16480113+olaservo@users.noreply.github.com>

* Update package.json license fields to reference LICENSE file

Co-authored-by: olaservo <16480113+olaservo@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: olaservo <16480113+olaservo@users.noreply.github.com>
Co-authored-by: Ola Hungerford <olahungerford@gmail.com>
2026-01-19 09:33:43 -07:00
Cliff Hall
94ba4c3b56
* In useConnection.ts (#924)
- in connect()
    - Pass authProvider in transport options
2026-01-18 19:08:43 -07:00
Ahmet Soormally
2bf0dd1a03
fix: omit scope field in OAuth DCR when undefined and improve error handling (#1003)
fix: OAuth DCR scope field compliance

Omits the scope field entirely when undefined, per RFC 7591. This allows OAuth servers to assign default scopes instead of registering clients with no scopes.

Tested with Keycloak DCR.
2026-01-18 14:22:21 -07:00
Cliff Hall
8cb845798e
Merge branch 'main' into inspector/error-popup 2026-01-09 15:52:22 -05:00
olaservo
66b84b0431 Update minimum SDK version to ^1.25.2 in package.json files
Ensures fresh installs without lock file get the patched version.

🦉 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 20:51:05 -07:00
cliffhall
f7bf100a65 Fix is401Error 2026-01-07 14:23:46 -05:00
Cliff Hall
04898cb5ce
Update client/src/lib/hooks/useConnection.ts 2026-01-07 14:16:22 -05:00
Cliff Hall
36a7244f86
Update client/src/lib/hooks/useConnection.ts
Adding fix for Via Proxy mode
2026-01-07 14:07:17 -05:00
thinhtpt-dev
e1886a8229 fix: detect 401 errors from StreamableHTTP transport in client 2026-01-06 14:00:13 +07:00
Dale Seo
6eed736d23 fix: display description for anyOf fields in JSON editor 2025-12-18 16:40:50 -05:00
cliffhall
96e256687e Bump TS SDK version to 1.24.3 2025-12-13 12:01:40 -05:00
Cliff Hall
e7018c0e23
Merge pull request #969 from olaservo/release/v0.18.0
chore: bump version to 0.18.0
2025-12-13 11:11:43 -05:00
olaservo
b3a27297c8 chore: bump version to 0.18.0
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 08:08:44 -07:00
Ola Hungerford
5778a3a93e
Merge pull request #926 from bolinfest/sapling-pr-archive-bolinfest
fix: allow empty elicitation form data when all fields are optional
2025-12-11 21:34:12 -07:00
Vijay Daswani
1e1b9e3619 feat: add theme property to Icon and Prompt types 2025-12-12 01:25:30 +04:00
Cliff Hall
2c94a00884
Merge branch 'main' into sep-1330-enums 2025-12-04 16:19:22 -05:00
cliffhall
124e73311a Bump version to 0.17.5 2025-12-04 09:46:13 -05:00
cliffhall
cb1be764c1 Exclude tests from build in tsconfig.app.json 2025-12-03 10:16:33 -05:00
cliffhall
d0c5b884c6 Fix linter issues in DynamicJsonForm.tsx 2025-12-03 10:08:13 -05:00
cliffhall
3f0c45e10d update DynamicJsonForm tests; add enum coverage and JSON-mode assertions
- Align tests with new form-first rendering and UI behavior:
  - Labels prefer schema `title` over property key.
  - Descriptions shown for boolean checkboxes and select fields.
  - Explicit mode switching between Form/JSON when needed.
- Add comprehensive coverage for enum schema variants:
  - Titled single-select via `oneOf`/`anyOf` with `{ const, title }`.
  - Untitled single-select via `enum` (with legacy `enumNames` labels).
  - Untitled multi-select via `items.enum` with `minItems`/`maxItems` helper text.
  - Titled multi-select via `items.anyOf`/`oneOf` with `{ const, title }`.
- Adjust complex/JSON-mode tests to click “Switch to JSON” before asserting textarea and clipboard interactions.
- Fix debounced JSON update expectations to assert parsed objects rather than raw text.

Files updated:
- `client/src/components/__tests__/DynamicJsonForm.test.tsx`
- `client/src/components/__tests__/DynamicJsonForm.array.test.tsx`
2025-12-03 09:58:18 -05:00
cliffhall
fd99d879c5 DynamicJsonForm improvements and full enum schema support
In DynamicJsonForm.tsx,
  - Support all five enum shapes used by MCP SDK:
    - Titled single-select via `oneOf`/`anyOf` with `{ const, title }`
    - Untitled single-select via `enum`
    - Titled legacy single-select with optional `enumNames` for labels
    - Titled multi-select via `items.anyOf`/`oneOf`
    - Untitled multi-select via `items.enum`
  - Show field descriptions for string select fields and boolean checkboxes (consistent help text above inputs).
  - Prefer schema property `title` for object field labels; fall back to the JSON key when missing.
  - Allow top‑level form rendering for objects with properties, arrays with items, and primitive types (was overly strict before).
  - Multi-select UI: sensible list size and `minItems`/`maxItems` helper text when present.
  - JSON editor fallback, copy/format controls, and debounced parsing preserved.
  - apply defaults for optional fields during form init

In schemaUtils.ts
  - `generateDefaultValue` now includes optional properties that declare a `default`, ensuring fields like strings show their defaults on first render.

In jsonUtils.ts
  - Add legacy `enumNames?: string[]` and array constraints `minItems?`/`maxItems?`.
2025-12-02 19:37:28 -05:00
Cliff Hall
7b644f9f99
Merge branch 'main' into jesselumarie/test-SEP-974 2025-12-01 14:13:47 -05:00
Michael Bolin
4b20f15c72 add suggested tests from code review 2025-12-01 10:07:10 -08:00
evalstate
6a86c19636 bump prettier. 3.7 was raising issues in CI (using 3.7.1) that 3.6.2 was not. 2025-11-27 20:48:30 +00:00
evalstate
927098faa9 prettier 2025-11-27 20:39:51 +00:00
evalstate
635a9a18f0 zod4 compatibility fixed for CI 2025-11-27 19:41:40 +00:00
Jesse Lumarie
a114db85bd mcp: update resources + icon alignment 2025-11-24 13:04:05 -07:00
Michael Bolin
92e01dca08 fix: allow empty elicitation form data when all fields are optional 2025-11-19 17:38:11 -08:00
Cliff Hall
35286a24c6
Merge branch 'main' into jesselumarie/test-SEP-974 2025-11-19 16:21:26 -05:00
lorenzo.neumann
c0b3b952f5 Merge branch 'main' of https://github.com/modelcontextprotocol/inspector into meta_properies_in_tools 2025-11-18 15:07:12 +01:00
Cliff Hall
156e1dcfed
Merge branch 'main' into fix/resolve-ref-pre-validation 2025-11-17 16:38:05 -05:00
Konstantin Konstantinov
a5d5593c97
Merge branch 'main' into meta_properies_in_tools 2025-11-15 01:34:22 +02:00
Konstantin Konstantinov
a45247a4f2
add validations against spec, add reserved metadata key validations 2025-11-15 01:26:13 +02:00
olaservo
54a9e7a8b8 Bump version to 0.17.4
Version 0.17.3 had TypeScript build errors that prevented successful builds. This patch release fixes those errors and bumps the version to 0.17.4.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-14 06:38:44 -07:00
olaservo
a33699f8e3 Fix notification parameters in HistoryAndNotifications tests 2025-11-14 05:25:56 -07:00
olaservo
c93c10beca Add typegaurd for blob 2025-11-14 05:25:36 -07:00
Vincent
6106b1b562 fix: Remove incorrect nested test 2025-11-13 14:30:28 -08:00
Cliff Hall
1598b28f3a
Merge branch 'main' into fix/resolve-ref-pre-validation 2025-11-13 11:06:15 -05:00
olaservo
3930bdd700 Bump version to 0.17.3 2025-11-12 18:29:41 -07:00
V
adb897f05b
Merge branch 'main' into fix/resolve-ref-pre-validation 2025-11-08 10:47:05 -08:00
Vincent
c1f18a8edd fix: add ref resolves def test 2025-11-08 10:46:28 -08:00
Vincent
12332932b0 fix: Modify test mock data 2025-11-08 09:57:48 -08:00
Vincent
8ad6253cd9 fix: Extract function to utils 2025-11-04 09:31:31 -08:00
Vincent
b000fc25bb fix: Remove redundant type 2025-11-04 09:24:54 -08:00
Vincent
2ab7d625e4 Resolve ref before validation 2025-11-04 07:44:06 -08:00
Cliff Hall
63eb231650
Merge branch 'main' into fix/set-scope-dcr 2025-11-04 09:35:15 -05:00
Cliff Hall
54484e7e8e
Merge branch 'main' into fix-default-null-array-input 2025-10-30 12:04:47 -04:00