@mostra/mcp 0.10.0 → 0.12.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/index.d.ts +184 -99
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +464 -202
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/schemas/mcp-tools.draft-07.json +2 -2
- package/schemas/mcp-tools.schema.json +2 -2
- package/src/docs.ts +259 -0
- package/src/http.ts +71 -0
- package/src/index.ts +15 -0
- package/src/tools.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mostra/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Mostra's MCP server: the tools, resources and HTTP handler `mostra mcp` serves to any MCP client, independent of the transport.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "The Mostra Authors",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@modelcontextprotocol/server": "2.4.0",
|
|
40
|
-
"@mostra/protocol": "0.
|
|
40
|
+
"@mostra/protocol": "0.12.0",
|
|
41
41
|
"diff": "9.0.0",
|
|
42
42
|
"zod": "4.6.7"
|
|
43
43
|
},
|
|
@@ -225,8 +225,8 @@
|
|
|
225
225
|
},
|
|
226
226
|
"until": {
|
|
227
227
|
"type": "string",
|
|
228
|
-
"pattern": "^(submitted|signal:[A-Za-z0-9][A-Za-z0-9._-]{0,63}|state:[^\\u0000-\\u001f\\u007f]{1,256}|event:[a-z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*(\\.\\*)?)$",
|
|
229
|
-
"description": "submitted, signal:<name>, state:<fieldId> or event:<type> (event:submission.* matches a family)."
|
|
228
|
+
"pattern": "^(?:(submitted|signal:[A-Za-z0-9][A-Za-z0-9._-]{0,63}|state:[^\\u0000-\\u001f\\u007f]{1,256}|event:[a-z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*(\\.\\*)?)$|submitted:(?:all|[1-9][0-9]{0,3}|10000)$)",
|
|
229
|
+
"description": "submitted, submitted:all (every expected respondent), submitted:<N>, signal:<name>, state:<fieldId> or event:<type> (event:submission.* matches a family)."
|
|
230
230
|
},
|
|
231
231
|
"after": {
|
|
232
232
|
"description": "Wait for what happens after this cursor: the one a previous wait returned.",
|
|
@@ -225,8 +225,8 @@
|
|
|
225
225
|
},
|
|
226
226
|
"until": {
|
|
227
227
|
"type": "string",
|
|
228
|
-
"pattern": "^(submitted|signal:[A-Za-z0-9][A-Za-z0-9._-]{0,63}|state:[^\\u0000-\\u001f\\u007f]{1,256}|event:[a-z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*(\\.\\*)?)$",
|
|
229
|
-
"description": "submitted, signal:<name>, state:<fieldId> or event:<type> (event:submission.* matches a family)."
|
|
228
|
+
"pattern": "^(?:(submitted|signal:[A-Za-z0-9][A-Za-z0-9._-]{0,63}|state:[^\\u0000-\\u001f\\u007f]{1,256}|event:[a-z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*(\\.\\*)?)$|submitted:(?:all|[1-9][0-9]{0,3}|10000)$)",
|
|
229
|
+
"description": "submitted, submitted:all (every expected respondent), submitted:<N>, signal:<name>, state:<fieldId> or event:<type> (event:submission.* matches a family)."
|
|
230
230
|
},
|
|
231
231
|
"after": {
|
|
232
232
|
"description": "Wait for what happens after this cursor: the one a previous wait returned.",
|
package/src/docs.ts
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bundled reference (D140 item 17, D162): the CLI reference, the telemetry and self-hosting pages, every
|
|
3
|
+
* diagnostic code and the Agent Skill as `guide` topics, read from the directories a package ships.
|
|
4
|
+
* `mostra docs` and both MCP servers read it.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
7
|
+
import { extname, join } from "node:path";
|
|
8
|
+
import { DEFAULT_DOCS_BASE } from "@mostra/protocol";
|
|
9
|
+
import type { DocsTopicSummary, McpDocs } from "./ports.ts";
|
|
10
|
+
|
|
11
|
+
/** One topic of the reference. */
|
|
12
|
+
export interface DocsTopic {
|
|
13
|
+
/** Its stable slug: `cli`, `telemetry`, a diagnostic code, `guide` or `guide/<name>`. */
|
|
14
|
+
readonly topic: string;
|
|
15
|
+
/** Its title, from the page's first heading. */
|
|
16
|
+
readonly title: string;
|
|
17
|
+
/** Where the docs site serves it. */
|
|
18
|
+
readonly url: string;
|
|
19
|
+
/** Its Markdown file, or a guide topic's first file. */
|
|
20
|
+
readonly file: string;
|
|
21
|
+
/**
|
|
22
|
+
* A guide topic that isn't one Markdown page (a stylesheet, an example): its files, relative to
|
|
23
|
+
* the Skill's `assets/`, each shown as code.
|
|
24
|
+
*/
|
|
25
|
+
readonly files?: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function titleOf(file: string): string {
|
|
29
|
+
const first = readFileSync(file, "utf8")
|
|
30
|
+
.split("\n")
|
|
31
|
+
.find((line) => line.startsWith("# "));
|
|
32
|
+
return first ? first.slice(2).trim() : "";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Every topic, the pages first and then the codes, sorted. */
|
|
36
|
+
/**
|
|
37
|
+
* Every topic of the reference in `referenceDir` and the Agent Skill in `skillDir`: the pages first,
|
|
38
|
+
* then the guide, then the codes, sorted.
|
|
39
|
+
*/
|
|
40
|
+
export function docsIndex(referenceDir: string, skillDir: string): DocsTopic[] {
|
|
41
|
+
const dir = referenceDir;
|
|
42
|
+
const base = DEFAULT_DOCS_BASE.replace(/\/+$/, "");
|
|
43
|
+
const pages: DocsTopic[] = [];
|
|
44
|
+
for (const topic of ["cli", "telemetry", "self-hosting"]) {
|
|
45
|
+
const file = join(dir, `${topic}.md`);
|
|
46
|
+
if (existsSync(file))
|
|
47
|
+
pages.push({ topic, title: titleOf(file), url: `${base}/${topic}`, file });
|
|
48
|
+
}
|
|
49
|
+
const errorsDir = join(dir, "errors");
|
|
50
|
+
const codes = existsSync(errorsDir)
|
|
51
|
+
? readdirSync(errorsDir)
|
|
52
|
+
.filter((name) => /^MOSTRA_[A-Z0-9_]+\.md$/.test(name))
|
|
53
|
+
.sort()
|
|
54
|
+
: [];
|
|
55
|
+
const errors: DocsTopic[] = codes.map((name) => {
|
|
56
|
+
const code = name.slice(0, -3);
|
|
57
|
+
const file = join(errorsDir, name);
|
|
58
|
+
return { topic: code, title: titleOf(file), url: `${base}/errors/${code}`, file };
|
|
59
|
+
});
|
|
60
|
+
return [...pages, ...guideTopics(skillDir, base), ...errors];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const byName = (a: { name: string }, b: { name: string }): number => (a.name < b.name ? -1 : 1);
|
|
64
|
+
|
|
65
|
+
/** Every file below `root`'s `prefix`, relative to `root`, sorted. */
|
|
66
|
+
function filesBelow(root: string, prefix: string): string[] {
|
|
67
|
+
return readdirSync(join(root, prefix), { withFileTypes: true })
|
|
68
|
+
.sort(byName)
|
|
69
|
+
.flatMap((entry) => {
|
|
70
|
+
const path = `${prefix}/${entry.name}`;
|
|
71
|
+
return entry.isDirectory() ? filesBelow(root, path) : [path];
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The Skill as topics: `guide` (its SKILL.md), `guide/<name>` for each reference,
|
|
77
|
+
* `guide/<file>` for each asset (the baseline stylesheet), and `guide/examples/<name>` for each
|
|
78
|
+
* example, every file of it.
|
|
79
|
+
*/
|
|
80
|
+
export function guideTopics(dir: string, base: string): DocsTopic[] {
|
|
81
|
+
const skill = join(dir, "SKILL.md");
|
|
82
|
+
if (!existsSync(skill)) return [];
|
|
83
|
+
const topics: DocsTopic[] = [
|
|
84
|
+
{ topic: "guide", title: "Using Mostra", url: `${base}/guide`, file: skill },
|
|
85
|
+
];
|
|
86
|
+
const references = join(dir, "references");
|
|
87
|
+
if (existsSync(references)) {
|
|
88
|
+
for (const name of readdirSync(references)
|
|
89
|
+
.filter((entry) => entry.endsWith(".md"))
|
|
90
|
+
.sort()) {
|
|
91
|
+
const file = join(references, name);
|
|
92
|
+
const slug = name.slice(0, -3);
|
|
93
|
+
topics.push({
|
|
94
|
+
topic: `guide/${slug}`,
|
|
95
|
+
title: titleOf(file),
|
|
96
|
+
url: `${base}/guide/${slug}`,
|
|
97
|
+
file,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const assets = join(dir, "assets");
|
|
102
|
+
if (!existsSync(assets)) return topics;
|
|
103
|
+
for (const entry of readdirSync(assets, { withFileTypes: true }).sort(byName)) {
|
|
104
|
+
if (!entry.isFile()) continue;
|
|
105
|
+
topics.push({
|
|
106
|
+
topic: `guide/${entry.name}`,
|
|
107
|
+
title: entry.name,
|
|
108
|
+
url: `${base}/guide/${entry.name}`,
|
|
109
|
+
file: join(assets, entry.name),
|
|
110
|
+
files: [entry.name],
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const examples = join(assets, "examples");
|
|
114
|
+
if (!existsSync(examples)) return topics;
|
|
115
|
+
for (const entry of readdirSync(examples, { withFileTypes: true }).sort(byName)) {
|
|
116
|
+
if (!entry.isDirectory()) continue;
|
|
117
|
+
const files = filesBelow(assets, `examples/${entry.name}`);
|
|
118
|
+
if (files.length === 0) continue;
|
|
119
|
+
topics.push({
|
|
120
|
+
topic: `guide/examples/${entry.name}`,
|
|
121
|
+
title: `Example: ${entry.name}`,
|
|
122
|
+
url: `${base}/guide/examples/${entry.name}`,
|
|
123
|
+
file: join(assets, files[0] as string),
|
|
124
|
+
files,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return topics;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const FENCE_LANGUAGES: Readonly<Record<string, string>> = {
|
|
131
|
+
".css": "css",
|
|
132
|
+
".json": "json",
|
|
133
|
+
".md": "md",
|
|
134
|
+
".mdx": "mdx",
|
|
135
|
+
".ts": "ts",
|
|
136
|
+
".tsx": "tsx",
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/** How the guide's relative links read through the CLI, before each of its pages. */
|
|
140
|
+
export const GUIDE_LINKS: string =
|
|
141
|
+
"> Read through `mostra docs`: a link to `references/<name>.md` is `mostra docs guide/<name>`, `assets/<file>` is `mostra docs guide/<file>`, and `assets/examples/<name>/` is `mostra docs guide/examples/<name>`.";
|
|
142
|
+
|
|
143
|
+
/** The same for the guide read through `mostra mcp` (D164): topics of `docs_search`, or resources. */
|
|
144
|
+
export const MCP_GUIDE_LINKS: string =
|
|
145
|
+
"> Read through Mostra's MCP server: a link to `references/<name>.md` is the topic `guide/<name>`, `assets/<file>` is `guide/<file>`, and `assets/examples/<name>/` is `guide/examples/<name>`; read one with docs_search (`topic`) or the resource `mostra://docs/<topic>`. Where the guide runs a `mostra` command, use the tool of the same step (artifact_verify for `mostra verify`, artifact_wait for `mostra wait`).";
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A topic's Markdown. A guide page loses its frontmatter and says how its links read (through the
|
|
149
|
+
* CLI by default, or `links`); a guide topic made of files shows each one as code under its path.
|
|
150
|
+
*/
|
|
151
|
+
export function topicMarkdown(topic: DocsTopic, dir: string, links: string = GUIDE_LINKS): string {
|
|
152
|
+
if (topic.files !== undefined) {
|
|
153
|
+
const parts = topic.files.map((path) => {
|
|
154
|
+
const text = readFileSync(join(dir, "assets", path), "utf8");
|
|
155
|
+
const fence = text.includes("```") ? "````" : "```";
|
|
156
|
+
const body = text.endsWith("\n") ? text : `${text}\n`;
|
|
157
|
+
return `## \`${path}\`\n\n${fence}${FENCE_LANGUAGES[extname(path)] ?? ""}\n${body}${fence}\n`;
|
|
158
|
+
});
|
|
159
|
+
return [`# ${topic.title}`, "", links, "", ...parts].join("\n");
|
|
160
|
+
}
|
|
161
|
+
const text = readFileSync(topic.file, "utf8");
|
|
162
|
+
if (topic.topic !== "guide" && !topic.topic.startsWith("guide/")) return text;
|
|
163
|
+
return [links, "", text.replace(/^---\n[\s\S]*?\n---\n+/, "")].join("\n");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The index as Markdown: what `mostra docs` prints without a topic. */
|
|
167
|
+
export function indexMarkdown(topics: readonly DocsTopic[]): string {
|
|
168
|
+
const pages = topics.filter(
|
|
169
|
+
(topic) => !topic.topic.startsWith("MOSTRA_") && !topic.topic.startsWith("guide"),
|
|
170
|
+
);
|
|
171
|
+
const guide = topics.filter(
|
|
172
|
+
(topic) => topic.topic === "guide" || topic.topic.startsWith("guide/"),
|
|
173
|
+
);
|
|
174
|
+
const codes = topics.filter((topic) => topic.topic.startsWith("MOSTRA_"));
|
|
175
|
+
return [
|
|
176
|
+
"# Mostra reference",
|
|
177
|
+
"",
|
|
178
|
+
"Run `mostra docs <topic>` to read one. Diagnostic codes are topics too.",
|
|
179
|
+
"",
|
|
180
|
+
...pages.map((topic) => `- \`${topic.topic}\`: ${topic.title}`),
|
|
181
|
+
"",
|
|
182
|
+
...(guide.length > 0
|
|
183
|
+
? [
|
|
184
|
+
"## Writing artifacts",
|
|
185
|
+
"",
|
|
186
|
+
...guide.map((topic) => `- \`${topic.topic}\`: ${topic.title}`),
|
|
187
|
+
"",
|
|
188
|
+
]
|
|
189
|
+
: []),
|
|
190
|
+
"## Diagnostic codes",
|
|
191
|
+
"",
|
|
192
|
+
...codes.map((topic) => `- \`${topic.topic}\`: ${topic.title}`),
|
|
193
|
+
"",
|
|
194
|
+
].join("\n");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** The topics nearest an unknown one, for its usage error. */
|
|
198
|
+
export function nearestTopics(wanted: string, topics: readonly DocsTopic[], count = 3): string[] {
|
|
199
|
+
const target = wanted.toUpperCase();
|
|
200
|
+
const scored = topics.map((topic) => {
|
|
201
|
+
const name = topic.topic.toUpperCase();
|
|
202
|
+
const contains = name.includes(target) || target.includes(name) ? 0 : 1;
|
|
203
|
+
return { topic: topic.topic, score: contains * 100 + distance(name, target) };
|
|
204
|
+
});
|
|
205
|
+
return scored
|
|
206
|
+
.sort((a, b) => a.score - b.score || (a.topic < b.topic ? -1 : 1))
|
|
207
|
+
.slice(0, count)
|
|
208
|
+
.map((item) => item.topic);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Levenshtein distance. */
|
|
212
|
+
function distance(a: string, b: string): number {
|
|
213
|
+
const row = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
214
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
215
|
+
let previous = row[0] as number;
|
|
216
|
+
row[0] = i;
|
|
217
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
218
|
+
const current = row[j] as number;
|
|
219
|
+
row[j] = Math.min(
|
|
220
|
+
(row[j] as number) + 1,
|
|
221
|
+
(row[j - 1] as number) + 1,
|
|
222
|
+
previous + (a[i - 1] === b[j - 1] ? 0 : 1),
|
|
223
|
+
);
|
|
224
|
+
previous = current;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return row[b.length] as number;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The bundled reference as the MCP server's docs (`docs_search`, `mostra://docs/{topic}`): the
|
|
232
|
+
* reference and the Skill in two directories, read once and cached. The CLI gives the copies it
|
|
233
|
+
* ships; the remote server the copies its build carries.
|
|
234
|
+
*/
|
|
235
|
+
export function fileDocs(options: {
|
|
236
|
+
readonly referenceDir: string;
|
|
237
|
+
readonly skillDir: string;
|
|
238
|
+
readonly links?: string;
|
|
239
|
+
}): McpDocs {
|
|
240
|
+
let topics: DocsTopic[] | undefined;
|
|
241
|
+
const all = (): DocsTopic[] => {
|
|
242
|
+
topics ??= docsIndex(options.referenceDir, options.skillDir);
|
|
243
|
+
return topics;
|
|
244
|
+
};
|
|
245
|
+
const cache = new Map<string, string>();
|
|
246
|
+
return {
|
|
247
|
+
topics: (): DocsTopicSummary[] =>
|
|
248
|
+
all().map((topic) => ({ topic: topic.topic, title: topic.title, url: topic.url })),
|
|
249
|
+
read(topic) {
|
|
250
|
+
const cached = cache.get(topic);
|
|
251
|
+
if (cached !== undefined) return cached;
|
|
252
|
+
const found = all().find((entry) => entry.topic === topic);
|
|
253
|
+
if (found === undefined) return undefined;
|
|
254
|
+
const markdown = topicMarkdown(found, options.skillDir, options.links ?? MCP_GUIDE_LINKS);
|
|
255
|
+
cache.set(topic, markdown);
|
|
256
|
+
return markdown;
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
package/src/http.ts
CHANGED
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
refusal,
|
|
20
20
|
safeEqual,
|
|
21
21
|
} from "@mostra/protocol";
|
|
22
|
+
import type { McpServerOptions } from "./ports.ts";
|
|
23
|
+
import { createMcpServerFactory } from "./server.ts";
|
|
22
24
|
|
|
23
25
|
/** The path the endpoint serves. */
|
|
24
26
|
export const MCP_PATH = "/mcp";
|
|
@@ -186,3 +188,72 @@ export function createHttpEndpoint(
|
|
|
186
188
|
close: () => handler.close(),
|
|
187
189
|
};
|
|
188
190
|
}
|
|
191
|
+
|
|
192
|
+
/** What an authorization server established about a remote MCP request (INTERFACES §18.8). */
|
|
193
|
+
export interface McpAuthorization {
|
|
194
|
+
/** The access token, as presented (never logged). */
|
|
195
|
+
readonly token: string;
|
|
196
|
+
/** The OAuth client the token was issued to. */
|
|
197
|
+
readonly clientId: string;
|
|
198
|
+
/** The token's scopes. */
|
|
199
|
+
readonly scopes: readonly string[];
|
|
200
|
+
/** When the token expires, in seconds since the epoch. */
|
|
201
|
+
readonly expiresAt?: number;
|
|
202
|
+
/** The resource (audience) it was issued for. */
|
|
203
|
+
readonly resource: string;
|
|
204
|
+
/** Whatever the server needs to build the request's ports (its account, its home). */
|
|
205
|
+
readonly subject: Readonly<Record<string, unknown>>;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** A remote MCP endpoint: requests whose authorization the caller checked already. */
|
|
209
|
+
export interface McpAuthorizedEndpoint {
|
|
210
|
+
/** Serves one request, `authorization` being what the caller established for it. */
|
|
211
|
+
fetch(request: Request, authorization: McpAuthorization): Promise<Response>;
|
|
212
|
+
/** Stops serving: requests in flight end. */
|
|
213
|
+
close(): Promise<void>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* A Streamable HTTP endpoint for a server that authorizes requests itself (the remote server,
|
|
218
|
+
* D164): stateless, for the `2026-07-28` and the 2025 revisions, building each request's MCP
|
|
219
|
+
* server from the ports `optionsFor` gives for its authorization. Host, Origin, the bearer token,
|
|
220
|
+
* its audience and its scope are the caller's to check before; this adds the endpoint's own
|
|
221
|
+
* headers to every answer.
|
|
222
|
+
*/
|
|
223
|
+
export function createAuthorizedEndpoint(
|
|
224
|
+
optionsFor: (authorization: McpAuthorization) => McpServerOptions,
|
|
225
|
+
policy: { readonly onError?: (error: Error) => void } = {},
|
|
226
|
+
): McpAuthorizedEndpoint {
|
|
227
|
+
const handler = createMcpHandler(
|
|
228
|
+
(context) => {
|
|
229
|
+
const authorization = context.authInfo?.extra?.["mostra"] as McpAuthorization | undefined;
|
|
230
|
+
if (authorization === undefined)
|
|
231
|
+
throw new Error("An authorized request has no authorization.");
|
|
232
|
+
return createMcpServerFactory(optionsFor(authorization))(context);
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
legacy: "stateless",
|
|
236
|
+
maxRequestBodySize: MCP_MAX_BODY_BYTES,
|
|
237
|
+
...(policy.onError !== undefined ? { onerror: policy.onError } : {}),
|
|
238
|
+
},
|
|
239
|
+
);
|
|
240
|
+
return {
|
|
241
|
+
async fetch(request, authorization) {
|
|
242
|
+
return harden(
|
|
243
|
+
await handler.fetch(request, {
|
|
244
|
+
authInfo: {
|
|
245
|
+
token: authorization.token,
|
|
246
|
+
clientId: authorization.clientId,
|
|
247
|
+
scopes: [...authorization.scopes],
|
|
248
|
+
...(authorization.expiresAt !== undefined
|
|
249
|
+
? { expiresAt: authorization.expiresAt }
|
|
250
|
+
: {}),
|
|
251
|
+
resource: new URL(authorization.resource),
|
|
252
|
+
extra: { mostra: authorization },
|
|
253
|
+
},
|
|
254
|
+
}),
|
|
255
|
+
);
|
|
256
|
+
},
|
|
257
|
+
close: () => handler.close(),
|
|
258
|
+
};
|
|
259
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -12,13 +12,28 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @packageDocumentation
|
|
14
14
|
*/
|
|
15
|
+
|
|
15
16
|
export {
|
|
17
|
+
type DocsTopic,
|
|
18
|
+
docsIndex,
|
|
19
|
+
fileDocs,
|
|
20
|
+
GUIDE_LINKS,
|
|
21
|
+
guideTopics,
|
|
22
|
+
indexMarkdown,
|
|
23
|
+
MCP_GUIDE_LINKS,
|
|
24
|
+
nearestTopics,
|
|
25
|
+
topicMarkdown,
|
|
26
|
+
} from "./docs.ts";
|
|
27
|
+
export {
|
|
28
|
+
createAuthorizedEndpoint,
|
|
16
29
|
createHttpEndpoint,
|
|
17
30
|
GUESS_LIMIT,
|
|
18
31
|
GUESS_WINDOW_MS,
|
|
19
32
|
type HttpEndpointPolicy,
|
|
20
33
|
MCP_MAX_BODY_BYTES,
|
|
21
34
|
MCP_PATH,
|
|
35
|
+
type McpAuthorization,
|
|
36
|
+
type McpAuthorizedEndpoint,
|
|
22
37
|
type McpHttpEndpoint,
|
|
23
38
|
type RawRequest,
|
|
24
39
|
} from "./http.ts";
|
package/src/tools.ts
CHANGED
|
@@ -238,7 +238,7 @@ const waitInput = input(
|
|
|
238
238
|
z.object({
|
|
239
239
|
artifact: artifactField,
|
|
240
240
|
until: WaitCondition.describe(
|
|
241
|
-
"submitted, signal:<name>, state:<fieldId> or event:<type> (event:submission.* matches a family).",
|
|
241
|
+
"submitted, submitted:all (every expected respondent), submitted:<N>, signal:<name>, state:<fieldId> or event:<type> (event:submission.* matches a family).",
|
|
242
242
|
),
|
|
243
243
|
after: z
|
|
244
244
|
.string()
|
|
@@ -585,7 +585,7 @@ export function createTools(
|
|
|
585
585
|
defineTool({
|
|
586
586
|
name: "artifact_wait",
|
|
587
587
|
title: "Wait for an answer",
|
|
588
|
-
description: `Wait until a person submits (until: submitted), raises a signal (signal:<name>), changes shared state (state:<fieldId>) or an event happens (event:<type>). Waits at most timeoutSeconds (${WAIT_MAX_SECONDS} at most). Returns satisfied with the event once it happens, or still_waiting with a cursor: nothing is lost, so call again with after set to that cursor, or do other work and check later.`,
|
|
588
|
+
description: `Wait until a person submits (until: submitted), every expected respondent has (submitted:all) or N submissions exist (submitted:<N>), a person raises a signal (signal:<name>), changes shared state (state:<fieldId>) or an event happens (event:<type>). Waits at most timeoutSeconds (${WAIT_MAX_SECONDS} at most). Returns satisfied with the event once it happens, or still_waiting with a cursor: nothing is lost, so call again with after set to that cursor, or do other work and check later.`,
|
|
589
589
|
input: waitInput,
|
|
590
590
|
annotations: {
|
|
591
591
|
readOnlyHint: true,
|