@shardflux/mcp 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
2
  import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
3
- import type { JsonSchema, LifecycleTiming, Operation, TemplateBuild, TemplateDetail, TemplateOwner, ToolName, WorkspaceTool, WorkspaceView } from '@shardflux/sdk';
3
+ import type { ClientVersionStatus, JsonSchema, LifecycleTiming, Operation, TemplateBuild, TemplateDetail, TemplateOwner, ToolName, WorkspaceMode, WorkspaceTool, WorkspaceView } from '@shardflux/sdk';
4
4
  import type { McpConfig } from './config.js';
5
5
  import type { ToolErrorInfo } from './errors.js';
6
- export declare const MCP_SERVER_VERSION = "0.3.0";
6
+ export declare const MCP_SERVER_VERSION = "0.4.0";
7
+ /** The package this server is distributed as: its entry in GET /v1/client-versions (contracts §30.4). */
8
+ export declare const MCP_PACKAGE = "@shardflux/mcp";
7
9
  export declare const ALL_TOOL_PERMISSIONS: readonly ToolName[];
8
10
  export type ObjectSchema = JsonSchema & {
9
11
  type: 'object';
@@ -14,16 +16,19 @@ export interface Logger {
14
16
  (level: 'debug' | 'info' | 'warn' | 'error', message: string, fields?: Record<string, unknown>): void;
15
17
  }
16
18
  /**
17
- * The SDK's workspace tool definitions without a workspace. `workspaceTools()`
18
- * only touches the workspace inside `execute`, which is never called on these:
19
- * the proxy throws on any access, so a change in the SDK that did would fail loudly.
19
+ * The SDK's workspace tool definitions for a workspace mode, without a workspace. Given `tools` and `mode`,
20
+ * `workspaceTools()` only touches the workspace inside `execute`, which is never called on these: the proxy throws on
21
+ * any access, so a change in the SDK that did would fail loudly. `file_first` (0.4.0): the SDK offers only the exec
22
+ * and files tools, and exec is its file-first definition (executions: the result adds execution_id, state,
23
+ * tree_revision and changed).
24
+ */
25
+ export declare function sdkToolDefinitions(tools?: readonly ToolName[], mode?: WorkspaceMode): WorkspaceTool[];
26
+ /**
27
+ * What tools return for a workspace (no tokens or other credentials). `mode` (0.4.0) is `processful` or `file_first`
28
+ * (a view without it, from an older API, is processful); `tree_revision`, the latest revision of the file tree, only
29
+ * for file-first workspaces (the API reports 0 for every processful one).
20
30
  */
21
- export declare function sdkToolDefinitions(tools?: readonly ToolName[]): WorkspaceTool[];
22
- /** What tools return for a workspace (no tokens or other credentials). */
23
31
  export declare function summarizeWorkspace(v: WorkspaceView): {
24
- id: string;
25
- key: string;
26
- ready: boolean;
27
32
  observed_state: "running" | "failed" | "suspended" | "deleted" | "creating" | "starting" | "suspending" | "resuming" | "forking" | "stopping" | "deleting";
28
33
  desired_state: "running" | "suspended" | "deleted";
29
34
  template: {
@@ -72,6 +77,11 @@ export declare function summarizeWorkspace(v: WorkspaceView): {
72
77
  } | null;
73
78
  created_at: string;
74
79
  deleted_at: string | null;
80
+ tree_revision?: number | undefined;
81
+ id: string;
82
+ key: string;
83
+ ready: boolean;
84
+ mode: "processful" | "file_first";
75
85
  };
76
86
  /** A template build without the stored recipe (the compiled steps are long): state, version and what the builder refused. */
77
87
  export declare function summarizeBuild(b: TemplateBuild): {
@@ -190,15 +200,38 @@ export declare function compactTiming(t: LifecycleTiming): {
190
200
  outcome: import("@shardflux/sdk").TimingOutcome;
191
201
  };
192
202
  export declare function okResult(value: unknown): CallToolResult;
193
- /** `timing` (optional): where the failed open/wait/wake spent its time, next to `error`. */
194
- export declare function errorResult(info: ToolErrorInfo, timing?: ReturnType<typeof compactTiming>): CallToolResult;
203
+ /**
204
+ * `timing` (optional): where the failed open/wait/wake spent its time, next to `error`. `extra` (0.4.0): more sibling
205
+ * fields, e.g. `feedback` (how to report the failure with send_feedback) or `hint`.
206
+ */
207
+ export declare function errorResult(info: ToolErrorInfo, timing?: ReturnType<typeof compactTiming>, extra?: Record<string, unknown>): CallToolResult;
208
+ /** The `feedback` field of a failed call (0.4.0+): how to report it, with the error's request id and code. */
209
+ export declare function feedbackSuggestion(info: ToolErrorInfo): string;
195
210
  export interface ServerOptions {
196
211
  log?: Logger;
197
212
  /** Replaces the HTTP client entirely (tests); default: the runtime fetch via makeFetch(env). */
198
213
  fetch?: typeof fetch;
199
- /** Process environment (SHARDFLUX_HTTP_KEEPALIVE). */
214
+ /**
215
+ * Process environment: SHARDFLUX_HTTP_KEEPALIVE (read only from here), and the version check's opt-outs
216
+ * SHARDFLUX_NO_UPDATE_CHECK / NO_UPDATE_NOTIFIER (from process.env when `env` is not given).
217
+ */
200
218
  env?: Record<string, string | undefined>;
201
219
  /** template_build reads local files only inside this directory (default: the process's working directory). */
202
220
  cwd?: string;
221
+ /**
222
+ * The startup version check (0.4.0; default true): see `checkServerVersion`. false, SHARDFLUX_NO_UPDATE_CHECK=1 (also
223
+ * true, yes, on) or NO_UPDATE_NOTIFIER turn it off.
224
+ */
225
+ versionCheck?: boolean;
203
226
  }
227
+ /**
228
+ * The startup version check (0.4.0; contracts §30.4): one GET <api>/v1/client-versions through the server's fetch
229
+ * (the SDK's checkClientVersion: 3 s timeout, never throws) for @shardflux/mcp at MCP_SERVER_VERSION. Outdated or
230
+ * unsupported: one `warn` line whose message is the notice (`@shardflux/mcp 0.4.0 is outdated: 0.5.0 is available.
231
+ * Update: <upgrade command>`) plus the status fields. Anything else (current; unknown: not listed, `latest` null while
232
+ * the package is not distributed, or the request failed) is a `debug` line only. createShardfluxMcpServer runs it in
233
+ * the background and never awaits it: the handshake and every tool call proceed without it. Resolves to the status;
234
+ * never rejects (a logger that throws is ignored).
235
+ */
236
+ export declare function checkServerVersion(apiUrl: string, f: typeof fetch, log: Logger): Promise<ClientVersionStatus>;
204
237
  export declare function createShardfluxMcpServer(config: McpConfig, opts?: ServerOptions): Server;