diff options
| author | Adam Malczewski <[email protected]> | 2026-06-24 21:04:49 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-24 21:04:49 +0900 |
| commit | 1b2a13e29e98da04d55c061c2dcadb8c36d783cd (patch) | |
| tree | ca818510b2337f2cd291aff61e0171712a1435f5 /packages | |
| parent | 5c37d89f412f0dbb6fa798b16e1d4bb91dc58595 (diff) | |
| download | dispatch-1b2a13e29e98da04d55c061c2dcadb8c36d783cd.tar.gz dispatch-1b2a13e29e98da04d55c061c2dcadb8c36d783cd.zip | |
feat(transport-contract): add McpServerInfo + McpStatusResponse (0.22.0)
Additive types for GET /conversations/:id/mcp status endpoint, mirroring the
existing LSP status types. McpServerState, McpServerInfo, McpStatusResponse.
+2 type-test assertions. Version bump 0.21.0 → 0.22.0.
Handoff written: frontend-mcp-status-handoff.md (backend route + FE consumption).
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/transport-contract/package.json | 2 | ||||
| -rw-r--r-- | packages/transport-contract/src/contract.types.test.ts | 22 | ||||
| -rw-r--r-- | packages/transport-contract/src/index.ts | 31 |
3 files changed, 54 insertions, 1 deletions
diff --git a/packages/transport-contract/package.json b/packages/transport-contract/package.json index 34c7fc4..842a28b 100644 --- a/packages/transport-contract/package.json +++ b/packages/transport-contract/package.json @@ -1,6 +1,6 @@ { "name": "@dispatch/transport-contract", - "version": "0.21.0", + "version": "0.22.0", "type": "module", "private": true, "main": "dist/index.js", diff --git a/packages/transport-contract/src/contract.types.test.ts b/packages/transport-contract/src/contract.types.test.ts index e022812..6d0129c 100644 --- a/packages/transport-contract/src/contract.types.test.ts +++ b/packages/transport-contract/src/contract.types.test.ts @@ -12,6 +12,7 @@ import type { LspServerInfo, LspServerState, LspStatusResponse, + McpStatusResponse, SetCwdRequest, } from "./index.js"; @@ -129,4 +130,25 @@ describe("transport-contract types compile and are exported", () => { it("LspStatusResponse: populated servers when cwd is set", () => { expect(_lspWithServers.servers).toHaveLength(2); }); + + // ─── MCP status ───────────────────────────────────────────────────────────── + + it("McpStatusResponse: empty servers when cwd is null", () => { + const _noCwd: McpStatusResponse = { conversationId: "c1", cwd: null, servers: [] }; + expect(_noCwd.servers).toEqual([]); + }); + + it("McpStatusResponse: populated servers when cwd is set", () => { + const _withServers: McpStatusResponse = { + conversationId: "c2", + cwd: "/home/user/project", + servers: [ + { id: "freecad", state: "connected", toolCount: 12, configSource: ".dispatch/mcp.json" }, + { id: "chrome", state: "error", error: "spawn failed", toolCount: 0 }, + ], + }; + expect(_withServers.servers).toHaveLength(2); + expect(_withServers.servers[0]?.toolCount).toBe(12); + expect(_withServers.servers[1]?.error).toBe("spawn failed"); + }); }); diff --git a/packages/transport-contract/src/index.ts b/packages/transport-contract/src/index.ts index c251ae4..4e3e7dc 100644 --- a/packages/transport-contract/src/index.ts +++ b/packages/transport-contract/src/index.ts @@ -455,6 +455,37 @@ export interface LspStatusResponse { readonly servers: readonly LspServerInfo[]; } +// ─── MCP status ────────────────────────────────────────────────────── + +export type McpServerState = "connecting" | "connected" | "error" | "disconnected"; + +/** One MCP server's status as reported to the frontend. */ +export interface McpServerInfo { + /** Stable server id (the config key from `.dispatch/mcp.json`), e.g. "freecad". */ + readonly id: string; + /** Current connection state. */ + readonly state: McpServerState; + /** Present only when `state === "error"`: a short human-readable reason. */ + readonly error?: string; + /** Number of tools discovered from this server. */ + readonly toolCount: number; + /** Which config source this server was resolved from. */ + readonly configSource?: string; +} + +/** Response of `GET /conversations/:id/mcp`. */ +export interface McpStatusResponse { + readonly conversationId: string; + /** + * The resolved working directory the MCP servers are configured for, or + * `null` when no cwd has been set for the conversation (then `servers` is + * empty). Mirrors the LSP status endpoint behavior. + */ + readonly cwd: string | null; + /** The MCP servers configured for `cwd` and their live state. */ + readonly servers: readonly McpServerInfo[]; +} + /** * Request body for `POST /chat/warm` — manually trigger a prompt-cache WARMING * request for a conversation (e.g. a frontend "warm now" button, or fast tests |
