jetty-mcp-server 1.0.0 → 1.1.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/README.md +61 -3
- package/dist/api-client.d.ts +71 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +201 -0
- package/dist/api-client.js.map +1 -0
- package/dist/client.d.ts +12 -28
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +47 -127
- package/dist/client.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lib.d.ts +14 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +11 -0
- package/dist/lib.js.map +1 -0
- package/dist/tool-definitions.d.ts +49 -0
- package/dist/tool-definitions.d.ts.map +1 -0
- package/dist/tool-definitions.js +428 -0
- package/dist/tool-definitions.js.map +1 -0
- package/dist/tools.d.ts +8 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +10 -111
- package/dist/tools.js.map +1 -1
- package/dist/webmcp.d.ts +61 -0
- package/dist/webmcp.d.ts.map +1 -0
- package/dist/webmcp.js +98 -0
- package/dist/webmcp.js.map +1 -0
- package/package.json +51 -6
- package/src/client.ts +0 -206
- package/src/index.ts +0 -17
- package/src/tools.ts +0 -222
- package/tsconfig.json +0 -18
package/README.md
CHANGED
|
@@ -14,15 +14,14 @@ Set your API token:
|
|
|
14
14
|
export JETTY_API_TOKEN="mlc_your_token_here"
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Get a token at [
|
|
17
|
+
Get a token at [jetty.io](https://jetty.io) → Settings → API Tokens.
|
|
18
18
|
|
|
19
19
|
## Environment Variables
|
|
20
20
|
|
|
21
21
|
| Variable | Required | Default | Description |
|
|
22
22
|
|----------|----------|---------|-------------|
|
|
23
23
|
| `JETTY_API_TOKEN` | Yes | — | Your Jetty API token (`mlc_...`) |
|
|
24
|
-
| `
|
|
25
|
-
| `JETTY_FLOWS_URL` | No | `https://flows-api.jetty.io` | Flows API base URL |
|
|
24
|
+
| `JETTY_API_URL` | No | `https://flows-api.jetty.io` | API base URL |
|
|
26
25
|
|
|
27
26
|
## Configuration
|
|
28
27
|
|
|
@@ -92,6 +91,65 @@ JETTY_API_TOKEN=mlc_your_token npx -y jetty-mcp-server
|
|
|
92
91
|
| `add-label` | Label a trajectory (e.g., quality=high) |
|
|
93
92
|
| `list-step-templates` | List available step templates |
|
|
94
93
|
| `get-step-template` | Get template details and schema |
|
|
94
|
+
| `check-secrets` | Compare a collection's env vars with what a runbook needs |
|
|
95
|
+
| `set-environment-vars` | Set env vars on a collection |
|
|
96
|
+
| `get-trial-status` / `activate-trial` | Trial keys for a collection |
|
|
97
|
+
| `list-routines` / `get-routine` / `create-routine` / `update-routine` / `delete-routine` / `pause-routine` / `resume-routine` / `run-routine-now` / `list-routine-runs` | Scheduled runs (the API calls a schedule a *routine*) |
|
|
98
|
+
|
|
99
|
+
## Use as a library
|
|
100
|
+
|
|
101
|
+
Version 1.1.0 splits the package into importable pieces (all ESM):
|
|
102
|
+
|
|
103
|
+
| Import | Runs in | What it gives you |
|
|
104
|
+
|--------|---------|-------------------|
|
|
105
|
+
| `jetty-mcp-server` | Node | `JettyClient` (token from env / `~/.config/jetty/token`), `registerTools`, the catalog, and the WebMCP helpers |
|
|
106
|
+
| `jetty-mcp-server/api-client` | Browser + Node | `JettyApiClient` — the API client with the token, origin and URL builder passed in |
|
|
107
|
+
| `jetty-mcp-server/tool-definitions` | Browser + Node | `JETTY_TOOLS` — every tool as data: name, description, zod input shape, annotations, handler |
|
|
108
|
+
| `jetty-mcp-server/tools` | Node | `registerTools(server, client)` for an `McpServer` |
|
|
109
|
+
| `jetty-mcp-server/webmcp` | Browser + Node | The catalog as WebMCP tools (see below) |
|
|
110
|
+
|
|
111
|
+
`npx jetty-mcp-server` still starts the stdio server; nothing changes for editor setups.
|
|
112
|
+
|
|
113
|
+
## WebMCP: the same tools in the browser
|
|
114
|
+
|
|
115
|
+
[WebMCP](https://webmachinelearning.github.io/webmcp/) lets a web page hand tools to an
|
|
116
|
+
in-browser agent through `navigator.modelContext`. A site that already knows who the
|
|
117
|
+
visitor is can register the whole Jetty catalog, executed with the visitor's own session:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { JettyApiClient } from "jetty-mcp-server/api-client";
|
|
121
|
+
import { findModelContext, registerJettyWebMcpTools } from "jetty-mcp-server/webmcp";
|
|
122
|
+
|
|
123
|
+
const modelContext = findModelContext(); // document.modelContext, then navigator.modelContext
|
|
124
|
+
if (modelContext) {
|
|
125
|
+
const client = new JettyApiClient({
|
|
126
|
+
token: () => session.getToken(), // called on every request
|
|
127
|
+
buildUrl: (path) => `/api/mise${path.slice("/api/v1".length)}`, // a same-origin proxy
|
|
128
|
+
});
|
|
129
|
+
const controller = new AbortController();
|
|
130
|
+
registerJettyWebMcpTools(modelContext, client, {
|
|
131
|
+
signal: controller.signal, // abort to unregister
|
|
132
|
+
readOnly: false, // or true for list/get tools only
|
|
133
|
+
include: ["list-tasks", "run-workflow"], // optional allow-list
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Two tools stay MCP-only and are never exposed over WebMCP, even when `include` names
|
|
139
|
+
them: `get-trial-status` and `activate-trial` (trial keys are an account-level concern
|
|
140
|
+
for the local agent that set the workspace up, not something a page hands to a browser
|
|
141
|
+
agent). `JETTY_WEBMCP_TOOLS` is the eligible subset.
|
|
142
|
+
|
|
143
|
+
Each WebMCP tool carries the MCP tool's name, description, a JSON-Schema `inputSchema`
|
|
144
|
+
derived from the zod shape, MCP-style `annotations` (`readOnlyHint`, `destructiveHint`),
|
|
145
|
+
and an `execute` that validates input, calls the API, and returns the same
|
|
146
|
+
`{ content: [{ type: "text", text }] }` envelope the MCP server returns (with
|
|
147
|
+
`isError: true` on failure instead of throwing). Both API shapes are supported:
|
|
148
|
+
`registerTool(tool, { signal })` and the earlier `provideContext({ tools })`.
|
|
149
|
+
|
|
150
|
+
`flows-api.jetty.io` sends no CORS headers, so a page must call it through a proxy on its
|
|
151
|
+
own origin (hence `buildUrl`) or a backend that adds the bearer token. jetty.io does this
|
|
152
|
+
for signed-in users on its app pages.
|
|
95
153
|
|
|
96
154
|
## Development
|
|
97
155
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jetty API client core. Browser-safe: no Node built-ins, no environment
|
|
3
|
+
* reads. Credentials and the API origin come in through the constructor, so
|
|
4
|
+
* the same class serves the stdio MCP server (see client.ts, which resolves
|
|
5
|
+
* the token from JETTY_API_TOKEN / ~/.config/jetty/token) and WebMCP in a
|
|
6
|
+
* page (see webmcp.ts, where a site passes a session token getter and a
|
|
7
|
+
* same-origin proxy).
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_API_URL = "https://flows-api.jetty.io";
|
|
10
|
+
/** A bearer token, or a function that yields one per request. */
|
|
11
|
+
export type TokenSource = string | (() => string | undefined | Promise<string | undefined>);
|
|
12
|
+
export interface JettyApiClientOptions {
|
|
13
|
+
/** Bearer token, or a getter called on every request (e.g. a fresh session JWT). */
|
|
14
|
+
token?: TokenSource;
|
|
15
|
+
/** API origin. Defaults to https://flows-api.jetty.io. */
|
|
16
|
+
apiUrl?: string;
|
|
17
|
+
/** fetch implementation. Defaults to globalThis.fetch, resolved per request. */
|
|
18
|
+
fetch?: typeof fetch;
|
|
19
|
+
/**
|
|
20
|
+
* Maps an API path (always `/api/v1/...`) to the URL to request. Defaults
|
|
21
|
+
* to `${apiUrl}${path}`. Override it behind a same-origin proxy, e.g.
|
|
22
|
+
* jetty.io rewrites `/api/mise/:path*` to `${mise}/api/v1/:path*`.
|
|
23
|
+
*/
|
|
24
|
+
buildUrl?: (path: string, apiUrl: string) => string;
|
|
25
|
+
/** Error message thrown when no token is available. */
|
|
26
|
+
missingTokenMessage?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class JettyApiClient {
|
|
29
|
+
protected readonly apiUrl: string;
|
|
30
|
+
private readonly tokenSource;
|
|
31
|
+
private readonly fetchImpl;
|
|
32
|
+
private readonly buildUrlImpl;
|
|
33
|
+
private readonly missingTokenMessage;
|
|
34
|
+
constructor(options?: JettyApiClientOptions);
|
|
35
|
+
protected requireToken(): Promise<string>;
|
|
36
|
+
private request;
|
|
37
|
+
private api;
|
|
38
|
+
listCollections(): Promise<unknown>;
|
|
39
|
+
getCollection(collection: string): Promise<unknown>;
|
|
40
|
+
listTasks(collection: string): Promise<unknown>;
|
|
41
|
+
getTask(collection: string, task: string): Promise<unknown>;
|
|
42
|
+
createTask(collection: string, name: string, workflow: unknown, description?: string): Promise<unknown>;
|
|
43
|
+
updateTask(collection: string, task: string, updates: {
|
|
44
|
+
workflow?: unknown;
|
|
45
|
+
description?: string;
|
|
46
|
+
}): Promise<unknown>;
|
|
47
|
+
deleteTask(collection: string, task: string): Promise<unknown>;
|
|
48
|
+
getTrialStatus(collection: string): Promise<unknown>;
|
|
49
|
+
activateTrial(collection: string): Promise<unknown>;
|
|
50
|
+
getCollectionEnvironment(collection: string): Promise<unknown>;
|
|
51
|
+
runWorkflow(collection: string, task: string, initParams?: Record<string, unknown>): Promise<unknown>;
|
|
52
|
+
runWorkflowSync(collection: string, task: string, initParams?: Record<string, unknown>): Promise<unknown>;
|
|
53
|
+
listTrajectories(collection: string, task: string, limit?: number, page?: number): Promise<unknown>;
|
|
54
|
+
getTrajectory(collection: string, task: string, trajectoryId: string): Promise<unknown>;
|
|
55
|
+
getStats(collection: string, task: string): Promise<unknown>;
|
|
56
|
+
addLabel(collection: string, task: string, trajectoryId: string, key: string, value: string, author: string): Promise<unknown>;
|
|
57
|
+
getWorkflowLogs(workflowId: string): Promise<unknown>;
|
|
58
|
+
listStepTemplates(): Promise<unknown>;
|
|
59
|
+
getStepTemplate(name: string): Promise<unknown>;
|
|
60
|
+
setEnvironmentVars(collection: string, vars: Record<string, string>): Promise<unknown>;
|
|
61
|
+
listRoutines(collection: string, task?: string): Promise<unknown>;
|
|
62
|
+
getRoutine(collection: string, task: string, name: string): Promise<unknown>;
|
|
63
|
+
createRoutine(collection: string, task: string, body: Record<string, unknown>): Promise<unknown>;
|
|
64
|
+
updateRoutine(collection: string, task: string, name: string, patch: Record<string, unknown>): Promise<unknown>;
|
|
65
|
+
deleteRoutine(collection: string, task: string, name: string): Promise<unknown>;
|
|
66
|
+
pauseRoutine(collection: string, task: string, name: string): Promise<unknown>;
|
|
67
|
+
resumeRoutine(collection: string, task: string, name: string): Promise<unknown>;
|
|
68
|
+
runRoutineNow(collection: string, task: string, name: string): Promise<unknown>;
|
|
69
|
+
listRoutineRuns(collection: string, task: string, name: string, limit?: number): Promise<unknown>;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,eAAe,+BAA+B,CAAC;AAE5D,iEAAiE;AACjE,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,CAAC,MAAM,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAE7D,MAAM,WAAW,qBAAqB;IACpC,oFAAoF;IACpF,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACpD,uDAAuD;IACvD,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAQD,qBAAa,cAAc;IACzB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0B;IACtD,O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,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM;CAOjB"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jetty API client core. Browser-safe: no Node built-ins, no environment
|
|
3
|
+
* reads. Credentials and the API origin come in through the constructor, so
|
|
4
|
+
* the same class serves the stdio MCP server (see client.ts, which resolves
|
|
5
|
+
* the token from JETTY_API_TOKEN / ~/.config/jetty/token) and WebMCP in a
|
|
6
|
+
* page (see webmcp.ts, where a site passes a session token getter and a
|
|
7
|
+
* same-origin proxy).
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_API_URL = "https://flows-api.jetty.io";
|
|
10
|
+
/** A dynamic path segment, so reserved characters cannot alter the route. */
|
|
11
|
+
const seg = (value) => encodeURIComponent(String(value));
|
|
12
|
+
const DEFAULT_MISSING_TOKEN = "No Jetty token available. Pass `token` (a string or a getter) to the client.";
|
|
13
|
+
export class JettyApiClient {
|
|
14
|
+
apiUrl;
|
|
15
|
+
tokenSource;
|
|
16
|
+
fetchImpl;
|
|
17
|
+
buildUrlImpl;
|
|
18
|
+
missingTokenMessage;
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this.tokenSource = options.token;
|
|
21
|
+
this.apiUrl = (options.apiUrl || DEFAULT_API_URL).replace(/\/+$/, "");
|
|
22
|
+
this.fetchImpl = options.fetch;
|
|
23
|
+
this.buildUrlImpl = options.buildUrl ?? ((path, apiUrl) => `${apiUrl}${path}`);
|
|
24
|
+
this.missingTokenMessage = options.missingTokenMessage ?? DEFAULT_MISSING_TOKEN;
|
|
25
|
+
}
|
|
26
|
+
async requireToken() {
|
|
27
|
+
const source = this.tokenSource;
|
|
28
|
+
const token = typeof source === "function" ? await source() : source;
|
|
29
|
+
if (!token)
|
|
30
|
+
throw new Error(this.missingTokenMessage);
|
|
31
|
+
return token;
|
|
32
|
+
}
|
|
33
|
+
async request(path, options = {}) {
|
|
34
|
+
const url = this.buildUrlImpl(path, this.apiUrl);
|
|
35
|
+
const headers = {
|
|
36
|
+
Authorization: `Bearer ${await this.requireToken()}`,
|
|
37
|
+
...(options.headers || {}),
|
|
38
|
+
};
|
|
39
|
+
// Resolved per request so a test (or a page) may swap globalThis.fetch
|
|
40
|
+
// after construction.
|
|
41
|
+
const fetchImpl = this.fetchImpl ?? globalThis.fetch;
|
|
42
|
+
const res = await fetchImpl(url, { ...options, headers });
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
const body = await res.text();
|
|
45
|
+
throw new Error(`Jetty API error ${res.status}: ${body}`);
|
|
46
|
+
}
|
|
47
|
+
const contentType = res.headers.get("content-type") || "";
|
|
48
|
+
if (contentType.includes("application/json")) {
|
|
49
|
+
return res.json();
|
|
50
|
+
}
|
|
51
|
+
return res.text();
|
|
52
|
+
}
|
|
53
|
+
api(path, options) {
|
|
54
|
+
return this.request(path, options);
|
|
55
|
+
}
|
|
56
|
+
// Collections
|
|
57
|
+
async listCollections() {
|
|
58
|
+
return this.api("/api/v1/collections/");
|
|
59
|
+
}
|
|
60
|
+
async getCollection(collection) {
|
|
61
|
+
return this.api(`/api/v1/collections/${seg(collection)}`);
|
|
62
|
+
}
|
|
63
|
+
// Tasks
|
|
64
|
+
async listTasks(collection) {
|
|
65
|
+
return this.api(`/api/v1/tasks/${seg(collection)}/`);
|
|
66
|
+
}
|
|
67
|
+
async getTask(collection, task) {
|
|
68
|
+
return this.api(`/api/v1/tasks/${seg(collection)}/${seg(task)}`);
|
|
69
|
+
}
|
|
70
|
+
async createTask(collection, name, workflow, description) {
|
|
71
|
+
return this.api(`/api/v1/tasks/${seg(collection)}`, {
|
|
72
|
+
method: "POST",
|
|
73
|
+
headers: { "Content-Type": "application/json" },
|
|
74
|
+
body: JSON.stringify({ name, description: description || "", workflow }),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async updateTask(collection, task, updates) {
|
|
78
|
+
return this.api(`/api/v1/tasks/${seg(collection)}/${seg(task)}`, {
|
|
79
|
+
method: "PUT",
|
|
80
|
+
headers: { "Content-Type": "application/json" },
|
|
81
|
+
body: JSON.stringify(updates),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async deleteTask(collection, task) {
|
|
85
|
+
return this.api(`/api/v1/tasks/${seg(collection)}/${seg(task)}`, {
|
|
86
|
+
method: "DELETE",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
// Trial keys
|
|
90
|
+
async getTrialStatus(collection) {
|
|
91
|
+
return this.api(`/api/v1/trial/${seg(collection)}`);
|
|
92
|
+
}
|
|
93
|
+
async activateTrial(collection) {
|
|
94
|
+
return this.api(`/api/v1/trial/${seg(collection)}/activate`, {
|
|
95
|
+
method: "POST",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
// Collection environment
|
|
99
|
+
async getCollectionEnvironment(collection) {
|
|
100
|
+
return this.api(`/api/v1/collections/${seg(collection)}/environment`);
|
|
101
|
+
}
|
|
102
|
+
// Run workflows. Trial keys are injected automatically server-side when
|
|
103
|
+
// the collection is eligible — there is no flag to send.
|
|
104
|
+
async runWorkflow(collection, task, initParams) {
|
|
105
|
+
const formData = new FormData();
|
|
106
|
+
formData.append("init_params", JSON.stringify(initParams || {}));
|
|
107
|
+
return this.api(`/api/v1/run/${seg(collection)}/${seg(task)}`, {
|
|
108
|
+
method: "POST",
|
|
109
|
+
body: formData,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async runWorkflowSync(collection, task, initParams) {
|
|
113
|
+
const formData = new FormData();
|
|
114
|
+
formData.append("init_params", JSON.stringify(initParams || {}));
|
|
115
|
+
return this.api(`/api/v1/run-sync/${seg(collection)}/${seg(task)}`, {
|
|
116
|
+
method: "POST",
|
|
117
|
+
body: formData,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// Trajectories
|
|
121
|
+
async listTrajectories(collection, task, limit = 10, page = 1) {
|
|
122
|
+
return this.api(`/api/v1/db/trajectories/${seg(collection)}/${seg(task)}?limit=${seg(limit)}&page=${seg(page)}`);
|
|
123
|
+
}
|
|
124
|
+
async getTrajectory(collection, task, trajectoryId) {
|
|
125
|
+
return this.api(`/api/v1/db/trajectory/${seg(collection)}/${seg(task)}/${seg(trajectoryId)}`);
|
|
126
|
+
}
|
|
127
|
+
// Stats
|
|
128
|
+
async getStats(collection, task) {
|
|
129
|
+
return this.api(`/api/v1/db/stats/${seg(collection)}/${seg(task)}`);
|
|
130
|
+
}
|
|
131
|
+
// Labels
|
|
132
|
+
async addLabel(collection, task, trajectoryId, key, value, author) {
|
|
133
|
+
return this.api(`/api/v1/trajectory/${seg(collection)}/${seg(task)}/${seg(trajectoryId)}/labels`, {
|
|
134
|
+
method: "POST",
|
|
135
|
+
headers: { "Content-Type": "application/json" },
|
|
136
|
+
body: JSON.stringify({ key, value, author }),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
// Workflow logs
|
|
140
|
+
async getWorkflowLogs(workflowId) {
|
|
141
|
+
return this.api(`/api/v1/workflows-logs/${seg(workflowId)}`);
|
|
142
|
+
}
|
|
143
|
+
// Step templates
|
|
144
|
+
async listStepTemplates() {
|
|
145
|
+
return this.request("/api/v1/step-templates");
|
|
146
|
+
}
|
|
147
|
+
async getStepTemplate(name) {
|
|
148
|
+
return this.request(`/api/v1/step-templates/${seg(name)}`);
|
|
149
|
+
}
|
|
150
|
+
// Environment variables
|
|
151
|
+
async setEnvironmentVars(collection, vars) {
|
|
152
|
+
return this.api(`/api/v1/collections/${seg(collection)}/environment`, {
|
|
153
|
+
method: "PATCH",
|
|
154
|
+
headers: { "Content-Type": "application/json" },
|
|
155
|
+
body: JSON.stringify({ environment_variables: vars }),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
// Routines (scheduled runs)
|
|
159
|
+
async listRoutines(collection, task) {
|
|
160
|
+
const path = task
|
|
161
|
+
? `/api/v1/routines/${seg(collection)}/${seg(task)}`
|
|
162
|
+
: `/api/v1/routines/${seg(collection)}`;
|
|
163
|
+
return this.api(path);
|
|
164
|
+
}
|
|
165
|
+
async getRoutine(collection, task, name) {
|
|
166
|
+
return this.api(`/api/v1/routines/${seg(collection)}/${seg(task)}/${seg(name)}`);
|
|
167
|
+
}
|
|
168
|
+
async createRoutine(collection, task, body) {
|
|
169
|
+
return this.api(`/api/v1/routines/${seg(collection)}/${seg(task)}`, {
|
|
170
|
+
method: "POST",
|
|
171
|
+
headers: { "Content-Type": "application/json" },
|
|
172
|
+
body: JSON.stringify(body),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
async updateRoutine(collection, task, name, patch) {
|
|
176
|
+
return this.api(`/api/v1/routines/${seg(collection)}/${seg(task)}/${seg(name)}`, {
|
|
177
|
+
method: "PATCH",
|
|
178
|
+
headers: { "Content-Type": "application/json" },
|
|
179
|
+
body: JSON.stringify(patch),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async deleteRoutine(collection, task, name) {
|
|
183
|
+
return this.api(`/api/v1/routines/${seg(collection)}/${seg(task)}/${seg(name)}`, {
|
|
184
|
+
method: "DELETE",
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
async pauseRoutine(collection, task, name) {
|
|
188
|
+
return this.api(`/api/v1/routines/${seg(collection)}/${seg(task)}/${seg(name)}/pause`, { method: "POST" });
|
|
189
|
+
}
|
|
190
|
+
async resumeRoutine(collection, task, name) {
|
|
191
|
+
return this.api(`/api/v1/routines/${seg(collection)}/${seg(task)}/${seg(name)}/resume`, { method: "POST" });
|
|
192
|
+
}
|
|
193
|
+
async runRoutineNow(collection, task, name) {
|
|
194
|
+
return this.api(`/api/v1/routines/${seg(collection)}/${seg(task)}/${seg(name)}/run-now`, { method: "POST" });
|
|
195
|
+
}
|
|
196
|
+
async listRoutineRuns(collection, task, name, limit) {
|
|
197
|
+
const qs = typeof limit === "number" ? `?limit=${seg(limit)}` : "";
|
|
198
|
+
return this.api(`/api/v1/routines/${seg(collection)}/${seg(task)}/${seg(name)}/runs${qs}`);
|
|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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
createTask(collection: string, name: string, workflow: unknown, description?: string): Promise<unknown>;
|
|
14
|
-
updateTask(collection: string, task: string, updates: {
|
|
15
|
-
workflow?: unknown;
|
|
16
|
-
description?: string;
|
|
17
|
-
}): Promise<unknown>;
|
|
18
|
-
deleteTask(collection: string, task: string): Promise<unknown>;
|
|
19
|
-
runWorkflow(collection: string, task: string, initParams?: Record<string, unknown>): Promise<unknown>;
|
|
20
|
-
runWorkflowSync(collection: string, task: string, initParams?: Record<string, unknown>): Promise<unknown>;
|
|
21
|
-
listTrajectories(collection: string, task: string, limit?: number, page?: number): Promise<unknown>;
|
|
22
|
-
getTrajectory(collection: string, task: string, trajectoryId: string): Promise<unknown>;
|
|
23
|
-
getStats(collection: string, task: string): Promise<unknown>;
|
|
24
|
-
addLabel(collection: string, task: string, trajectoryId: string, key: string, value: string, author: string): Promise<unknown>;
|
|
25
|
-
getWorkflowLogs(workflowId: string): Promise<unknown>;
|
|
26
|
-
listStepTemplates(): Promise<unknown>;
|
|
27
|
-
getStepTemplate(name: string): Promise<unknown>;
|
|
28
|
-
setEnvironmentVars(collection: string, vars: Record<string, string>): Promise<unknown>;
|
|
1
|
+
import { JettyApiClient, type JettyApiClientOptions } from "./api-client.js";
|
|
2
|
+
export { DEFAULT_API_URL, JettyApiClient } from "./api-client.js";
|
|
3
|
+
export type { JettyApiClientOptions, TokenSource } from "./api-client.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the API token: prefer JETTY_API_TOKEN (trimmed, non-empty), then the
|
|
6
|
+
* token file written by `jetty login`. The env var is checked for emptiness
|
|
7
|
+
* because the plugin's .mcp.json may pass it through as "" — which must not
|
|
8
|
+
* count as "set" and must not block the file fallback.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveToken(): string | undefined;
|
|
11
|
+
export declare class JettyClient extends JettyApiClient {
|
|
12
|
+
constructor(options?: JettyApiClientOptions);
|
|
29
13
|
}
|
|
30
14
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,cAAc,EACd,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAU1E;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAYjD;AAED,qBAAa,WAAY,SAAQ,cAAc;gBACjC,OAAO,GAAE,qBAA0B;CAYhD"}
|
package/dist/client.js
CHANGED
|
@@ -1,130 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
async listTasks(collection) {
|
|
49
|
-
return this.dock(`/api/v1/tasks/${collection}/`);
|
|
50
|
-
}
|
|
51
|
-
async getTask(collection, task) {
|
|
52
|
-
return this.dock(`/api/v1/tasks/${collection}/${task}`);
|
|
53
|
-
}
|
|
54
|
-
async createTask(collection, name, workflow, description) {
|
|
55
|
-
return this.dock(`/api/v1/tasks/${collection}`, {
|
|
56
|
-
method: "POST",
|
|
57
|
-
headers: { "Content-Type": "application/json" },
|
|
58
|
-
body: JSON.stringify({ name, description: description || "", workflow }),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
async updateTask(collection, task, updates) {
|
|
62
|
-
return this.dock(`/api/v1/tasks/${collection}/${task}`, {
|
|
63
|
-
method: "PUT",
|
|
64
|
-
headers: { "Content-Type": "application/json" },
|
|
65
|
-
body: JSON.stringify(updates),
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
async deleteTask(collection, task) {
|
|
69
|
-
return this.dock(`/api/v1/tasks/${collection}/${task}`, {
|
|
70
|
-
method: "DELETE",
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
// Run workflows
|
|
74
|
-
async runWorkflow(collection, task, initParams) {
|
|
75
|
-
const formData = new FormData();
|
|
76
|
-
formData.append("bakery_host", this.dockUrl);
|
|
77
|
-
formData.append("init_params", JSON.stringify(initParams || {}));
|
|
78
|
-
return this.flows(`/api/v1/run/${collection}/${task}`, {
|
|
79
|
-
method: "POST",
|
|
80
|
-
body: formData,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
async runWorkflowSync(collection, task, initParams) {
|
|
84
|
-
const formData = new FormData();
|
|
85
|
-
formData.append("bakery_host", this.dockUrl);
|
|
86
|
-
formData.append("init_params", JSON.stringify(initParams || {}));
|
|
87
|
-
return this.flows(`/api/v1/run-sync/${collection}/${task}`, {
|
|
88
|
-
method: "POST",
|
|
89
|
-
body: formData,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
// Trajectories
|
|
93
|
-
async listTrajectories(collection, task, limit = 10, page = 1) {
|
|
94
|
-
return this.flows(`/api/v1/db/trajectories/${collection}/${task}?limit=${limit}&page=${page}`);
|
|
95
|
-
}
|
|
96
|
-
async getTrajectory(collection, task, trajectoryId) {
|
|
97
|
-
return this.flows(`/api/v1/db/trajectory/${collection}/${task}/${trajectoryId}`);
|
|
98
|
-
}
|
|
99
|
-
// Stats
|
|
100
|
-
async getStats(collection, task) {
|
|
101
|
-
return this.flows(`/api/v1/db/stats/${collection}/${task}`);
|
|
102
|
-
}
|
|
103
|
-
// Labels
|
|
104
|
-
async addLabel(collection, task, trajectoryId, key, value, author) {
|
|
105
|
-
return this.flows(`/api/v1/trajectory/${collection}/${task}/${trajectoryId}/labels`, {
|
|
106
|
-
method: "POST",
|
|
107
|
-
headers: { "Content-Type": "application/json" },
|
|
108
|
-
body: JSON.stringify({ key, value, author }),
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
// Workflow logs
|
|
112
|
-
async getWorkflowLogs(workflowId) {
|
|
113
|
-
return this.flows(`/api/v1/workflows-logs/${workflowId}`);
|
|
114
|
-
}
|
|
115
|
-
// Step templates
|
|
116
|
-
async listStepTemplates() {
|
|
117
|
-
return this.request(this.flowsUrl, "/api/v1/step-templates");
|
|
118
|
-
}
|
|
119
|
-
async getStepTemplate(name) {
|
|
120
|
-
return this.request(this.flowsUrl, `/api/v1/step-templates/${name}`);
|
|
121
|
-
}
|
|
122
|
-
// Environment variables
|
|
123
|
-
async setEnvironmentVars(collection, vars) {
|
|
124
|
-
return this.dock(`/api/v1/collections/${collection}/environment`, {
|
|
125
|
-
method: "PATCH",
|
|
126
|
-
headers: { "Content-Type": "application/json" },
|
|
127
|
-
body: JSON.stringify({ environment_variables: vars }),
|
|
1
|
+
/**
|
|
2
|
+
* Node client for the stdio MCP server: the browser-safe core (api-client.ts)
|
|
3
|
+
* plus token resolution from the environment and the file `jetty login`
|
|
4
|
+
* writes. Not for the browser — it imports node:fs.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { DEFAULT_API_URL, JettyApiClient, } from "./api-client.js";
|
|
10
|
+
export { DEFAULT_API_URL, JettyApiClient } from "./api-client.js";
|
|
11
|
+
// The `jetty` CLI / Claude Code skill writes the collection-scoped `mlc_` key
|
|
12
|
+
// here on `jetty login`. We fall back to it so an already-logged-in user does
|
|
13
|
+
// not also have to plumb JETTY_API_TOKEN into the MCP server's env. Resolved
|
|
14
|
+
// lazily (not memoized at module load) so HOME changes are honoured.
|
|
15
|
+
function tokenFilePath() {
|
|
16
|
+
return join(homedir(), ".config", "jetty", "token");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the API token: prefer JETTY_API_TOKEN (trimmed, non-empty), then the
|
|
20
|
+
* token file written by `jetty login`. The env var is checked for emptiness
|
|
21
|
+
* because the plugin's .mcp.json may pass it through as "" — which must not
|
|
22
|
+
* count as "set" and must not block the file fallback.
|
|
23
|
+
*/
|
|
24
|
+
export function resolveToken() {
|
|
25
|
+
const fromEnv = process.env.JETTY_API_TOKEN?.trim();
|
|
26
|
+
if (fromEnv)
|
|
27
|
+
return fromEnv;
|
|
28
|
+
try {
|
|
29
|
+
const fromFile = readFileSync(tokenFilePath(), "utf8").trim();
|
|
30
|
+
if (fromFile)
|
|
31
|
+
return fromFile;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// file absent / unreadable — fall through to undefined
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
export class JettyClient extends JettyApiClient {
|
|
39
|
+
constructor(options = {}) {
|
|
40
|
+
super({
|
|
41
|
+
...options,
|
|
42
|
+
token: options.token ?? resolveToken(),
|
|
43
|
+
apiUrl: options.apiUrl ?? (process.env.JETTY_API_URL || DEFAULT_API_URL),
|
|
44
|
+
missingTokenMessage: options.missingTokenMessage ??
|
|
45
|
+
"No Jetty token found. Set JETTY_API_TOKEN, or run `jetty login` " +
|
|
46
|
+
`(writes ${tokenFilePath()}). ` +
|
|
47
|
+
"Get a token at https://jetty.io → Settings → API Tokens",
|
|
128
48
|
});
|
|
129
49
|
}
|
|
130
50
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,eAAe,EACf,cAAc,GAEf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGlE,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,qEAAqE;AACrE,SAAS,aAAa;IACpB,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC;IACpD,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAE5B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,YAAY,CAAC,aAAa,EAAE,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9D,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,uDAAuD;IACzD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,OAAO,WAAY,SAAQ,cAAc;IAC7C,YAAY,U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