@shardflux/mcp 0.3.1 → 0.4.1
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/CHANGELOG.md +120 -0
- package/README.md +122 -5
- package/dist/config.d.ts +6 -0
- package/dist/config.js +5 -5
- package/dist/errors.d.ts +26 -2
- package/dist/errors.js +89 -6
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/main.js +3 -0
- package/dist/server.d.ts +52 -13
- package/dist/server.js +407 -55
- package/package.json +2 -2
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.
|
|
6
|
+
export declare const MCP_SERVER_VERSION = "0.4.1";
|
|
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. `
|
|
18
|
-
* only touches the workspace inside `execute`, which is never called on these:
|
|
19
|
-
*
|
|
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: {
|
|
@@ -70,8 +75,19 @@ export declare function summarizeWorkspace(v: WorkspaceView): {
|
|
|
70
75
|
operation_id: string | null;
|
|
71
76
|
at: string | null;
|
|
72
77
|
} | null;
|
|
78
|
+
/** A pending suspend-when-idle request (workspace_suspend with after_seconds); null when none. */
|
|
79
|
+
suspend_request: {
|
|
80
|
+
requested_at: string;
|
|
81
|
+
after_seconds: number;
|
|
82
|
+
not_before: string;
|
|
83
|
+
} | null;
|
|
73
84
|
created_at: string;
|
|
74
85
|
deleted_at: string | null;
|
|
86
|
+
tree_revision?: number | undefined;
|
|
87
|
+
id: string;
|
|
88
|
+
key: string;
|
|
89
|
+
ready: boolean;
|
|
90
|
+
mode: "processful" | "file_first";
|
|
75
91
|
};
|
|
76
92
|
/** A template build without the stored recipe (the compiled steps are long): state, version and what the builder refused. */
|
|
77
93
|
export declare function summarizeBuild(b: TemplateBuild): {
|
|
@@ -190,15 +206,38 @@ export declare function compactTiming(t: LifecycleTiming): {
|
|
|
190
206
|
outcome: import("@shardflux/sdk").TimingOutcome;
|
|
191
207
|
};
|
|
192
208
|
export declare function okResult(value: unknown): CallToolResult;
|
|
193
|
-
/**
|
|
194
|
-
|
|
209
|
+
/**
|
|
210
|
+
* `timing` (optional): where the failed open/wait/wake spent its time, next to `error`. `extra` (0.4.0): more sibling
|
|
211
|
+
* fields, e.g. `feedback` (how to report the failure with send_feedback) or `hint`.
|
|
212
|
+
*/
|
|
213
|
+
export declare function errorResult(info: ToolErrorInfo, timing?: ReturnType<typeof compactTiming>, extra?: Record<string, unknown>): CallToolResult;
|
|
214
|
+
/** The `feedback` field of a failed call (0.4.0+): how to report it, with the error's request id and code. */
|
|
215
|
+
export declare function feedbackSuggestion(info: ToolErrorInfo): string;
|
|
195
216
|
export interface ServerOptions {
|
|
196
217
|
log?: Logger;
|
|
197
218
|
/** Replaces the HTTP client entirely (tests); default: the runtime fetch via makeFetch(env). */
|
|
198
219
|
fetch?: typeof fetch;
|
|
199
|
-
/**
|
|
220
|
+
/**
|
|
221
|
+
* Process environment: SHARDFLUX_HTTP_KEEPALIVE (read only from here), and the version check's opt-outs
|
|
222
|
+
* SHARDFLUX_NO_UPDATE_CHECK / NO_UPDATE_NOTIFIER (from process.env when `env` is not given).
|
|
223
|
+
*/
|
|
200
224
|
env?: Record<string, string | undefined>;
|
|
201
225
|
/** template_build reads local files only inside this directory (default: the process's working directory). */
|
|
202
226
|
cwd?: string;
|
|
227
|
+
/**
|
|
228
|
+
* The startup version check (0.4.0; default true): see `checkServerVersion`. false, SHARDFLUX_NO_UPDATE_CHECK=1 (also
|
|
229
|
+
* true, yes, on) or NO_UPDATE_NOTIFIER turn it off.
|
|
230
|
+
*/
|
|
231
|
+
versionCheck?: boolean;
|
|
203
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* The startup version check (0.4.0; contracts §30.4): one GET <api>/v1/client-versions through the server's fetch
|
|
235
|
+
* (the SDK's checkClientVersion: 3 s timeout, never throws) for @shardflux/mcp at MCP_SERVER_VERSION. Outdated or
|
|
236
|
+
* unsupported: one `warn` line whose message is the notice (`@shardflux/mcp 0.4.0 is outdated: 0.5.0 is available.
|
|
237
|
+
* Update: <upgrade command>`) plus the status fields. Anything else (current; unknown: not listed, `latest` null while
|
|
238
|
+
* the package is not distributed, or the request failed) is a `debug` line only. createShardfluxMcpServer runs it in
|
|
239
|
+
* the background and never awaits it: the handshake and every tool call proceed without it. Resolves to the status;
|
|
240
|
+
* never rejects (a logger that throws is ignored).
|
|
241
|
+
*/
|
|
242
|
+
export declare function checkServerVersion(apiUrl: string, f: typeof fetch, log: Logger): Promise<ClientVersionStatus>;
|
|
204
243
|
export declare function createShardfluxMcpServer(config: McpConfig, opts?: ServerOptions): Server;
|