@muxoai/sdk 1.3.0 → 1.4.2

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.
Files changed (72) hide show
  1. package/.agents/plugins/marketplace.json +2 -2
  2. package/.claude-plugin/marketplace.json +19 -4
  3. package/.codex/config.toml +9 -2
  4. package/ARCHITECTURE.md +16 -6
  5. package/README.md +69 -24
  6. package/dist/clerk.d.ts +35 -0
  7. package/dist/clerk.js +201 -0
  8. package/dist/cli.js +1589 -103
  9. package/dist/composio-catalog.d.ts +234 -0
  10. package/dist/composio-catalog.js +1894 -0
  11. package/dist/config.d.ts +16 -0
  12. package/dist/config.js +27 -1
  13. package/dist/durable-workflow.d.ts +45 -0
  14. package/dist/durable-workflow.js +90 -0
  15. package/dist/engine.d.ts +315 -6
  16. package/dist/engine.js +1778 -94
  17. package/dist/mcp-schema.d.ts +286 -0
  18. package/dist/mcp-schema.js +2559 -0
  19. package/dist/mcp.d.ts +2 -25
  20. package/dist/mcp.js +949 -507
  21. package/dist/memory-graph.d.ts +21 -0
  22. package/dist/memory-graph.js +173 -0
  23. package/dist/nl.js +214 -35
  24. package/dist/oauth.d.ts +32 -0
  25. package/dist/oauth.js +134 -0
  26. package/dist/policy.d.ts +190 -0
  27. package/dist/policy.js +1597 -0
  28. package/dist/providers/composio-instant.d.ts +4 -0
  29. package/dist/providers/composio-instant.js +890 -535
  30. package/dist/providers/composio-sdk.d.ts +126 -5
  31. package/dist/providers/composio-sdk.js +902 -79
  32. package/dist/providers/microsoft-governance.d.ts +89 -3
  33. package/dist/providers/microsoft-governance.js +673 -26
  34. package/dist/providers/stripe-billing.d.ts +42 -0
  35. package/dist/providers/stripe-billing.js +244 -5
  36. package/dist/providers/stripe-projects.d.ts +459 -4
  37. package/dist/providers/stripe-projects.js +2674 -122
  38. package/dist/providers/supermemory.d.ts +102 -6
  39. package/dist/providers/supermemory.js +609 -55
  40. package/dist/provisioning-managed.d.ts +50 -0
  41. package/dist/provisioning-managed.js +155 -0
  42. package/dist/sdk.d.ts +705 -7
  43. package/dist/sdk.js +488 -10
  44. package/dist/server.js +2646 -348
  45. package/dist/store.d.ts +138 -6
  46. package/dist/store.js +932 -58
  47. package/dist/types.d.ts +312 -4
  48. package/dist/ui/console-html.d.ts +62 -0
  49. package/dist/ui/console-html.js +3742 -2228
  50. package/dist/ui/design-tokens.d.ts +177 -0
  51. package/dist/ui/design-tokens.js +210 -0
  52. package/dist/version.d.ts +1 -0
  53. package/dist/version.js +1 -0
  54. package/package.json +5 -4
  55. package/plugins/muxo/.app.json +1 -1
  56. package/plugins/muxo/.claude-plugin/plugin.json +3 -3
  57. package/plugins/muxo/.codex-plugin/plugin.json +19 -10
  58. package/plugins/muxo/.cursor-plugin/plugin.json +30 -0
  59. package/plugins/muxo/.mcp.json +1 -33
  60. package/plugins/muxo/assets/logo.png +0 -0
  61. package/plugins/muxo/hooks/session-start.sh +16 -4
  62. package/plugins/muxo/hooks/user-prompt-submit.sh +14 -1
  63. package/plugins/muxo/mcp.json +0 -10
  64. package/plugins/muxo/plugin.json +65 -8
  65. package/plugins/muxo/skills/muxo/SKILL.md +142 -14
  66. package/plugins/muxo/skills/muxo/agents/openai.yaml +12 -0
  67. package/plugins/muxo/skills/muxo/references/cli.md +9 -3
  68. package/plugins/muxo/skills/muxo/references/mcp.md +22 -10
  69. package/plugins/muxo/skills/muxo-activity-summary/SKILL.md +81 -0
  70. package/plugins/muxo/skills/setup/SKILL.md +17 -3
  71. package/plugins/muxo/skills/setup/agents/openai.yaml +12 -0
  72. package/src/catalogues/stripe-projects-catalog.json +140 -0
