@enhance-eng/enhance 0.1.6 → 0.1.13
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/{capability-inventory.mapper-DN3TEDbU.mjs → capability-inventory.mapper-DyYXyVBJ.mjs} +2 -1
- package/dist/{failure.mapper-CNRVSTrf.mjs → cli-output-identity.lib-DAJiBMGX.mjs} +1546 -211
- package/dist/{file-credential.adapter-WNl4GM58.mjs → file-credential.adapter-rI5HpMEo.mjs} +3 -1
- package/dist/main.mjs +656 -673
- package/dist/mcp-invocation.adapter-BG-WBGEr.mjs +119 -0
- package/dist/mcp-main.mjs +175 -9
- package/dist/{mcp-server.adapter-T8UqHf6A.mjs → mcp-server.adapter-BgUZCdl4.mjs} +165 -153
- package/dist/mcp.mjs +5 -4
- package/dist/{mutation-key.adapter-B7Ss_464.mjs → mutation-key.adapter-BffKsNR-.mjs} +283 -29
- package/dist/remote-mcp-main.mjs +11 -8
- package/package.json +1 -1
- package/dist/mcp-invocation.adapter-D0o0vb_-.mjs +0 -17
|
@@ -1,89 +1,60 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { C as CliError, a as toPresentedCapabilities, i as toFailurePayload, l as createCapabilityCatalogAdapter, n as withCommandName, s as createMcpCapabilityDiscoveryAdapter, t as withCommandInFailure } from "./cli-output-identity.lib-DAJiBMGX.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import { readFile, rm } from "node:fs/promises";
|
|
6
6
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const id = normalized(capability.id);
|
|
18
|
-
if (query === id) return EXACT_ID_SCORE;
|
|
19
|
-
const idSegments = new Set(id.split(" "));
|
|
20
|
-
const guide = normalized([
|
|
21
|
-
capability.guide.summary,
|
|
22
|
-
capability.guide.useWhen,
|
|
23
|
-
...capability.guide.preconditions,
|
|
24
|
-
...capability.guide.input.map((field) => `${field.name} ${field.meaning}`),
|
|
25
|
-
...capability.guide.output.map((field) => `${field.name} ${field.meaning}`),
|
|
26
|
-
...capability.guide.next
|
|
27
|
-
].join(" "));
|
|
28
|
-
const terms = query.split(" ").filter((term) => term !== "");
|
|
29
|
-
let score = id.startsWith(query) ? ID_PREFIX_SCORE : NO_MATCH_SCORE;
|
|
30
|
-
for (const term of terms) {
|
|
31
|
-
if (idSegments.has(term)) score += ID_SEGMENT_SCORE;
|
|
32
|
-
else if (id.includes(term)) score += ID_SUBSTRING_SCORE;
|
|
33
|
-
if (guide.includes(term)) score += GUIDE_MATCH_SCORE;
|
|
34
|
-
}
|
|
35
|
-
return score;
|
|
7
|
+
|
|
8
|
+
//#region src/infrastructure/capability-catalogue-text.mapper.ts
|
|
9
|
+
const MAX_LINE_CHARACTERS = 180;
|
|
10
|
+
const MAX_CATALOGUE_BYTES = 24 * 1024;
|
|
11
|
+
const oneLine = (value) => value.replaceAll(/\s+/gu, " ").trim();
|
|
12
|
+
const lineFor = (capability) => {
|
|
13
|
+
const prefix = `${capability.id} [${capability.effect}] — `;
|
|
14
|
+
const summary = oneLine(capability.guide.summary);
|
|
15
|
+
const available = MAX_LINE_CHARACTERS - prefix.length;
|
|
16
|
+
return `${prefix}${summary.slice(0, available)}`;
|
|
36
17
|
};
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
const toCapabilityCatalogueText = (catalog, serverVersion) => {
|
|
19
|
+
const lines = catalog.toSorted((left, right) => left.id.localeCompare(right.id)).map((capability) => lineFor(capability));
|
|
20
|
+
const digest = createHash("sha256").update(lines.join("\n")).digest("hex");
|
|
21
|
+
const text = [`Enhance MCP ${serverVersion} — ${String(lines.length)} capabilities — sha256:${digest}`, ...lines].join("\n");
|
|
22
|
+
if (Buffer.byteLength(text) > MAX_CATALOGUE_BYTES) throw new RangeError("the complete capability catalogue exceeds 24 KiB");
|
|
23
|
+
return {
|
|
24
|
+
digest,
|
|
25
|
+
text
|
|
26
|
+
};
|
|
41
27
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})).filter((candidate) => candidate.score > NO_MATCH_SCORE).toSorted((left, right) => {
|
|
73
|
-
const scoreDifference = right.score - left.score;
|
|
74
|
-
return scoreDifference === NO_MATCH_SCORE ? left.capability.id.localeCompare(right.capability.id) : scoreDifference;
|
|
75
|
-
});
|
|
76
|
-
return {
|
|
77
|
-
matches: ranked.slice(0, input.limit).map(({ capability }) => toBrief(capability)),
|
|
78
|
-
totalMatches: ranked.length,
|
|
79
|
-
truncated: ranked.length > input.limit
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
describe: (id) => {
|
|
83
|
-
const capability = catalog.find((candidate) => candidate.id === id);
|
|
84
|
-
return capability === void 0 ? null : toContract(capability);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/infrastructure/mcp-catalogue-tool.adapter.ts
|
|
31
|
+
const createMcpCatalogueToolAdapter = (catalog, version, commandName = "enhance") => {
|
|
32
|
+
const catalogue = toCapabilityCatalogueText(catalog, version);
|
|
33
|
+
const presented = String(withCommandName(catalogue.text, commandName));
|
|
34
|
+
return { register: (server) => {
|
|
35
|
+
server.registerTool("capability_catalogue", {
|
|
36
|
+
title: "Scan every Enhance capability",
|
|
37
|
+
description: "Return the complete bounded capability inventory when the task is broad, uncertain, or capability_search does not find the right words. Call capability_describe with one exact id before invoking it.",
|
|
38
|
+
inputSchema: z.strictObject({}),
|
|
39
|
+
annotations: {
|
|
40
|
+
readOnlyHint: true,
|
|
41
|
+
destructiveHint: false,
|
|
42
|
+
idempotentHint: true,
|
|
43
|
+
openWorldHint: false
|
|
44
|
+
},
|
|
45
|
+
_meta: {
|
|
46
|
+
"ai.enhancelabs/disclosure": "progressive",
|
|
47
|
+
"ai.enhancelabs/catalogSize": catalog.length,
|
|
48
|
+
"enhance/disclosure": "progressive",
|
|
49
|
+
"enhance/catalogSize": catalog.length
|
|
50
|
+
}
|
|
51
|
+
}, () => ({ content: [{
|
|
52
|
+
type: "text",
|
|
53
|
+
text: presented
|
|
54
|
+
}] }));
|
|
55
|
+
} };
|
|
56
|
+
};
|
|
57
|
+
|
|
87
58
|
//#endregion
|
|
88
59
|
//#region src/infrastructure/mcp-progressive.schema.ts
|
|
89
60
|
const failureSchema = z.object({
|
|
@@ -164,6 +135,33 @@ const mcpDescribeResultSchema = z.union([z.object({
|
|
|
164
135
|
ok: z.literal(true),
|
|
165
136
|
result: capabilityContractSchema
|
|
166
137
|
}), failureSchema]);
|
|
138
|
+
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/infrastructure/mcp-describe-tool.adapter.ts
|
|
141
|
+
const describeInputSchema = z.object({ capability: z.string().min(1).describe("Exact capability id returned by capability_search or capability_catalogue.") });
|
|
142
|
+
const createMcpDescribeToolAdapter = (discovery, mcpResults) => ({ register: (server) => {
|
|
143
|
+
server.registerTool("capability_describe", {
|
|
144
|
+
title: "Load one Enhance capability contract",
|
|
145
|
+
description: "Load the exact input schema, example, preconditions, result guidance, recovery, and next steps for one id returned by capability_search or capability_catalogue.",
|
|
146
|
+
inputSchema: describeInputSchema,
|
|
147
|
+
outputSchema: mcpDescribeResultSchema,
|
|
148
|
+
annotations: {
|
|
149
|
+
readOnlyHint: true,
|
|
150
|
+
destructiveHint: false,
|
|
151
|
+
idempotentHint: true,
|
|
152
|
+
openWorldHint: false
|
|
153
|
+
},
|
|
154
|
+
_meta: {
|
|
155
|
+
"ai.enhancelabs/disclosure": "progressive",
|
|
156
|
+
"enhance/disclosure": "progressive"
|
|
157
|
+
}
|
|
158
|
+
}, ({ capability }) => {
|
|
159
|
+
const contract = discovery.describe(capability);
|
|
160
|
+
if (contract !== null) return mcpResults.inline(contract);
|
|
161
|
+
return mcpResults.failure(new CliError("BAD_REQUEST", `Unknown shared capability: ${capability}.`, "Call capability_search or capability_catalogue and use an exact id from its results.", { capability: "No shared capability has this id." }));
|
|
162
|
+
});
|
|
163
|
+
} });
|
|
164
|
+
|
|
167
165
|
//#endregion
|
|
168
166
|
//#region src/infrastructure/mcp-result.adapter.ts
|
|
169
167
|
const PROTECTED_RESULT_BYTES = 2e4;
|
|
@@ -198,14 +196,25 @@ const localArtifactResult = async (server, result, delivery) => {
|
|
|
198
196
|
}
|
|
199
197
|
};
|
|
200
198
|
return {
|
|
201
|
-
content: [
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
199
|
+
content: [
|
|
200
|
+
{
|
|
201
|
+
type: "text",
|
|
202
|
+
text: textFor(structuredContent)
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
type: "image",
|
|
206
|
+
data: body.toString("base64"),
|
|
207
|
+
mimeType
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
type: "resource",
|
|
211
|
+
resource: {
|
|
212
|
+
uri,
|
|
213
|
+
mimeType,
|
|
214
|
+
blob: body.toString("base64")
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
],
|
|
209
218
|
structuredContent
|
|
210
219
|
};
|
|
211
220
|
}
|
|
@@ -295,16 +304,17 @@ const artifactResult = (server, serialized, delivery) => {
|
|
|
295
304
|
structuredContent
|
|
296
305
|
};
|
|
297
306
|
};
|
|
298
|
-
const validationError = (error) => new CliError("BAD_REQUEST", "Input validation error.", "Call
|
|
299
|
-
const createMcpResultAdapter = () => ({
|
|
307
|
+
const validationError = (error) => new CliError("BAD_REQUEST", "Input validation error.", "Call capability_search again and rewrite every rejected input field.", Object.fromEntries(error.issues.map((issue) => [issue.path.length === 0 ? "input" : issue.path.join("."), issue.message])));
|
|
308
|
+
const createMcpResultAdapter = (authenticationRemediation, commandName = "enhance") => ({
|
|
300
309
|
success: async (server, result, delivery) => {
|
|
301
|
-
const
|
|
310
|
+
const presented = withCommandName(result, commandName);
|
|
311
|
+
const localArtifact = await localArtifactResult(server, presented, delivery);
|
|
302
312
|
if (localArtifact !== null) return localArtifact;
|
|
303
|
-
const serialized = textFor(
|
|
304
|
-
if (Buffer.byteLength(serialized) > PROTECTED_RESULT_BYTES || hasProtectedMaterial(
|
|
313
|
+
const serialized = textFor(presented);
|
|
314
|
+
if (Buffer.byteLength(serialized) > PROTECTED_RESULT_BYTES || hasProtectedMaterial(presented)) return artifactResult(server, serialized, delivery);
|
|
305
315
|
const structuredContent = {
|
|
306
316
|
ok: true,
|
|
307
|
-
result
|
|
317
|
+
result: presented
|
|
308
318
|
};
|
|
309
319
|
return {
|
|
310
320
|
content: [{
|
|
@@ -317,7 +327,7 @@ const createMcpResultAdapter = () => ({
|
|
|
317
327
|
inline: (result) => {
|
|
318
328
|
const structuredContent = {
|
|
319
329
|
ok: true,
|
|
320
|
-
result
|
|
330
|
+
result: withCommandName(result, commandName)
|
|
321
331
|
};
|
|
322
332
|
return {
|
|
323
333
|
content: [{
|
|
@@ -328,9 +338,13 @@ const createMcpResultAdapter = () => ({
|
|
|
328
338
|
};
|
|
329
339
|
},
|
|
330
340
|
failure: (error) => {
|
|
341
|
+
const failure = withCommandInFailure(toFailurePayload(error instanceof z.ZodError ? validationError(error) : error, null), commandName);
|
|
331
342
|
const structuredContent = {
|
|
332
343
|
ok: false,
|
|
333
|
-
error:
|
|
344
|
+
error: failure.code === "UNAUTHORIZED" ? {
|
|
345
|
+
...failure,
|
|
346
|
+
remediation: authenticationRemediation
|
|
347
|
+
} : failure
|
|
334
348
|
};
|
|
335
349
|
return {
|
|
336
350
|
content: [{
|
|
@@ -342,15 +356,15 @@ const createMcpResultAdapter = () => ({
|
|
|
342
356
|
};
|
|
343
357
|
}
|
|
344
358
|
});
|
|
345
|
-
|
|
346
|
-
//#region src/infrastructure/shared-capabilities.mapper.ts
|
|
347
|
-
const toSharedCapabilities = (catalog) => catalog.filter((capability) => capability.policy.exposure === "shared");
|
|
359
|
+
|
|
348
360
|
//#endregion
|
|
349
361
|
//#region src/infrastructure/mcp-server.adapter.ts
|
|
350
362
|
const MAX_SEARCH_QUERY_CHARACTERS = 200;
|
|
351
363
|
const MAX_SEARCH_RESULTS = 10;
|
|
352
364
|
const DEFAULT_SEARCH_RESULTS = 5;
|
|
353
|
-
const
|
|
365
|
+
const AUTHENTICATION_INSTRUCTIONS = "Transport attachment is not Enhance sign-in, even when the host reports mcp_auth success. Use capability_query with capability auth.status to check the person. If authenticated is false or a read returns UNAUTHORIZED, use capability_mutate with capability auth.login and input {\"openBrowser\":true}, then show the returned sign-in URL and let the person complete browser sign-in. If their browser restores a canvas or another page, direct them to this exact URL. A waiting_for_browser result is pending, not authenticated. Verify auth.status and a read such as canvas.list before reporting setup complete.";
|
|
366
|
+
const LOCAL_AUTHENTICATION_REMEDY = "Call capability_mutate with capability auth.login and input {\"openBrowser\":true}. Show the returned sign-in URL, complete browser sign-in, then verify auth.status and a read such as canvas.list.";
|
|
367
|
+
const HOSTED_AUTHENTICATION_REMEDY = "Reconnect this hosted MCP server through your host’s browser OAuth sign-in. Then verify person.me and a read such as canvas.list.";
|
|
354
368
|
const searchInputSchema = z.object({
|
|
355
369
|
query: z.string().trim().min(1).max(MAX_SEARCH_QUERY_CHARACTERS).describe("Plain-language task, domain, or exact capability id to discover."),
|
|
356
370
|
operation: z.enum([
|
|
@@ -361,28 +375,27 @@ const searchInputSchema = z.object({
|
|
|
361
375
|
limit: z.number().int().min(1).max(MAX_SEARCH_RESULTS).default(DEFAULT_SEARCH_RESULTS).describe("Maximum contracts to return.")
|
|
362
376
|
});
|
|
363
377
|
const queryInputSchema = z.object({
|
|
364
|
-
capability: z.string().min(1).describe("Exact query id returned by
|
|
378
|
+
capability: z.string().min(1).describe("Exact query id returned by capability_describe."),
|
|
365
379
|
input: z.record(z.string(), z.unknown()).default({}).describe("Input matching the discovered capability inputSchema.")
|
|
366
380
|
});
|
|
367
381
|
const mutationInputSchema = z.object({
|
|
368
|
-
capability: z.string().min(1).describe("Exact mutation id returned by
|
|
382
|
+
capability: z.string().min(1).describe("Exact mutation id returned by capability_describe."),
|
|
369
383
|
input: z.record(z.string(), z.unknown()).default({}).describe("Input matching the discovered capability inputSchema."),
|
|
370
384
|
clientToken: z.uuid().optional().describe("Stable UUID reused only when retrying this exact mutation input.")
|
|
371
385
|
});
|
|
372
|
-
const describeInputSchema = z.object({ capability: z.string().min(1).describe("Exact capability id returned by capability.search.") });
|
|
373
386
|
const capabilityFor = (catalog, id, operation) => {
|
|
374
387
|
const capability = catalog.find((candidate) => candidate.id === id);
|
|
375
|
-
if (capability === void 0) throw new CliError("BAD_REQUEST", `Unknown shared capability: ${id}.`, "Call
|
|
388
|
+
if (capability === void 0) throw new CliError("BAD_REQUEST", `Unknown shared capability: ${id}.`, "Call capability_search or capability_catalogue and use an exact id from its results.", { capability: "No shared capability has this id." });
|
|
376
389
|
if (capability.operation !== operation) {
|
|
377
|
-
const dispatcher = capability.operation === "query" ? "
|
|
390
|
+
const dispatcher = capability.operation === "query" ? "capability_query" : "capability_mutate";
|
|
378
391
|
throw new CliError("BAD_REQUEST", `${id} is a ${capability.operation}, not a ${operation}.`, `Call ${dispatcher} with the same capability and input.`, { capability: `Use ${dispatcher} for this capability.` });
|
|
379
392
|
}
|
|
380
393
|
return capability;
|
|
381
394
|
};
|
|
382
|
-
const registerSearch = (server, catalog, discovery) => {
|
|
383
|
-
server.registerTool("
|
|
395
|
+
const registerSearch = (server, catalog, discovery, mcpResults) => {
|
|
396
|
+
server.registerTool("capability_search", {
|
|
384
397
|
title: "Discover Enhance capabilities",
|
|
385
|
-
description: "Search the
|
|
398
|
+
description: "Search the Enhance capability catalogue for a specific likely action. Returns only the most relevant summaries; use capability_catalogue when the request is broad or the matches look wrong, then call capability_describe before invoking.",
|
|
386
399
|
inputSchema: searchInputSchema,
|
|
387
400
|
outputSchema: mcpSearchResultSchema,
|
|
388
401
|
annotations: {
|
|
@@ -392,6 +405,8 @@ const registerSearch = (server, catalog, discovery) => {
|
|
|
392
405
|
openWorldHint: false
|
|
393
406
|
},
|
|
394
407
|
_meta: {
|
|
408
|
+
"ai.enhancelabs/disclosure": "progressive",
|
|
409
|
+
"ai.enhancelabs/catalogSize": catalog.length,
|
|
395
410
|
"enhance/disclosure": "progressive",
|
|
396
411
|
"enhance/catalogSize": catalog.length
|
|
397
412
|
}
|
|
@@ -401,29 +416,10 @@ const registerSearch = (server, catalog, discovery) => {
|
|
|
401
416
|
limit
|
|
402
417
|
})));
|
|
403
418
|
};
|
|
404
|
-
const
|
|
405
|
-
server.registerTool("
|
|
406
|
-
title: "Load one Enhance capability contract",
|
|
407
|
-
description: "Load the exact input schema, example, preconditions, result guidance, recovery, and next steps for one id returned by capability.search.",
|
|
408
|
-
inputSchema: describeInputSchema,
|
|
409
|
-
outputSchema: mcpDescribeResultSchema,
|
|
410
|
-
annotations: {
|
|
411
|
-
readOnlyHint: true,
|
|
412
|
-
destructiveHint: false,
|
|
413
|
-
idempotentHint: true,
|
|
414
|
-
openWorldHint: false
|
|
415
|
-
},
|
|
416
|
-
_meta: { "enhance/disclosure": "progressive" }
|
|
417
|
-
}, async ({ capability }) => {
|
|
418
|
-
const contract = discovery.describe(capability);
|
|
419
|
-
if (contract !== null) return mcpResults.inline(contract);
|
|
420
|
-
return mcpResults.failure(new CliError("BAD_REQUEST", `Unknown shared capability: ${capability}.`, "Call capability.search and use an exact id from its matches.", { capability: "No shared capability has this id." }));
|
|
421
|
-
});
|
|
422
|
-
};
|
|
423
|
-
const registerQuery = (server, catalog, invocation, delivery) => {
|
|
424
|
-
server.registerTool("capability.query", {
|
|
419
|
+
const registerQuery = (server, catalog, invocation, execution) => {
|
|
420
|
+
server.registerTool("capability_query", {
|
|
425
421
|
title: "Run a discovered Enhance query",
|
|
426
|
-
description: "Run one read-only capability using the exact id and input loaded by
|
|
422
|
+
description: "Run one read-only capability using the exact id and input loaded by capability_describe. Search and describe first whenever the contract is not already present in the conversation.",
|
|
427
423
|
inputSchema: queryInputSchema,
|
|
428
424
|
outputSchema: mcpDispatchedResultSchema,
|
|
429
425
|
annotations: {
|
|
@@ -432,60 +428,76 @@ const registerQuery = (server, catalog, invocation, delivery) => {
|
|
|
432
428
|
idempotentHint: true,
|
|
433
429
|
openWorldHint: false
|
|
434
430
|
},
|
|
435
|
-
_meta: {
|
|
431
|
+
_meta: {
|
|
432
|
+
"ai.enhancelabs/disclosure": "progressive",
|
|
433
|
+
"enhance/disclosure": "progressive"
|
|
434
|
+
}
|
|
436
435
|
}, async ({ capability: id, input }) => {
|
|
437
436
|
try {
|
|
438
|
-
return await
|
|
437
|
+
return await execution.results.success(server, await invocation.invoke({
|
|
439
438
|
capability: capabilityFor(catalog, id, "query"),
|
|
440
439
|
arguments: input,
|
|
441
440
|
clientToken: null
|
|
442
|
-
}), delivery);
|
|
441
|
+
}), execution.delivery);
|
|
443
442
|
} catch (error) {
|
|
444
|
-
return
|
|
443
|
+
return execution.results.failure(error);
|
|
445
444
|
}
|
|
446
445
|
});
|
|
447
446
|
};
|
|
448
|
-
const registerMutation = (server, catalog, invocation,
|
|
449
|
-
server.registerTool("
|
|
447
|
+
const registerMutation = (server, catalog, invocation, execution) => {
|
|
448
|
+
server.registerTool("capability_mutate", {
|
|
450
449
|
title: "Run a discovered Enhance mutation",
|
|
451
|
-
description: "Run one state-changing capability using the exact id and input loaded by
|
|
450
|
+
description: "Run one state-changing capability using the exact id and input loaded by capability_describe. Search and describe first, respect its preconditions, and reuse clientToken only when retrying the identical mutation.",
|
|
452
451
|
inputSchema: mutationInputSchema,
|
|
453
452
|
outputSchema: mcpDispatchedResultSchema,
|
|
454
453
|
annotations: {
|
|
455
454
|
readOnlyHint: false,
|
|
456
455
|
destructiveHint: true,
|
|
457
456
|
idempotentHint: false,
|
|
458
|
-
openWorldHint:
|
|
457
|
+
openWorldHint: true
|
|
459
458
|
},
|
|
460
|
-
_meta: {
|
|
459
|
+
_meta: {
|
|
460
|
+
"ai.enhancelabs/disclosure": "progressive",
|
|
461
|
+
"enhance/disclosure": "progressive"
|
|
462
|
+
}
|
|
461
463
|
}, async ({ capability: id, input, clientToken }) => {
|
|
462
464
|
try {
|
|
463
|
-
return await
|
|
465
|
+
return await execution.results.success(server, await invocation.invoke({
|
|
464
466
|
capability: capabilityFor(catalog, id, "mutation"),
|
|
465
467
|
arguments: input,
|
|
466
468
|
clientToken: clientToken ?? null
|
|
467
|
-
}), delivery);
|
|
469
|
+
}), execution.delivery);
|
|
468
470
|
} catch (error) {
|
|
469
|
-
return
|
|
471
|
+
return execution.results.failure(error);
|
|
470
472
|
}
|
|
471
473
|
});
|
|
472
474
|
};
|
|
473
475
|
const createMcpServerAdapter = (input) => {
|
|
474
476
|
const server = new McpServer({
|
|
475
|
-
name: "enhance-mcp",
|
|
477
|
+
name: input.name ?? "enhance-mcp",
|
|
476
478
|
version: input.version
|
|
477
|
-
}, {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
479
|
+
}, {
|
|
480
|
+
capabilities: {
|
|
481
|
+
tools: { listChanged: false },
|
|
482
|
+
resources: { listChanged: true }
|
|
483
|
+
},
|
|
484
|
+
...input.exposures?.includes("mcp-transport") === true && { instructions: AUTHENTICATION_INSTRUCTIONS }
|
|
485
|
+
});
|
|
486
|
+
const catalog = toPresentedCapabilities(input.catalog ?? createCapabilityCatalogAdapter(), input.exposures ?? ["shared"]);
|
|
482
487
|
const discovery = createMcpCapabilityDiscoveryAdapter(catalog);
|
|
483
488
|
const delivery = input.delivery ?? "linked";
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
489
|
+
const mcpResults = createMcpResultAdapter(input.exposures?.includes("mcp-transport") === true ? LOCAL_AUTHENTICATION_REMEDY : HOSTED_AUTHENTICATION_REMEDY, input.commandName);
|
|
490
|
+
createMcpCatalogueToolAdapter(catalog, input.version, input.commandName).register(server);
|
|
491
|
+
registerSearch(server, catalog, discovery, mcpResults);
|
|
492
|
+
createMcpDescribeToolAdapter(discovery, mcpResults).register(server);
|
|
493
|
+
const execution = {
|
|
494
|
+
delivery,
|
|
495
|
+
results: mcpResults
|
|
496
|
+
};
|
|
497
|
+
registerQuery(server, catalog, input.invocation, execution);
|
|
498
|
+
registerMutation(server, catalog, input.invocation, execution);
|
|
488
499
|
return server;
|
|
489
500
|
};
|
|
501
|
+
|
|
490
502
|
//#endregion
|
|
491
|
-
export {
|
|
503
|
+
export { createMcpServerAdapter as t };
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { t as toCapabilityInventory } from "./capability-inventory.mapper-
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { l as createCapabilityCatalogAdapter, o as toSharedCapabilities } from "./cli-output-identity.lib-DAJiBMGX.mjs";
|
|
3
|
+
import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
|
|
4
|
+
import { t as createMcpServerAdapter } from "./mcp-server.adapter-BgUZCdl4.mjs";
|
|
5
|
+
|
|
6
|
+
export { createCapabilityCatalogAdapter, createMcpServerAdapter as createEnhanceMcpServer, toCapabilityInventory, toSharedCapabilities };
|