@topolo/mcp 0.10.2 → 0.10.3

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.
@@ -75,6 +75,11 @@ type ToolDispatchResult = {
75
75
  reason: ToolDispatchFailureReason;
76
76
  durationMs: number;
77
77
  requiredScopes?: string[];
78
+ code?: string;
79
+ status?: number;
80
+ requestId?: string;
81
+ details?: unknown;
82
+ hint?: string;
78
83
  };
79
84
  interface ToolAdvertisement {
80
85
  name: string;
package/dist/dispatch.js CHANGED
@@ -1,5 +1,11 @@
1
1
  // src/dispatch.ts
2
- import { TopoloAuthError, TopoloPermissionError } from "@topolo/sdk";
2
+ import {
3
+ TopoloAuthError,
4
+ TopoloHttpError,
5
+ TopoloPermissionError,
6
+ publicTopoloErrorMessage,
7
+ topoloErrorHint
8
+ } from "@topolo/sdk";
3
9
 
4
10
  // src/tools.ts
5
11
  import {
@@ -8,6 +14,7 @@ import {
8
14
  auditApplicationEntries,
9
15
  applicationRequirementScopes,
10
16
  compactActionCatalogEntry,
17
+ compactActionPreparation,
11
18
  compactActionPlan,
12
19
  compactActionValidation,
13
20
  compactApplicationAudit,
@@ -373,6 +380,38 @@ var TOOLS = [
373
380
  return args["detail"] === true ? result : compactActionValidation(result.action.actionId, result.validation);
374
381
  }
375
382
  },
383
+ {
384
+ name: "topolo_prepare_action",
385
+ title: "Prepare one Topolo action",
386
+ description: "Fetches one exact live action contract once and returns one valid published example, missing fields, exact request, confirmation state, verification, and rollback without executing it.",
387
+ requiredScopes: [],
388
+ destructive: false,
389
+ inputSchema: {
390
+ type: "object",
391
+ properties: {
392
+ actionId: { type: "string", minLength: 1 },
393
+ input: { type: "object", additionalProperties: true },
394
+ resourceType: { type: "string" },
395
+ resourceId: { type: "string" },
396
+ confirm: { type: "boolean", description: "Include confirmation in the plan without executing the action." }
397
+ },
398
+ required: ["actionId"],
399
+ additionalProperties: false
400
+ },
401
+ handler: async (topolo, args) => {
402
+ const actionId = requiredString(args, "actionId");
403
+ const resource = optionalResourceContext(args);
404
+ const preparation = await topolo.client.prepareAction(
405
+ actionId,
406
+ args["input"] === void 0 ? void 0 : coerceObjectParam(args["input"], "input"),
407
+ {
408
+ confirm: args["confirm"] === true,
409
+ ...resource ? { resource } : {}
410
+ }
411
+ );
412
+ return compactActionPreparation(preparation);
413
+ }
414
+ },
376
415
  {
377
416
  name: "topolo_plan_action",
378
417
  title: "Plan one Topolo action",
@@ -867,8 +906,13 @@ async function dispatchTopoloTool(input) {
867
906
  return {
868
907
  ok: false,
869
908
  reason: "permission",
870
- error: `Permission denied. Required: ${err.required.join(", ") || "(unknown)"}`,
909
+ error: publicTopoloErrorMessage(err),
871
910
  requiredScopes: err.required,
911
+ code: err.code,
912
+ status: err.status,
913
+ requestId: err.requestId,
914
+ details: err.details,
915
+ hint: topoloErrorHint(err),
872
916
  durationMs: Date.now() - started
873
917
  };
874
918
  }
@@ -877,6 +921,24 @@ async function dispatchTopoloTool(input) {
877
921
  ok: false,
878
922
  reason: "auth",
879
923
  error: "Authentication failed.",
924
+ code: err.code,
925
+ status: err.status,
926
+ requestId: err.requestId,
927
+ details: err.details,
928
+ hint: topoloErrorHint(err),
929
+ durationMs: Date.now() - started
930
+ };
931
+ }
932
+ if (err instanceof TopoloHttpError) {
933
+ return {
934
+ ok: false,
935
+ reason: "handler",
936
+ error: publicTopoloErrorMessage(err),
937
+ code: err.code,
938
+ status: err.status,
939
+ requestId: err.requestId,
940
+ details: err.details,
941
+ hint: topoloErrorHint(err),
880
942
  durationMs: Date.now() - started
881
943
  };
882
944
  }
package/dist/http.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { TopoloRuntimeEnvironment, TopoloCredential, Topolo } from '@topolo/sdk';
1
2
  import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
2
- import { TopoloCredential, Topolo } from '@topolo/sdk';
3
3
 
4
4
  /**
5
5
  * Hosted, multi-tenant MCP Streamable HTTP transport for the Topolo platform.
@@ -18,9 +18,11 @@ import { TopoloCredential, Topolo } from '@topolo/sdk';
18
18
  * Mcp-Session-Id continuity, GET SSE stream, DELETE to terminate) over pure
19
19
  * Web-Standard Request/Response — so it runs unchanged in a Cloudflare Worker.
20
20
  */
21
- interface TopoloMcpHttpOptions {
21
+ interface TopoloMcpHttpInternalOptions {
22
22
  /** Path the MCP endpoint is mounted at. Defaults to '/mcp'. */
23
23
  path?: string;
24
+ /** Effective Topolo environment. Defaults to production and is always surfaced to the MCP client. */
25
+ environment?: TopoloRuntimeEnvironment;
24
26
  /** Per-service URL overrides (e.g. staging). Passed through to createTopolo. */
25
27
  serviceUrls?: Record<string, string>;
26
28
  /** Per-service TopoloAuth app-id overrides. Passed through to createTopolo. */
@@ -52,12 +54,33 @@ interface McpSession {
52
54
  * const handler = createTopoloMcpHttpHandler();
53
55
  * export default { fetch: handler.fetch };
54
56
  */
55
- declare function createTopoloMcpHttpHandler(options?: TopoloMcpHttpOptions): {
57
+ declare function createTopoloMcpHttpHandlerInternal(options?: TopoloMcpHttpInternalOptions): {
56
58
  /** Cloudflare Worker / fetch-compatible entrypoint. */
57
59
  fetch: (request: Request) => Promise<Response>;
58
60
  /** Exposed for tests/introspection. */
59
61
  sessions: Map<string, McpSession>;
60
62
  };
63
+ type TopoloMcpHttpHandlerInternal = ReturnType<typeof createTopoloMcpHttpHandlerInternal>;
64
+
65
+ interface TopoloMcpHttpOptions {
66
+ /** Path the MCP endpoint is mounted at. Defaults to '/mcp'. */
67
+ path?: string;
68
+ /** Effective Topolo environment. Defaults to production and is always surfaced to the MCP client. */
69
+ environment?: TopoloRuntimeEnvironment;
70
+ /** Per-service URL overrides (e.g. staging). Passed through to createTopolo. */
71
+ serviceUrls?: Record<string, string>;
72
+ /** Per-service TopoloAuth app-id overrides. Passed through to createTopolo. */
73
+ appIds?: Record<string, string>;
74
+ /** Human-readable agent label for audit logs (forwarded to the SDK). */
75
+ agentName?: string;
76
+ /** Validated network transport for the SDK client. Defaults to global fetch. */
77
+ fetch?: typeof fetch;
78
+ }
79
+ /**
80
+ * Create the public hosted MCP handler. The SDK client is always constructed
81
+ * here from the validated effective environment and per-request credential.
82
+ */
83
+ declare function createTopoloMcpHttpHandler(options?: TopoloMcpHttpOptions): TopoloMcpHttpHandlerInternal;
61
84
  type TopoloMcpHttpHandler = ReturnType<typeof createTopoloMcpHttpHandler>;
62
85
 
63
86
  export { type TopoloMcpHttpHandler, type TopoloMcpHttpOptions, createTopoloMcpHttpHandler };