package/dist/mcp.js CHANGED
@@ -2,474 +2,9 @@ import crypto from "node:crypto";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { ROOT_DIR } from "./config.js";
5
- /**
6
- * Concise server instructions (<512 chars) per OpenAI Plugin MCP Server specification:
7
- * https://developers.openai.com/plugins/build/mcp-server
8
- */
9
- export const MUXO_MCP_SERVER_INSTRUCTIONS = "Muxo governs SaaS actions (Composio app.*), Instant tools (instant.*), Cloud Infrastructure (Stripe Projects resource.*), Supermemory v5 recall, and Microsoft Agent Governance Ed25519 receipts. Workflow: 1) search_tools & inspect_tool. 2) plan_action to get a plan_*. 3) If authHandoff.required is true, show redirectUrl and call wait_for_connection. 4) Execute via the matching risk tool (execute_read/write/admin/financial/provisioning/destructive). 5) Verify via get_receipt.";
10
- export const MUXO_MCP_TOOLS = [
11
- {
12
- name: "get_profile",
13
- title: "Get Authenticated Profile",
14
- description: "Get the authenticated actor profile, user ID, email, workspace ID, and subscription tier.",
15
- inputSchema: {
16
- type: "object",
17
- properties: {},
18
- additionalProperties: false,
19
- },
20
- outputSchema: {
21
- type: "object",
22
- properties: {
23
- id: { type: "string", description: "Unique user identifier" },
24
- name: { type: "string", description: "Display name" },
25
- email: { type: "string", description: "Email address" },
26
- workspaceId: { type: "string", description: "Active workspace ID" },
27
- workspaceName: { type: "string", description: "Active workspace name" },
28
- tier: { type: "string", description: "Workspace subscription tier" },
29
- },
30
- required: ["id"],
31
- },
32
- annotations: {
33
- readOnlyHint: true,
34
- destructiveHint: false,
35
- openWorldHint: false,
36
- },
37
- _meta: {
38
- "openai/profile": true,
39
- },
40
- },
41
- {
42
- name: "get_organization",
43
- title: "Get Organization & Billing Summary",
44
- description: "Get workspace governance policy, monthly action usage, credit balance, Merchant-of-Record supplier settlement summary, and active connection/resource counts.",
45
- inputSchema: {
46
- type: "object",
47
- properties: {},
48
- additionalProperties: false,
49
- },
50
- annotations: {
51
- readOnlyHint: true,
52
- destructiveHint: false,
53
- openWorldHint: false,
54
- },
55
- },
56
- {
57
- name: "search_tools",
58
- title: "Search Unified Tool Catalog",
59
- description: "Search the unified Muxo catalog across Connected Apps (Composio SDK: app.*), Instant Tools (Composio Instant: instant.*), and Cloud Infrastructure (Stripe Projects: resource.*).",
60
- inputSchema: {
61
- type: "object",
62
- properties: {
63
- query: {
64
- type: "string",
65
- description: "Search keywords (e.g. 'postgres', 'github issue', 'web search', 'seo audit', 'redis')",
66
- },
67
- lane: {
68
- type: "string",
69
- enum: ["all", "composio_sdk", "composio_instant", "stripe_projects"],
70
- default: "all",
71
- },
72
- risk_level: {
73
- type: "string",
74
- enum: [
75
- "read",
76
- "write",
77
- "admin",
78
- "financial",
79
- "provisioning",
80
- "destructive",
81
- ],
82
- },
83
- limit: { type: "number", default: 20 },
84
- },
85
- additionalProperties: false,
86
- },
87
- annotations: {
88
- readOnlyHint: true,
89
- destructiveHint: false,
90
- openWorldHint: true,
91
- },
92
- },
93
- {
94
- name: "inspect_tool",
95
- title: "Inspect Tool Schema & Risk",
96
- description: "Inspect a tool's full input JSON schema, risk classification, provider lane, LLM context URL, and credit cost before planning.",
97
- inputSchema: {
98
- type: "object",
99
- required: ["tool_slug"],
100
- properties: {
101
- tool_slug: {
102
- type: "string",
103
- description: "Canonical Muxo tool slug (e.g. 'instant.seo.audit', 'app.gmail.send_email', or 'resource.turso.database')",
104
- },
105
- },
106
- additionalProperties: false,
107
- },
108
- annotations: {
109
- readOnlyHint: true,
110
- destructiveHint: false,
111
- openWorldHint: false,
112
- },
113
- },
114
- {
115
- name: "connection_status",
116
- title: "Check Connection Status",
117
- description: "Check connection status across Composio OAuth apps, Instant wallet, and linked Stripe Projects cloud providers.",
118
- inputSchema: {
119
- type: "object",
120
- properties: {
121
- provider: {
122
- type: "string",
123
- description: "Optional provider filter (e.g. 'github', 'gmail', 'slack', 'neon', 'turso')",
124
- },
125
- sync_live: {
126
- type: "boolean",
127
- default: true,
128
- description: "Whether to sync live status from upstream Composio and Stripe Projects",
129
- },
130
- },
131
- additionalProperties: false,
132
- },
133
- annotations: {
134
- readOnlyHint: true,
135
- destructiveHint: false,
136
- openWorldHint: true,
137
- },
138
- },
139
- {
140
- name: "start_connection",
141
- title: "Start OAuth Connection Handoff",
142
- description: "Initiate a managed OAuth connection handoff for a Connected App (Composio) or link a cloud provider (Stripe Projects).",
143
- inputSchema: {
144
- type: "object",
145
- required: ["provider"],
146
- properties: {
147
- provider: {
148
- type: "string",
149
- description: "Provider or toolkit slug (e.g. 'github', 'gmail', 'slack', 'neon')",
150
- },
151
- lane: {
152
- type: "string",
153
- enum: ["composio_sdk", "stripe_projects"],
154
- description: "Provider lane (defaults to composio_sdk unless prefixed with resource.)",
155
- },
156
- callback_url: {
157
- type: "string",
158
- description: "Optional OAuth callback URL",
159
- },
160
- },
161
- additionalProperties: false,
162
- },
163
- annotations: {
164
- readOnlyHint: false,
165
- destructiveHint: false,
166
- openWorldHint: true,
167
- },
168
- },
169
- {
170
- name: "wait_for_connection",
171
- title: "Wait for OAuth Connection Handoff",
172
- description: "Poll and wait for an external user's pending OAuth connection handoff to become active before resuming a planned operation.",
173
- inputSchema: {
174
- type: "object",
175
- required: ["provider"],
176
- properties: {
177
- provider: {
178
- type: "string",
179
- description: "Provider or toolkit slug (e.g. 'github', 'gmail', 'slack', 'notion', 'linear')",
180
- },
181
- timeout_seconds: {
182
- type: "number",
183
- default: 15,
184
- description: "Maximum seconds to poll for OAuth completion (0-120, default 15)",
185
- },
186
- },
187
- additionalProperties: false,
188
- },
189
- annotations: {
190
- readOnlyHint: true,
191
- destructiveHint: false,
192
- openWorldHint: true,
193
- },
194
- },
195
- {
196
- name: "plan_action",
197
- title: "Create Governed Action Plan",
198
- description: "Create a governed execution plan (plan_*) for any tool, billing operation, or infrastructure provisioning operation. Accepts either an exact tool_slug (e.g. 'instant.seo.audit', 'billing.credits.topup', 'resource.turso.database') or a natural-language instruction (e.g. 'audit seo for https://muxo.ai'). Evaluates workspace policy, risk level, Supermemory v5 recall, Ed25519 signature, BYOK vs Muxo-funded mode, and credit balance.",
199
- inputSchema: {
200
- type: "object",
201
- required: ["tool_slug"],
202
- properties: {
203
- tool_slug: {
204
- type: "string",
205
- description: "Muxo tool slug (e.g. 'instant.seo.audit', 'billing.credits.topup') or natural-language request",
206
- },
207
- input: {
208
- type: "object",
209
- description: "Arguments matching the tool's inputSchema (auto-extracted when tool_slug is natural language)",
210
- },
211
- reason: {
212
- type: "string",
213
- description: "Audit reason explaining why this action is being planned",
214
- },
215
- },
216
- additionalProperties: false,
217
- },
218
- annotations: {
219
- readOnlyHint: false,
220
- destructiveHint: false,
221
- openWorldHint: false,
222
- },
223
- },
224
- {
225
- name: "get_plan",
226
- title: "Get Action Plan",
227
- description: "Inspect the status, risk level, governance decision record, and approval state of a planned action.",
228
- inputSchema: {
229
- type: "object",
230
- required: ["plan_id"],
231
- properties: {
232
- plan_id: { type: "string", description: "Plan ID (plan_*)" },
233
- },
234
- additionalProperties: false,
235
- },
236
- annotations: {
237
- readOnlyHint: true,
238
- destructiveHint: false,
239
- openWorldHint: false,
240
- },
241
- },
242
- {
243
- name: "get_run_context",
244
- title: "Get Workspace Context & Memory",
245
- description: "Get the workspace runtime context, Supermemory v5 contextual brain (static/dynamic profile + hybrid search recall), Microsoft Agent Governance status, active provisioned Stripe Projects resources, and redacted environment variable keys.",
246
- inputSchema: {
247
- type: "object",
248
- properties: {
249
- query: {
250
- type: "string",
251
- description: "Optional semantic search query to recall relevant workspace memories from Supermemory v5",
252
- },
253
- },
254
- additionalProperties: false,
255
- },
256
- annotations: {
257
- readOnlyHint: true,
258
- destructiveHint: false,
259
- openWorldHint: false,
260
- },
261
- },
262
- {
263
- name: "execute_read",
264
- title: "Execute Read Plan",
265
- description: "Execute an approved plan with riskLevel = 'read'.",
266
- inputSchema: {
267
- type: "object",
268
- required: ["plan_id"],
269
- properties: {
270
- plan_id: { type: "string", description: "Plan ID (plan_*)" },
271
- },
272
- additionalProperties: false,
273
- },
274
- annotations: {
275
- readOnlyHint: true,
276
- destructiveHint: false,
277
- openWorldHint: true,
278
- },
279
- },
280
- {
281
- name: "execute_write",
282
- title: "Execute Write Plan",
283
- description: "Execute an approved plan with riskLevel = 'write'.",
284
- inputSchema: {
285
- type: "object",
286
- required: ["plan_id"],
287
- properties: {
288
- plan_id: { type: "string", description: "Plan ID (plan_*)" },
289
- },
290
- additionalProperties: false,
291
- },
292
- annotations: {
293
- readOnlyHint: false,
294
- destructiveHint: false,
295
- openWorldHint: true,
296
- },
297
- },
298
- {
299
- name: "execute_admin",
300
- title: "Execute Admin Plan",
301
- description: "Execute an approved plan with riskLevel = 'admin'.",
302
- inputSchema: {
303
- type: "object",
304
- required: ["plan_id"],
305
- properties: {
306
- plan_id: { type: "string", description: "Plan ID (plan_*)" },
307
- },
308
- additionalProperties: false,
309
- },
310
- annotations: {
311
- readOnlyHint: false,
312
- destructiveHint: false,
313
- openWorldHint: true,
314
- },
315
- },
316
- {
317
- name: "execute_financial",
318
- title: "Execute Financial Plan",
319
- description: "Execute an approved plan with riskLevel = 'financial'.",
320
- inputSchema: {
321
- type: "object",
322
- required: ["plan_id"],
323
- properties: {
324
- plan_id: { type: "string", description: "Plan ID (plan_*)" },
325
- },
326
- additionalProperties: false,
327
- },
328
- annotations: {
329
- readOnlyHint: false,
330
- destructiveHint: false,
331
- openWorldHint: true,
332
- },
333
- },
334
- {
335
- name: "execute_provisioning",
336
- title: "Execute Infrastructure Provisioning Plan",
337
- description: "Execute an approved infrastructure provisioning plan with riskLevel = 'provisioning' via Stripe Projects.",
338
- inputSchema: {
339
- type: "object",
340
- required: ["plan_id"],
341
- properties: {
342
- plan_id: { type: "string", description: "Plan ID (plan_*)" },
343
- },
344
- additionalProperties: false,
345
- },
346
- annotations: {
347
- readOnlyHint: false,
348
- destructiveHint: false,
349
- openWorldHint: true,
350
- },
351
- },
352
- {
353
- name: "execute_destructive",
354
- title: "Execute Destructive Plan",
355
- description: "Execute an approved plan with riskLevel = 'destructive'.",
356
- inputSchema: {
357
- type: "object",
358
- required: ["plan_id"],
359
- properties: {
360
- plan_id: { type: "string", description: "Plan ID (plan_*)" },
361
- },
362
- additionalProperties: false,
363
- },
364
- annotations: {
365
- readOnlyHint: false,
366
- destructiveHint: true,
367
- openWorldHint: true,
368
- },
369
- },
370
- {
371
- name: "get_run",
372
- title: "Get Execution Run",
373
- description: "Get the execution status, output, duration, and metered cost of a run (run_*).",
374
- inputSchema: {
375
- type: "object",
376
- required: ["run_id"],
377
- properties: {
378
- run_id: { type: "string", description: "Run ID (run_*)" },
379
- },
380
- additionalProperties: false,
381
- },
382
- annotations: {
383
- readOnlyHint: true,
384
- destructiveHint: false,
385
- openWorldHint: false,
386
- },
387
- },
388
- {
389
- name: "cancel_run",
390
- title: "Cancel Execution Run",
391
- description: "Cancel an in-progress run and issue a cancellation receipt.",
392
- inputSchema: {
393
- type: "object",
394
- required: ["run_id"],
395
- properties: {
396
- run_id: { type: "string", description: "Run ID (run_*)" },
397
- },
398
- additionalProperties: false,
399
- },
400
- annotations: {
401
- readOnlyHint: false,
402
- destructiveHint: true,
403
- openWorldHint: false,
404
- },
405
- },
406
- {
407
- name: "get_receipt",
408
- title: "Verify Execution Receipt",
409
- description: "Fetch and cryptographically verify the HMAC-SHA256 + Ed25519 chained execution receipt (rcpt_*) for a run.",
410
- inputSchema: {
411
- type: "object",
412
- required: ["receipt_id"],
413
- properties: {
414
- receipt_id: {
415
- type: "string",
416
- description: "Receipt ID (rcpt_*) or Run ID (run_*)",
417
- },
418
- },
419
- additionalProperties: false,
420
- },
421
- annotations: {
422
- readOnlyHint: true,
423
- destructiveHint: false,
424
- openWorldHint: false,
425
- },
426
- },
427
- ];
428
- /**
429
- * OpenAI Company Knowledge standard `search` and `fetch` tool definitions
430
- * per https://developers.openai.com/plugins/build/mcp-server#company-knowledge-compatibility
431
- */
432
- export const OPENAI_COMPANY_KNOWLEDGE_TOOLS = [
433
- {
434
- name: "search",
435
- title: "Search Muxo Tools & Workspace Memory",
436
- description: "Search across Muxo tools, provisioned cloud resources, and Supermemory v5 workspace knowledge.",
437
- inputSchema: {
438
- type: "object",
439
- required: ["query"],
440
- properties: {
441
- query: { type: "string", description: "Search query string." },
442
- },
443
- additionalProperties: false,
444
- },
445
- annotations: {
446
- readOnlyHint: true,
447
- destructiveHint: false,
448
- openWorldHint: false,
449
- },
450
- },
451
- {
452
- name: "fetch",
453
- title: "Fetch Muxo Tool or Memory Record",
454
- description: "Retrieve complete details for a Muxo tool, resource, or workspace memory record by ID.",
455
- inputSchema: {
456
- type: "object",
457
- required: ["id"],
458
- properties: {
459
- id: {
460
- type: "string",
461
- description: "Identifier returned by search (e.g. 'tool:instant.seo.audit' or 'memory:mem_123').",
462
- },
463
- },
464
- additionalProperties: false,
465
- },
466
- annotations: {
467
- readOnlyHint: true,
468
- destructiveHint: false,
469
- openWorldHint: false,
470
- },
471
- },
472
- ];
5
+ import { APPROVED_PLAN_STATUSES, DEFAULT_LEGACY_MCP_PROTOCOL_VERSION, DEFAULT_TOOL_SECURITY_SCHEMES, LATEST_MCP_PROTOCOL_VERSION, MCP_ERR_HEADER_MISMATCH, MCP_ERR_MISSING_REQUIRED_CLIENT_CAPABILITY, MCP_ERR_UNSUPPORTED_PROTOCOL_VERSION, MUXO_MCP_RESOURCE_TEMPLATES, MUXO_MCP_SERVER_INSTRUCTIONS, MUXO_MCP_TOOLS, MUXO_UI_MCP_APP_URI, MUXO_UI_RESOURCES, MUXO_UI_WIDGET_URI, OPENAI_COMPANY_KNOWLEDGE_TOOLS, PUBLIC_MCP_TOOL_NAMES, PUBLIC_TOOL_SECURITY_SCHEMES, SUPPORTED_MCP_PROTOCOL_VERSIONS, UI_RENDERED_MCP_TOOL_NAMES, attachMcpHarnessGuidance, MuxoToolError, buildApprovalUrl, buildMcpDiscoverResult, buildMcpErrorResultMeta, buildMcpToolDescriptor, buildMcpToolResultMeta, buildOnboardTeamGuide, clampWaitSeconds, completeMcpArgument, decodeMcpHeaderValue, errorPayloadFrom, extractOpenAiClientMeta, findMcpSkill, isSupportedMcpProtocolVersion, renderMuxoUiWidgetHtml, securitySchemesForTool, validateMcpHttpHeadersAndMeta, } from "./mcp-schema.js";
6
+ import { MUXO_VERSION } from "./version.js";
7
+ export { DEFAULT_LEGACY_MCP_PROTOCOL_VERSION, DEFAULT_TOOL_SECURITY_SCHEMES, LATEST_MCP_PROTOCOL_VERSION, MCP_ERR_HEADER_MISMATCH, MCP_ERR_MISSING_REQUIRED_CLIENT_CAPABILITY, MCP_ERR_UNSUPPORTED_PROTOCOL_VERSION, MUXO_MCP_RESOURCE_TEMPLATES, MUXO_MCP_SERVER_INSTRUCTIONS, MUXO_MCP_TOOLS, MUXO_UI_MCP_APP_URI, MUXO_UI_RESOURCES, MUXO_UI_WIDGET_URI, OPENAI_COMPANY_KNOWLEDGE_TOOLS, PUBLIC_MCP_TOOL_NAMES, PUBLIC_TOOL_SECURITY_SCHEMES, SUPPORTED_MCP_PROTOCOL_VERSIONS, UI_RENDERED_MCP_TOOL_NAMES, attachMcpHarnessGuidance, buildMcpDiscoverResult, buildMcpErrorResultMeta, buildMcpToolDescriptor, buildMcpToolResultMeta, completeMcpArgument, decodeMcpHeaderValue, extractOpenAiClientMeta, isSupportedMcpProtocolVersion, renderMuxoUiWidgetHtml, securitySchemesForTool, validateMcpHttpHeadersAndMeta, };
473
8
  function sha256Digest(content) {
474
9
  const hash = crypto
475
10
  .createHash("sha256")
@@ -508,7 +43,7 @@ function readSkillFileOrDefault(relPath, fallback) {
508
43
  export function getMuxoMcpSkills() {
509
44
  const muxoSkillMd = readSkillFileOrDefault("muxo/SKILL.md", `---
510
45
  name: muxo
511
- description: Route governed Muxo work between the hosted MCP-backed app and the local Muxo CLI across Connected Apps (Composio), Instant Tools, Cloud Infrastructure (Stripe Projects), Supermemory v5, and Microsoft Agent Governance.
46
+ description: Route governed Muxo work between the hosted MCP-backed app and the local Muxo CLI across Muxo Connected Apps, Instant Tools, Cloud Infrastructure (Stripe Projects), Supermemory v5, and Microsoft Agent Governance.
512
47
  ---
513
48
 
514
49
  # Muxo
@@ -526,6 +61,8 @@ description: Guided onboarding skill for setting up the Muxo plugin in OpenAI Ch
526
61
 
527
62
  Call \`get_profile\` and \`get_organization\` to verify your workspace connection, or run \`npx -y @muxoai/cli@latest login --signup\` in a terminal.
528
63
  `);
64
+ const muxoOpenaiYaml = readSkillFileOrDefault("muxo/agents/openai.yaml", `interface:\n display_name: "Muxo"\n short_description: "Governed SaaS, Instant Web/SEO tools, Cloud Infrastructure, and Workspace Memory"\n default_prompt: "Audit https://muxo.ai for technical SEO and crawl its top pages."\n\ndependencies:\n tools:\n - type: "mcp"\n value: "muxo"\n description: "Muxo Governed Execution, Instant Web/SEO Tools, Connected Apps, and Cloud Infrastructure MCP Server"\n transport: "streamable_http"\n url: "https://api.muxo.ai/mcp"\n`);
65
+ const setupOpenaiYaml = readSkillFileOrDefault("setup/agents/openai.yaml", `interface:\n display_name: "Muxo Setup"\n short_description: "Guided onboarding and connection verification for Muxo in ChatGPT and Codex"\n default_prompt: "Check my Muxo profile and organization status."\n\ndependencies:\n tools:\n - type: "mcp"\n value: "muxo"\n description: "Muxo Governed Execution, Instant Web/SEO Tools, Connected Apps, and Cloud Infrastructure MCP Server"\n transport: "streamable_http"\n url: "https://api.muxo.ai/mcp"\n`);
529
66
  const muxoFm = parseFrontmatter(muxoSkillMd);
530
67
  const setupFm = parseFrontmatter(setupSkillMd);
531
68
  const muxoFiles = [
@@ -537,6 +74,14 @@ Call \`get_profile\` and \`get_organization\` to verify your workspace connectio
537
74
  mimeType: "text/markdown",
538
75
  content: muxoSkillMd,
539
76
  },
77
+ {
78
+ path: "agents/openai.yaml",
79
+ uri: "skill://muxo/muxo/agents/openai.yaml",
80
+ size: Buffer.byteLength(muxoOpenaiYaml, "utf8"),
81
+ digest: sha256Digest(muxoOpenaiYaml),
82
+ mimeType: "application/yaml",
83
+ content: muxoOpenaiYaml,
84
+ },
540
85
  {
541
86
  path: "references/cli.md",
542
87
  uri: "skill://muxo/muxo/references/cli.md",
@@ -563,6 +108,14 @@ Call \`get_profile\` and \`get_organization\` to verify your workspace connectio
563
108
  mimeType: "text/markdown",
564
109
  content: setupSkillMd,
565
110
  },
111
+ {
112
+ path: "agents/openai.yaml",
113
+ uri: "skill://muxo/setup/agents/openai.yaml",
114
+ size: Buffer.byteLength(setupOpenaiYaml, "utf8"),
115
+ digest: sha256Digest(setupOpenaiYaml),
116
+ mimeType: "application/yaml",
117
+ content: setupOpenaiYaml,
118
+ },
566
119
  ];
567
120
  const muxoName = muxoFm.name || "muxo";
568
121
  const muxoDesc = muxoFm.description ||
@@ -615,18 +168,22 @@ export async function dispatchMcpToolCall(engine, ctx, toolName, args = {}) {
615
168
  provider: args.provider ? String(args.provider) : undefined,
616
169
  syncLive: args.sync_live !== false,
617
170
  });
618
- case "start_connection":
619
- return engine.startConnection(ctx, {
171
+ case "start_connection": {
172
+ const conn = await engine.startConnection(ctx, {
620
173
  provider: String(args.provider || ""),
621
174
  lane: args.lane,
622
175
  callbackUrl: args.callback_url ? String(args.callback_url) : undefined,
623
176
  });
177
+ return {
178
+ ok: true,
179
+ ...conn,
180
+ connection: conn,
181
+ };
182
+ }
624
183
  case "wait_for_connection":
625
184
  return engine.waitForConnection(ctx, {
626
185
  provider: String(args.provider || ""),
627
- timeoutSeconds: args.timeout_seconds !== undefined
628
- ? Number(args.timeout_seconds)
629
- : 15,
186
+ timeoutSeconds: clampWaitSeconds(args.timeout_seconds),
630
187
  });
631
188
  case "plan_action":
632
189
  return engine.planAction(ctx, {
@@ -640,9 +197,157 @@ export async function dispatchMcpToolCall(engine, ctx, toolName, args = {}) {
640
197
  reason: args.reason ? String(args.reason) : undefined,
641
198
  });
642
199
  case "get_plan":
643
- return engine.getPlan(ctx, String(args.plan_id || ""));
644
- case "get_run_context":
645
- return engine.getRunContext(ctx, args.query ? String(args.query) : undefined);
200
+ if (args.wait_for_approval === true || args.wait === true) {
201
+ return engine.waitForPlanApproval(ctx, {
202
+ planId: String(args.plan_id || ""),
203
+ timeoutSeconds: clampWaitSeconds(args.timeout_seconds, 15, 60),
204
+ });
205
+ }
206
+ {
207
+ const plan = engine.getPlan(ctx, String(args.plan_id || ""));
208
+ return {
209
+ ok: true,
210
+ approved: APPROVED_PLAN_STATUSES.has(plan.approvalStatus),
211
+ timedOut: false,
212
+ plan,
213
+ approvalStatus: plan.approvalStatus,
214
+ approvalUrl: buildApprovalUrl(engine.config.baseUrl, plan.id),
215
+ };
216
+ }
217
+ case "get_run_context": {
218
+ const action = String(args.action || "").trim().toLowerCase();
219
+ const prompt = String(args.prompt || "").trim();
220
+ const query = args.query ? String(args.query) : undefined;
221
+ const rawParamRules = Array.isArray(args.parameter_rules)
222
+ ? args.parameter_rules
223
+ : Array.isArray(args.parameterRules)
224
+ ? args.parameterRules
225
+ : undefined;
226
+ if (action === "memory_graph") {
227
+ return engine.getMemoryGraph(ctx, query);
228
+ }
229
+ if (action === "governance_status") {
230
+ return engine.getGovernanceOverview(ctx);
231
+ }
232
+ if (action === "list_workspaces") {
233
+ const workspaces = engine.store.listUserWorkspaces(ctx.user.id, ctx.workspace.id);
234
+ return {
235
+ ok: true,
236
+ action,
237
+ currentWorkspaceId: ctx.workspace.id,
238
+ activeWorkspace: workspaces.find((w) => w.id === ctx.workspace.id) || {
239
+ id: ctx.workspace.id,
240
+ name: ctx.workspace.name,
241
+ slug: ctx.workspace.slug,
242
+ tier: ctx.workspace.tier,
243
+ },
244
+ workspaces,
245
+ };
246
+ }
247
+ if (action === "switch_workspace") {
248
+ const targetWsId = String(args.workspace_id || query || prompt || "").trim();
249
+ if (!targetWsId) {
250
+ throw new Error("workspace_id is required when action='switch_workspace'");
251
+ }
252
+ const switched = engine.store.switchUserWorkspace(ctx.user.id, targetWsId);
253
+ if (!switched) {
254
+ throw new Error(`Workspace ${targetWsId} not found or not linked to your account. Call get_run_context with action='list_workspaces' to see accessible workspaces.`);
255
+ }
256
+ return {
257
+ ok: true,
258
+ action,
259
+ switched: true,
260
+ workspaceId: switched.workspace.id,
261
+ workspace: switched.workspace,
262
+ workspaces: engine.store.listUserWorkspaces(ctx.user.id, switched.workspace.id),
263
+ message: `Active workspace for your session is now ${switched.workspace.name} (${switched.workspace.id}). API keys stay bound to their own workspace; use a key minted for ${switched.workspace.id} to target it over MCP.`,
264
+ };
265
+ }
266
+ if (action === "onboard_team") {
267
+ return buildOnboardTeamGuide({
268
+ baseUrl: engine.config.baseUrl,
269
+ workspaceId: ctx.workspace.id,
270
+ workspaceName: ctx.workspace.name,
271
+ teamName: String(args.team_name || args.teamName || query || prompt || "").trim(),
272
+ workspaces: engine.store.listUserWorkspaces(ctx.user.id, ctx.workspace.id),
273
+ });
274
+ }
275
+ if (action === "set_guardrail" &&
276
+ (prompt || (rawParamRules && rawParamRules.length > 0))) {
277
+ return engine.applyNaturalLanguageGuardrail(ctx, prompt, {
278
+ parameterRules: rawParamRules,
279
+ source: rawParamRules ? "mcp_harness" : "deterministic",
280
+ });
281
+ }
282
+ if (action === "reset_guardrails") {
283
+ return engine.resetWorkspaceGuardrails(ctx);
284
+ }
285
+ if (action === "check_policy" || action === "simulate_policy") {
286
+ const toolSlug = String(args.tool_slug || args.slug || args.tool_id || query || prompt || "instant.web.search").trim();
287
+ const input = (args.input || args.arguments) || {};
288
+ return engine.checkToolPolicy(ctx, { toolSlug, input });
289
+ }
290
+ if (action === "kill_switch") {
291
+ const enabled = typeof args.enabled === "boolean"
292
+ ? args.enabled
293
+ : typeof args.active === "boolean"
294
+ ? args.active
295
+ : !/\b(resume|unpause|disable|off|false)\b/i.test(prompt || query || "");
296
+ const reason = prompt ||
297
+ query ||
298
+ (enabled ? "Paused via MCP get_run_context" : undefined);
299
+ const updated = engine.setKillSwitch(ctx, enabled, reason);
300
+ const govOverview = engine.getGovernanceOverview(ctx);
301
+ return {
302
+ ok: true,
303
+ action: "kill_switch",
304
+ killSwitchActive: Boolean(updated.policy.killSwitchActive),
305
+ killSwitchReason: updated.policy.killSwitchReason || null,
306
+ policy: updated.policy,
307
+ llmPolicyBrief: govOverview.llmPolicyBrief,
308
+ explanation: govOverview.explanation,
309
+ };
310
+ }
311
+ if (action === "scan_context") {
312
+ const textToScan = String(args.content || prompt || query || "");
313
+ return engine.scanForContextPoisoning(ctx.workspace.id, textToScan);
314
+ }
315
+ if (action === "forget") {
316
+ if (!(query || prompt)) {
317
+ throw new Error("query is required when action='forget'");
318
+ }
319
+ return engine.forgetWorkspaceMemoryMatching(ctx, query || prompt);
320
+ }
321
+ if (action === "recall") {
322
+ return engine.getMemoryOverview(ctx, query);
323
+ }
324
+ if (action === "remember") {
325
+ if (prompt && !args.content) {
326
+ return engine.doNaturalLanguage(ctx, { prompt });
327
+ }
328
+ const record = await engine.addWorkspaceMemory(ctx, {
329
+ title: String(args.title || prompt.slice(0, 60) || "Workspace Fact"),
330
+ content: String(args.content || prompt || query || ""),
331
+ kind: "fact",
332
+ });
333
+ const overview = await engine.getMemoryOverview(ctx);
334
+ return {
335
+ ok: true,
336
+ memory: record,
337
+ activeDefaults: overview.activeDefaults,
338
+ explanation: overview.explanation,
339
+ };
340
+ }
341
+ if (prompt && !action) {
342
+ return engine.doNaturalLanguage(ctx, { prompt });
343
+ }
344
+ const runCtx = await engine.getRunContext(ctx, query);
345
+ if (args.include_graph === true) {
346
+ const memoryGraph = await engine.getMemoryGraph(ctx, query);
347
+ return { ...runCtx, memoryGraph };
348
+ }
349
+ return runCtx;
350
+ }
646
351
  case "execute_read":
647
352
  return engine.executePlanForRisk(ctx, String(args.plan_id || ""), "read");
648
353
  case "execute_write":
@@ -658,9 +363,125 @@ export async function dispatchMcpToolCall(engine, ctx, toolName, args = {}) {
658
363
  case "get_run":
659
364
  return engine.getRun(ctx, String(args.run_id || ""));
660
365
  case "cancel_run":
661
- return engine.cancelRun(ctx, String(args.run_id || ""));
662
- case "get_receipt":
663
- return engine.getReceipt(ctx, String(args.receipt_id || args.run_id || ""));
366
+ return engine.cancelRun(ctx, String(args.run_id || ""), args.reason ? String(args.reason) : undefined);
367
+ case "get_receipt": {
368
+ const targetId = String(args.receipt_id || args.run_id || "latest").trim();
369
+ if (targetId === "chain") {
370
+ return engine.verifyReceiptChain(ctx);
371
+ }
372
+ const verified = engine.getReceipt(ctx, targetId);
373
+ if (args.verify_chain === true) {
374
+ const receiptChain = engine.verifyReceiptChain(ctx);
375
+ return { ...verified, receiptChain };
376
+ }
377
+ return verified;
378
+ }
379
+ // Supermemory MCP & Governance direct tool aliases for agent harness interoperability
380
+ case "who_am_i":
381
+ return engine.getProfile(ctx);
382
+ case "list_spaces": {
383
+ const overview = await engine.getMemoryOverview(ctx);
384
+ return {
385
+ activeSpace: overview.namespace,
386
+ spaces: [
387
+ {
388
+ id: overview.namespace,
389
+ containerTag: overview.namespace,
390
+ workspaceId: ctx.workspace.id,
391
+ workspaceName: ctx.workspace.name,
392
+ active: true,
393
+ },
394
+ ],
395
+ };
396
+ }
397
+ case "search_memory":
398
+ case "list_memories":
399
+ return engine.getMemoryOverview(ctx, args.query ? String(args.query) : undefined);
400
+ case "add_memory":
401
+ case "remember": {
402
+ const prompt = String(args.prompt || "").trim();
403
+ if (prompt && !args.content) {
404
+ return engine.doNaturalLanguage(ctx, { prompt });
405
+ }
406
+ const content = String(args.content || args.memory || prompt || "");
407
+ const title = String(args.title || content.slice(0, 60) || "Workspace Memory");
408
+ const record = await engine.addWorkspaceMemory(ctx, {
409
+ title,
410
+ content,
411
+ kind: args.kind || "fact",
412
+ });
413
+ const overview = await engine.getMemoryOverview(ctx);
414
+ return {
415
+ ok: true,
416
+ memory: record,
417
+ activeDefaults: overview.activeDefaults,
418
+ explanation: overview.explanation,
419
+ };
420
+ }
421
+ case "forget_memory": {
422
+ const query = String(args.query || args.id || args.memory || "").trim();
423
+ if (!query)
424
+ throw new Error("query is required to forget a memory");
425
+ return engine.forgetWorkspaceMemoryMatching(ctx, query);
426
+ }
427
+ case "memory_graph":
428
+ return engine.getMemoryGraph(ctx, args.query ? String(args.query) : undefined);
429
+ case "set_guardrail":
430
+ case "configure_guardrails": {
431
+ const rawParamRules = Array.isArray(args.parameter_rules)
432
+ ? args.parameter_rules
433
+ : Array.isArray(args.parameterRules)
434
+ ? args.parameterRules
435
+ : undefined;
436
+ return engine.applyNaturalLanguageGuardrail(ctx, String(args.prompt || args.rule || args.instruction || ""), {
437
+ parameterRules: rawParamRules,
438
+ source: rawParamRules ? "mcp_harness" : "deterministic",
439
+ });
440
+ }
441
+ case "reset_guardrails":
442
+ return engine.resetWorkspaceGuardrails(ctx);
443
+ case "check_policy":
444
+ case "simulate_policy":
445
+ return engine.checkToolPolicy(ctx, {
446
+ toolSlug: String(args.tool_slug || args.slug || args.tool_id || args.query || "instant.web.search"),
447
+ input: (args.input || args.arguments) || {},
448
+ });
449
+ case "kill_switch": {
450
+ const enabled = typeof args.enabled === "boolean"
451
+ ? args.enabled
452
+ : typeof args.active === "boolean"
453
+ ? args.active
454
+ : true;
455
+ const reason = args.reason
456
+ ? String(args.reason)
457
+ : args.prompt
458
+ ? String(args.prompt)
459
+ : undefined;
460
+ const updated = engine.setKillSwitch(ctx, enabled, reason);
461
+ const govOverview = engine.getGovernanceOverview(ctx);
462
+ return {
463
+ ok: true,
464
+ action: "kill_switch",
465
+ killSwitchActive: Boolean(updated.policy.killSwitchActive),
466
+ killSwitchReason: updated.policy.killSwitchReason || null,
467
+ policy: updated.policy,
468
+ llmPolicyBrief: govOverview.llmPolicyBrief,
469
+ explanation: govOverview.explanation,
470
+ };
471
+ }
472
+ case "scan_context":
473
+ return engine.scanForContextPoisoning(ctx.workspace.id, String(args.content || args.prompt || args.query || ""));
474
+ case "governance_status":
475
+ return engine.getGovernanceOverview(ctx);
476
+ case "verify_receipt_chain":
477
+ return engine.verifyReceiptChain(ctx, args.limit ? Number(args.limit) : 100);
478
+ case "do":
479
+ return engine.doNaturalLanguage(ctx, {
480
+ prompt: String(args.prompt || args.instruction || args.query || ""),
481
+ input: args.input || undefined,
482
+ dryRun: Boolean(args.dry_run || args.dryRun),
483
+ autoApprove: args.auto_approve !== false && args.autoApprove !== false,
484
+ });
664
485
  // OpenAI Company Knowledge standard `search` and `fetch` tool support
665
486
  case "search": {
666
487
  const q = String(args.query || "").trim();
@@ -671,7 +492,7 @@ export async function dispatchMcpToolCall(engine, ctx, toolName, args = {}) {
671
492
  const toolHits = toolsRes.tools.map((t) => ({
672
493
  id: `tool:${t.slug}`,
673
494
  title: `${t.name} (${t.slug})`,
674
- url: t.providerUrl || `https://docs.muxo.ai/tools/${encodeURIComponent(t.slug)}`,
495
+ url: t.providerUrl || `https://docs.muxo.ai/catalogue#${encodeURIComponent(t.providerSlug || t.slug)}`,
675
496
  snippet: `${t.description} [lane=${t.lane}, risk=${t.riskLevel}, cost=${t.creditCost}cr]`,
676
497
  }));
677
498
  const memHits = (memRes.memories || []).slice(0, 5).map((m) => ({
@@ -711,7 +532,7 @@ export async function dispatchMcpToolCall(engine, ctx, toolName, args = {}) {
711
532
  title: tool.name,
712
533
  text: JSON.stringify(tool, null, 2),
713
534
  url: tool.providerUrl ||
714
- `https://docs.muxo.ai/tools/${encodeURIComponent(tool.slug)}`,
535
+ `https://docs.muxo.ai/catalogue#${encodeURIComponent(tool.providerSlug || tool.slug)}`,
715
536
  metadata: {
716
537
  slug: tool.slug,
717
538
  lane: tool.lane,
@@ -721,7 +542,7 @@ export async function dispatchMcpToolCall(engine, ctx, toolName, args = {}) {
721
542
  };
722
543
  }
723
544
  default:
724
- throw new Error(`Unknown MCP tool: ${toolName}`);
545
+ throw new MuxoToolError(`Unknown MCP tool: '${toolName}'. Call tools/list for the canonical Muxo MCP tools.`, { code: "unknown_mcp_tool", statusCode: 404, payload: { toolName } });
725
546
  }
726
547
  }
727
548
  export async function handleJsonRpcMcpRequest(engine, ctx, rpc) {
@@ -732,55 +553,270 @@ export async function handleJsonRpcMcpRequest(engine, ctx, rpc) {
732
553
  method.startsWith("notifications/")) {
733
554
  return null;
734
555
  }
556
+ const headerAndMetaCheck = validateMcpHttpHeadersAndMeta({}, rpc);
557
+ if (!headerAndMetaCheck.ok) {
558
+ return {
559
+ jsonrpc: "2.0",
560
+ id,
561
+ error: headerAndMetaCheck.error,
562
+ };
563
+ }
735
564
  try {
565
+ if (method === "server/discover") {
566
+ return {
567
+ jsonrpc: "2.0",
568
+ id,
569
+ result: buildMcpDiscoverResult(MUXO_VERSION),
570
+ };
571
+ }
736
572
  if (method === "initialize") {
737
- const requestedProtocol = typeof params.protocolVersion === "string" &&
738
- params.protocolVersion.trim()
739
- ? params.protocolVersion.trim()
740
- : "2025-06-18";
573
+ const requestedProtocol = headerAndMetaCheck.protocolVersion;
574
+ const serverInfo = {
575
+ name: "muxo-mcp-server",
576
+ title: "Muxo Unified Agent Runtime & Governance MCP Server",
577
+ version: MUXO_VERSION,
578
+ };
741
579
  return {
742
580
  jsonrpc: "2.0",
743
581
  id,
744
582
  result: {
583
+ resultType: "complete",
745
584
  protocolVersion: requestedProtocol,
585
+ supportedVersions: [...SUPPORTED_MCP_PROTOCOL_VERSIONS],
746
586
  instructions: MUXO_MCP_SERVER_INSTRUCTIONS,
747
- serverInfo: {
748
- name: "muxo-mcp-server",
749
- version: "1.3.0",
750
- },
587
+ serverInfo,
751
588
  capabilities: {
752
589
  tools: { listChanged: false },
753
- resources: { listChanged: false },
590
+ resources: { listChanged: false, subscribe: false },
591
+ prompts: { listChanged: false },
592
+ completions: {},
754
593
  extensions: {
755
594
  "io.modelcontextprotocol/skills": {},
595
+ "io.modelcontextprotocol/apps": {},
756
596
  },
757
597
  },
598
+ _meta: {
599
+ "io.modelcontextprotocol/serverInfo": serverInfo,
600
+ "io.modelcontextprotocol/instructions": MUXO_MCP_SERVER_INSTRUCTIONS,
601
+ },
758
602
  },
759
603
  };
760
604
  }
761
605
  if (method === "ping") {
762
- return { jsonrpc: "2.0", id, result: {} };
606
+ return { jsonrpc: "2.0", id, result: { resultType: "complete" } };
607
+ }
608
+ if (method === "completion/complete") {
609
+ const catalogTools = await engine.searchTools({ lane: "all", limit: 100 });
610
+ const completion = completeMcpArgument(params, catalogTools.tools.map((t) => t.slug));
611
+ return {
612
+ jsonrpc: "2.0",
613
+ id,
614
+ result: {
615
+ resultType: "complete",
616
+ completion,
617
+ },
618
+ };
619
+ }
620
+ if (method === "subscriptions/listen") {
621
+ return {
622
+ jsonrpc: "2.0",
623
+ id,
624
+ result: {
625
+ resultType: "complete",
626
+ events: [],
627
+ ttlMs: 30_000,
628
+ cacheScope: "private",
629
+ },
630
+ };
631
+ }
632
+ if (method === "prompts/list") {
633
+ return {
634
+ jsonrpc: "2.0",
635
+ id,
636
+ result: {
637
+ resultType: "complete",
638
+ ttlMs: 300_000,
639
+ cacheScope: "public",
640
+ prompts: [
641
+ {
642
+ name: "context",
643
+ title: "Workspace Memory & Governance Context",
644
+ description: "Ready-to-attach workspace context (Supermemory v5 profile, bi-temporal facts, learned parameter defaults, and active Microsoft Governance guardrails).",
645
+ arguments: [
646
+ {
647
+ name: "query",
648
+ description: "Optional topic or task query to focus memory recall",
649
+ required: false,
650
+ },
651
+ ],
652
+ },
653
+ {
654
+ name: "governed_execution",
655
+ title: "Governed Tool Execution Workflow",
656
+ description: "Step-by-step assistant prompt for discovering, planning, approving, executing, and verifying a governed Muxo action.",
657
+ arguments: [
658
+ {
659
+ name: "task",
660
+ description: "Natural-language task to plan and execute",
661
+ required: false,
662
+ },
663
+ ],
664
+ },
665
+ {
666
+ name: "security_audit",
667
+ title: "Workspace Governance, Memory Graph & Receipt Chain Audit",
668
+ description: "Inspect the workspace's 9-module Microsoft Agent Governance posture, Bi-Temporal Knowledge Graph, and Ed25519 AgenticReceipt hash chain.",
669
+ arguments: [],
670
+ },
671
+ {
672
+ name: "policy_guardrails",
673
+ title: "Workspace Policy, Parameter Guardrails & Risk Matrix",
674
+ description: "Load the structured LLM Policy & Governance Brief (riskLaneMatrix, conditional parameterRules with compliance guidance, budget caps, kill switch status, and control-plane commands).",
675
+ arguments: [],
676
+ },
677
+ ],
678
+ },
679
+ };
680
+ }
681
+ if (method === "prompts/get") {
682
+ const promptName = String(params.name || "context").trim();
683
+ const promptArgs = (params.arguments || {});
684
+ if (promptName === "context") {
685
+ const query = promptArgs.query ? String(promptArgs.query) : undefined;
686
+ const runCtx = await engine.getRunContext(ctx, query);
687
+ return {
688
+ jsonrpc: "2.0",
689
+ id,
690
+ result: {
691
+ resultType: "complete",
692
+ description: "Ready-to-attach Muxo workspace memory, active defaults, and safety guardrails.",
693
+ messages: [
694
+ {
695
+ role: "user",
696
+ content: {
697
+ type: "text",
698
+ text: String(runCtx.llmSystemPrompt || runCtx.explanation.preferred),
699
+ },
700
+ },
701
+ ],
702
+ },
703
+ };
704
+ }
705
+ if (promptName === "policy_guardrails") {
706
+ const gov = engine.getGovernanceOverview(ctx);
707
+ const sections = [
708
+ gov.llmPolicyBrief.llmSystemDirective,
709
+ `### Structured LLM Policy Brief (JSON)\n\`\`\`json\n${JSON.stringify(gov.llmPolicyBrief, null, 2)}\n\`\`\``,
710
+ ];
711
+ if (promptArgs.tool_slug) {
712
+ const sim = await engine.checkToolPolicy(ctx, {
713
+ toolSlug: String(promptArgs.tool_slug),
714
+ });
715
+ sections.push(`### Dry-Run Policy Check for \`${sim.toolSlug}\`\n\`\`\`json\n${JSON.stringify(sim, null, 2)}\n\`\`\``);
716
+ }
717
+ return {
718
+ jsonrpc: "2.0",
719
+ id,
720
+ result: {
721
+ resultType: "complete",
722
+ description: "Workspace policy, conditional parameter guardrails, and risk-lane matrix for AI agents",
723
+ messages: [
724
+ {
725
+ role: "user",
726
+ content: {
727
+ type: "text",
728
+ text: sections.join("\n\n"),
729
+ },
730
+ },
731
+ ],
732
+ },
733
+ };
734
+ }
735
+ if (promptName === "governed_execution") {
736
+ const task = String(promptArgs.task || "the user's requested operation");
737
+ const runCtx = await engine.getRunContext(ctx);
738
+ return {
739
+ jsonrpc: "2.0",
740
+ id,
741
+ result: {
742
+ resultType: "complete",
743
+ description: "Governed Muxo execution workflow prompt",
744
+ messages: [
745
+ {
746
+ role: "user",
747
+ content: {
748
+ type: "text",
749
+ text: `${runCtx.llmSystemPrompt}\n\n## Task\nExecute "${task}" safely using Muxo:\n1. Call \`search_tools\` and \`inspect_tool\` (or pass a natural-language request to \`plan_action\`).\n2. Call \`plan_action\` and inspect \`plan.approvalStatus\`, \`authHandoff\`, and \`llmGuidance.nextToolCalls\`.\n3. If \`authHandoff.required\` is true, present \`humanHandoff.markdownForUser\` and call \`wait_for_connection\`.\n4. If \`approvalStatus === "pending_approval"\`, present \`humanHandoff.markdownForUser\` and call \`get_plan\` with \`wait_for_approval: true\`.\n5. Execute with \`execute_<riskLevel>\` and verify the cryptographic receipt with \`get_receipt\`.`,
750
+ },
751
+ },
752
+ ],
753
+ },
754
+ };
755
+ }
756
+ if (promptName === "security_audit") {
757
+ const [gov, graph, chain] = await Promise.all([
758
+ Promise.resolve(engine.getGovernanceOverview(ctx)),
759
+ engine.getMemoryGraph(ctx),
760
+ Promise.resolve(engine.verifyReceiptChain(ctx)),
761
+ ]);
762
+ return {
763
+ jsonrpc: "2.0",
764
+ id,
765
+ result: {
766
+ resultType: "complete",
767
+ description: "Workspace governance, bi-temporal graph, and receipt chain audit",
768
+ messages: [
769
+ {
770
+ role: "user",
771
+ content: {
772
+ type: "text",
773
+ text: [
774
+ `# Muxo Security, Memory & Cryptographic Audit`,
775
+ `## 1. Microsoft Agent Governance (9 Modules)\n${gov.explanation.preferred}`,
776
+ `## 2. Bi-Temporal Knowledge Graph\n${graph.explanation.preferred}\n\`\`\`mermaid\n${graph.mermaid}\n\`\`\``,
777
+ `## 3. Portable Ed25519 AgenticReceipt Chain\n${chain.explanation.preferred}`,
778
+ ].join("\n\n"),
779
+ },
780
+ },
781
+ ],
782
+ },
783
+ };
784
+ }
785
+ return {
786
+ jsonrpc: "2.0",
787
+ id,
788
+ error: {
789
+ code: -32602,
790
+ message: `Prompt not found: ${promptName}`,
791
+ },
792
+ };
763
793
  }
764
794
  if (method === "tools/list") {
765
795
  return {
766
796
  jsonrpc: "2.0",
767
797
  id,
768
798
  result: {
769
- tools: MUXO_MCP_TOOLS,
799
+ resultType: "complete",
800
+ ttlMs: 300_000,
801
+ cacheScope: "public",
802
+ tools: MUXO_MCP_TOOLS.map((t) => buildMcpToolDescriptor(t)),
770
803
  },
771
804
  };
772
805
  }
773
806
  if (method === "tools/call") {
774
807
  const toolName = String(params.name || "");
775
808
  const toolArgs = (params.arguments || {});
776
- const output = await dispatchMcpToolCall(engine, ctx, toolName, toolArgs);
809
+ const rawOutput = await dispatchMcpToolCall(engine, ctx, toolName, toolArgs);
810
+ const output = attachMcpHarnessGuidance(toolName, toolArgs, rawOutput);
777
811
  const structuredContent = output && typeof output === "object" && !Array.isArray(output)
778
812
  ? output
779
813
  : { data: output };
814
+ const resultMeta = buildMcpToolResultMeta(toolName, params);
780
815
  return {
781
816
  jsonrpc: "2.0",
782
817
  id,
783
818
  result: {
819
+ resultType: "complete",
784
820
  structuredContent,
785
821
  content: [
786
822
  {
@@ -788,6 +824,7 @@ export async function handleJsonRpcMcpRequest(engine, ctx, rpc) {
788
824
  text: JSON.stringify(output, null, 2),
789
825
  },
790
826
  ],
827
+ ...(resultMeta ? { _meta: resultMeta } : {}),
791
828
  isError: false,
792
829
  },
793
830
  };
@@ -795,9 +832,14 @@ export async function handleJsonRpcMcpRequest(engine, ctx, rpc) {
795
832
  // SEP-2640 Skills Import Extension (`io.modelcontextprotocol/skills`)
796
833
  if (method === "skills/list") {
797
834
  const skills = getMuxoMcpSkills().map((s) => ({
835
+ uri: s.uri,
836
+ frontmatter: s.frontmatter,
837
+ resources: s.files.map((f) => ({
838
+ uri: f.uri,
839
+ digest: f.digest,
840
+ })),
798
841
  name: s.name,
799
842
  description: s.description,
800
- uri: s.uri,
801
843
  version: s.version,
802
844
  digest: s.files[0]?.digest || "",
803
845
  files: s.files.length,
@@ -805,34 +847,49 @@ export async function handleJsonRpcMcpRequest(engine, ctx, rpc) {
805
847
  return {
806
848
  jsonrpc: "2.0",
807
849
  id,
808
- result: { skills },
850
+ result: {
851
+ resultType: "complete",
852
+ ttlMs: 300_000,
853
+ cacheScope: "public",
854
+ skills,
855
+ },
809
856
  };
810
857
  }
811
858
  if (method === "skills/get") {
812
- const requestedName = String(params.name || "muxo").trim();
813
- const skill = getMuxoMcpSkills().find((s) => s.name === requestedName);
859
+ const { skill, requested } = findMcpSkill(getMuxoMcpSkills(), params);
814
860
  if (!skill) {
815
861
  return {
816
862
  jsonrpc: "2.0",
817
863
  id,
818
864
  error: {
819
865
  code: -32602,
820
- message: `Skill not found: ${requestedName}`,
866
+ message: `Skill not found: ${requested}`,
821
867
  },
822
868
  };
823
869
  }
870
+ const resources = skill.files.map((f) => ({
871
+ uri: f.uri,
872
+ digest: f.digest,
873
+ }));
824
874
  return {
825
875
  jsonrpc: "2.0",
826
876
  id,
827
877
  result: {
878
+ resultType: "complete",
879
+ ttlMs: 300_000,
880
+ cacheScope: "public",
828
881
  skill: {
882
+ uri: skill.uri,
883
+ frontmatter: skill.frontmatter,
884
+ resources,
829
885
  name: skill.name,
830
886
  description: skill.description,
831
- uri: skill.uri,
832
887
  version: skill.version,
833
888
  digest: skill.files[0]?.digest || "",
834
889
  },
890
+ uri: skill.uri,
835
891
  frontmatter: skill.frontmatter,
892
+ resources,
836
893
  files: skill.files.map((f) => ({
837
894
  path: f.path,
838
895
  uri: f.uri,
@@ -843,21 +900,401 @@ export async function handleJsonRpcMcpRequest(engine, ctx, rpc) {
843
900
  },
844
901
  };
845
902
  }
903
+ if (method === "resources/templates/list") {
904
+ return {
905
+ jsonrpc: "2.0",
906
+ id,
907
+ result: {
908
+ resultType: "complete",
909
+ ttlMs: 300_000,
910
+ cacheScope: "public",
911
+ resourceTemplates: MUXO_MCP_RESOURCE_TEMPLATES,
912
+ },
913
+ };
914
+ }
846
915
  if (method === "resources/list") {
847
- const resources = getMuxoMcpSkills().flatMap((s) => s.files.map((f) => ({
916
+ const skillResources = getMuxoMcpSkills().flatMap((s) => s.files.map((f) => ({
848
917
  uri: f.uri,
849
918
  name: `${s.name}/${f.path}`,
850
919
  description: s.description,
851
920
  mimeType: f.mimeType,
852
921
  })));
922
+ const dynamicResources = [
923
+ {
924
+ uri: "muxo://profile",
925
+ name: "Workspace Profile & Active Memory Defaults",
926
+ description: "Stable and recent Supermemory v5 profile context, active auto-fill defaults, and Ed25519 Agent DID for the active workspace.",
927
+ mimeType: "application/json",
928
+ },
929
+ {
930
+ uri: "supermemory://profile",
931
+ name: "Supermemory Active Space Profile",
932
+ description: "Supermemory MCP compatible profile resource (static + dynamic facts and preferences) for the active workspace.",
933
+ mimeType: "application/json",
934
+ },
935
+ {
936
+ uri: "supermemory://spaces",
937
+ name: "Supermemory Accessible Spaces",
938
+ description: "Compact list of accessible workspace memory spaces with the active containerTag marked.",
939
+ mimeType: "application/json",
940
+ },
941
+ {
942
+ uri: "muxo://context",
943
+ name: "Governed Workspace Run Context",
944
+ description: "Ready-to-inject workspace context including guardrails, learned defaults, provisioned cloud resources, and Supermemory recall.",
945
+ mimeType: "application/json",
946
+ },
947
+ {
948
+ uri: "muxo://memory/graph",
949
+ name: "Bi-Temporal Knowledge Graph",
950
+ description: "Entity & relationship graph with active facts, superseded historical facts (validFrom/validTo), and Mermaid topology.",
951
+ mimeType: "application/json",
952
+ },
953
+ {
954
+ uri: "muxo://governance/policy",
955
+ name: "Microsoft Agent Governance & Guardrails",
956
+ description: "9-module Microsoft Agent Governance status, plain-English guardrails, Bayesian trust score, and OWASP ASI-06 scan status.",
957
+ mimeType: "application/json",
958
+ },
959
+ {
960
+ uri: "muxo://policy/brief",
961
+ name: "LLM Policy, Risk Matrix & Parameter Guardrails Brief",
962
+ description: "Structured LLM policy digest with riskLaneMatrix, conditional parameterRules compliance guidance, learned memory defaults, and control-plane commands.",
963
+ mimeType: "application/json",
964
+ },
965
+ {
966
+ uri: "muxo://receipts/chain",
967
+ name: "Cryptographic AgenticReceipt Hash Chain",
968
+ description: "Tamper-evident SHA-256 + portable Ed25519 AgenticReceipt chain verification report.",
969
+ mimeType: "application/json",
970
+ },
971
+ ];
853
972
  return {
854
973
  jsonrpc: "2.0",
855
974
  id,
856
- result: { resources },
975
+ result: {
976
+ resultType: "complete",
977
+ ttlMs: 60_000,
978
+ cacheScope: "private",
979
+ resources: [...MUXO_UI_RESOURCES, ...skillResources, ...dynamicResources],
980
+ },
857
981
  };
858
982
  }
859
983
  if (method === "resources/read") {
860
984
  const uri = String(params.uri || "").trim();
985
+ const uiResource = MUXO_UI_RESOURCES.find((r) => r.uri === uri);
986
+ if (uiResource) {
987
+ return {
988
+ jsonrpc: "2.0",
989
+ id,
990
+ result: {
991
+ resultType: "complete",
992
+ ttlMs: 300_000,
993
+ cacheScope: "public",
994
+ contents: [
995
+ {
996
+ uri: uiResource.uri,
997
+ mimeType: uiResource.mimeType,
998
+ text: renderMuxoUiWidgetHtml(),
999
+ _meta: uiResource._meta,
1000
+ },
1001
+ ],
1002
+ },
1003
+ };
1004
+ }
1005
+ if (uri === "muxo://profile" || uri === "supermemory://profile") {
1006
+ const overview = await engine.getMemoryOverview(ctx);
1007
+ const profile = engine.getProfile(ctx);
1008
+ const payload = {
1009
+ uri,
1010
+ workspaceId: ctx.workspace.id,
1011
+ workspaceSlug: ctx.workspace.slug,
1012
+ namespace: overview.namespace,
1013
+ profile: overview.context.profile,
1014
+ activeDefaults: overview.activeDefaults,
1015
+ activeGuardrails: overview.activeGuardrails,
1016
+ actor: profile,
1017
+ explanation: overview.explanation,
1018
+ };
1019
+ return {
1020
+ jsonrpc: "2.0",
1021
+ id,
1022
+ result: {
1023
+ resultType: "complete",
1024
+ ttlMs: 60_000,
1025
+ cacheScope: "private",
1026
+ contents: [
1027
+ {
1028
+ uri,
1029
+ mimeType: "application/json",
1030
+ text: JSON.stringify(payload, null, 2),
1031
+ },
1032
+ ],
1033
+ },
1034
+ };
1035
+ }
1036
+ if (uri === "muxo://spaces" || uri === "supermemory://spaces") {
1037
+ const overview = await engine.getMemoryOverview(ctx);
1038
+ const payload = {
1039
+ activeSpace: overview.namespace,
1040
+ spaces: [
1041
+ {
1042
+ id: overview.namespace,
1043
+ containerTag: overview.namespace,
1044
+ workspaceId: ctx.workspace.id,
1045
+ workspaceName: ctx.workspace.name,
1046
+ active: true,
1047
+ },
1048
+ ],
1049
+ };
1050
+ return {
1051
+ jsonrpc: "2.0",
1052
+ id,
1053
+ result: {
1054
+ resultType: "complete",
1055
+ ttlMs: 60_000,
1056
+ cacheScope: "private",
1057
+ contents: [
1058
+ {
1059
+ uri,
1060
+ mimeType: "application/json",
1061
+ text: JSON.stringify(payload, null, 2),
1062
+ },
1063
+ ],
1064
+ },
1065
+ };
1066
+ }
1067
+ if (uri === "muxo://context") {
1068
+ const runCtx = await engine.getRunContext(ctx);
1069
+ return {
1070
+ jsonrpc: "2.0",
1071
+ id,
1072
+ result: {
1073
+ resultType: "complete",
1074
+ ttlMs: 60_000,
1075
+ cacheScope: "private",
1076
+ contents: [
1077
+ {
1078
+ uri,
1079
+ mimeType: "application/json",
1080
+ text: JSON.stringify(runCtx, null, 2),
1081
+ },
1082
+ ],
1083
+ },
1084
+ };
1085
+ }
1086
+ if (uri === "muxo://memory/graph") {
1087
+ const graph = await engine.getMemoryGraph(ctx);
1088
+ return {
1089
+ jsonrpc: "2.0",
1090
+ id,
1091
+ result: {
1092
+ resultType: "complete",
1093
+ ttlMs: 60_000,
1094
+ cacheScope: "private",
1095
+ contents: [
1096
+ {
1097
+ uri,
1098
+ mimeType: "application/json",
1099
+ text: JSON.stringify(graph, null, 2),
1100
+ },
1101
+ ],
1102
+ },
1103
+ };
1104
+ }
1105
+ if (uri === "muxo://governance/policy") {
1106
+ const gov = engine.getGovernanceOverview(ctx);
1107
+ return {
1108
+ jsonrpc: "2.0",
1109
+ id,
1110
+ result: {
1111
+ resultType: "complete",
1112
+ ttlMs: 60_000,
1113
+ cacheScope: "private",
1114
+ contents: [
1115
+ {
1116
+ uri,
1117
+ mimeType: "application/json",
1118
+ text: JSON.stringify(gov, null, 2),
1119
+ },
1120
+ ],
1121
+ },
1122
+ };
1123
+ }
1124
+ if (uri === "muxo://policy/brief") {
1125
+ const gov = engine.getGovernanceOverview(ctx);
1126
+ return {
1127
+ jsonrpc: "2.0",
1128
+ id,
1129
+ result: {
1130
+ resultType: "complete",
1131
+ ttlMs: 60_000,
1132
+ cacheScope: "private",
1133
+ contents: [
1134
+ {
1135
+ uri,
1136
+ mimeType: "application/json",
1137
+ text: JSON.stringify(gov.llmPolicyBrief, null, 2),
1138
+ },
1139
+ ],
1140
+ },
1141
+ };
1142
+ }
1143
+ if (uri === "muxo://receipts/chain") {
1144
+ const chain = engine.verifyReceiptChain(ctx);
1145
+ return {
1146
+ jsonrpc: "2.0",
1147
+ id,
1148
+ result: {
1149
+ resultType: "complete",
1150
+ ttlMs: 60_000,
1151
+ cacheScope: "private",
1152
+ contents: [
1153
+ {
1154
+ uri,
1155
+ mimeType: "application/json",
1156
+ text: JSON.stringify(chain, null, 2),
1157
+ },
1158
+ ],
1159
+ },
1160
+ };
1161
+ }
1162
+ if (uri.startsWith("muxo://tools/")) {
1163
+ const slug = decodeURIComponent(uri.slice("muxo://tools/".length)).trim();
1164
+ try {
1165
+ const inspected = await dispatchMcpToolCall(engine, ctx, "inspect_tool", {
1166
+ tool_slug: slug,
1167
+ });
1168
+ return {
1169
+ jsonrpc: "2.0",
1170
+ id,
1171
+ result: {
1172
+ resultType: "complete",
1173
+ ttlMs: 300_000,
1174
+ cacheScope: "public",
1175
+ contents: [
1176
+ {
1177
+ uri,
1178
+ mimeType: "application/json",
1179
+ text: JSON.stringify(inspected, null, 2),
1180
+ },
1181
+ ],
1182
+ },
1183
+ };
1184
+ }
1185
+ catch {
1186
+ return {
1187
+ jsonrpc: "2.0",
1188
+ id,
1189
+ error: {
1190
+ code: -32602,
1191
+ message: `Resource not found: ${uri}`,
1192
+ },
1193
+ };
1194
+ }
1195
+ }
1196
+ if (uri.startsWith("muxo://plans/")) {
1197
+ const planId = decodeURIComponent(uri.slice("muxo://plans/".length)).trim();
1198
+ try {
1199
+ const planRecord = await dispatchMcpToolCall(engine, ctx, "get_plan", {
1200
+ plan_id: planId,
1201
+ });
1202
+ return {
1203
+ jsonrpc: "2.0",
1204
+ id,
1205
+ result: {
1206
+ resultType: "complete",
1207
+ ttlMs: 30_000,
1208
+ cacheScope: "private",
1209
+ contents: [
1210
+ {
1211
+ uri,
1212
+ mimeType: "application/json",
1213
+ text: JSON.stringify(planRecord, null, 2),
1214
+ },
1215
+ ],
1216
+ },
1217
+ };
1218
+ }
1219
+ catch {
1220
+ return {
1221
+ jsonrpc: "2.0",
1222
+ id,
1223
+ error: {
1224
+ code: -32602,
1225
+ message: `Resource not found: ${uri}`,
1226
+ },
1227
+ };
1228
+ }
1229
+ }
1230
+ if (uri.startsWith("muxo://runs/")) {
1231
+ const runId = decodeURIComponent(uri.slice("muxo://runs/".length)).trim();
1232
+ try {
1233
+ const runRecord = await dispatchMcpToolCall(engine, ctx, "get_run", {
1234
+ run_id: runId,
1235
+ });
1236
+ return {
1237
+ jsonrpc: "2.0",
1238
+ id,
1239
+ result: {
1240
+ resultType: "complete",
1241
+ ttlMs: 30_000,
1242
+ cacheScope: "private",
1243
+ contents: [
1244
+ {
1245
+ uri,
1246
+ mimeType: "application/json",
1247
+ text: JSON.stringify(runRecord, null, 2),
1248
+ },
1249
+ ],
1250
+ },
1251
+ };
1252
+ }
1253
+ catch {
1254
+ return {
1255
+ jsonrpc: "2.0",
1256
+ id,
1257
+ error: {
1258
+ code: -32602,
1259
+ message: `Resource not found: ${uri}`,
1260
+ },
1261
+ };
1262
+ }
1263
+ }
1264
+ if (uri.startsWith("muxo://receipts/")) {
1265
+ const receiptId = decodeURIComponent(uri.slice("muxo://receipts/".length)).trim();
1266
+ try {
1267
+ const receiptRecord = await dispatchMcpToolCall(engine, ctx, "get_receipt", {
1268
+ receipt_id: receiptId,
1269
+ });
1270
+ return {
1271
+ jsonrpc: "2.0",
1272
+ id,
1273
+ result: {
1274
+ resultType: "complete",
1275
+ ttlMs: 60_000,
1276
+ cacheScope: "private",
1277
+ contents: [
1278
+ {
1279
+ uri,
1280
+ mimeType: "application/json",
1281
+ text: JSON.stringify(receiptRecord, null, 2),
1282
+ },
1283
+ ],
1284
+ },
1285
+ };
1286
+ }
1287
+ catch {
1288
+ return {
1289
+ jsonrpc: "2.0",
1290
+ id,
1291
+ error: {
1292
+ code: -32602,
1293
+ message: `Resource not found: ${uri}`,
1294
+ },
1295
+ };
1296
+ }
1297
+ }
861
1298
  const allFiles = getMuxoMcpSkills().flatMap((s) => s.files);
862
1299
  const found = allFiles.find((f) => f.uri === uri);
863
1300
  if (!found) {
@@ -874,6 +1311,9 @@ export async function handleJsonRpcMcpRequest(engine, ctx, rpc) {
874
1311
  jsonrpc: "2.0",
875
1312
  id,
876
1313
  result: {
1314
+ resultType: "complete",
1315
+ ttlMs: 300_000,
1316
+ cacheScope: "public",
877
1317
  contents: [
878
1318
  {
879
1319
  uri: found.uri,
@@ -894,19 +1334,21 @@ export async function handleJsonRpcMcpRequest(engine, ctx, rpc) {
894
1334
  };
895
1335
  }
896
1336
  catch (err) {
1337
+ const errPayload = errorPayloadFrom(err, "MCP tool execution failed");
1338
+ const errMeta = buildMcpErrorResultMeta(err, engine?.config?.baseUrl || "https://api.muxo.ai");
897
1339
  return {
898
1340
  jsonrpc: "2.0",
899
1341
  id,
900
1342
  result: {
1343
+ resultType: "complete",
1344
+ structuredContent: errPayload,
901
1345
  content: [
902
1346
  {
903
1347
  type: "text",
904
- text: JSON.stringify({
905
- ok: false,
906
- error: String(err?.message || err || "MCP tool execution failed"),
907
- }, null, 2),
1348
+ text: JSON.stringify(errPayload, null, 2),
908
1349
  },
909
1350
  ],
1351
+ ...(errMeta ? { _meta: errMeta } : {}),
910
1352
  isError: true,
911
1353
  },
912
1354
  };