@defai.digital/automatosx 12.3.0 → 12.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  [![Ubuntu](https://img.shields.io/badge/Ubuntu-24.04-blue.svg)](https://ubuntu.com)
13
13
  [![License](https://img.shields.io/badge/license-Apache--2.0-yellow.svg)](LICENSE)
14
14
 
15
- **Status**: ✅ **Production Ready** | v12.3.0 | MCP Configuration Fix for ax-glm & ax-grok
15
+ **Status**: ✅ **Production Ready** | v12.3.1 | MCP Resource Templates & Enhanced Server
16
16
 
17
17
  > 🎯 **What AutomatosX Does**: Adds 20+ specialized agents, persistent memory, workflow automation, and 80% cost savings to Claude Code/Codex - **without changing how you work**.
18
18
 
package/dist/index.js CHANGED
@@ -6069,7 +6069,7 @@ var PRECOMPILED_CONFIG = {
6069
6069
  "enableFreeTierPrioritization": true,
6070
6070
  "enableWorkloadAwareRouting": true
6071
6071
  },
6072
- "version": "12.3.0"
6072
+ "version": "12.3.1"
6073
6073
  };
6074
6074
 
6075
6075
  // src/core/config/schemas.ts
@@ -13264,7 +13264,8 @@ init_esm_shims();
13264
13264
 
13265
13265
  // src/mcp/types.ts
13266
13266
  init_esm_shims();
13267
- var MCP_PROTOCOL_VERSION = "2024-11-05";
13267
+ var MCP_PROTOCOL_VERSION = "2024-12-05";
13268
+ var MCP_SUPPORTED_VERSIONS = ["2024-12-05", "2024-11-05"];
13268
13269
 
13269
13270
  // src/mcp/server.ts
13270
13271
  init_logger();
@@ -15063,6 +15064,13 @@ var Router = class {
15063
15064
  }
15064
15065
  }
15065
15066
  }
15067
+ /**
15068
+ * Get the number of configured providers.
15069
+ * @returns Number of providers registered with this router
15070
+ */
15071
+ get providerCount() {
15072
+ return this.providers.length;
15073
+ }
15066
15074
  /**
15067
15075
  * Warm up provider availability caches immediately.
15068
15076
  * Phase 3 (v5.6.3): Eliminates cold-start latency on first request.
@@ -26250,7 +26258,11 @@ var McpClient = class _McpClient extends EventEmitter {
26250
26258
  const params = {
26251
26259
  protocolVersion: MCP_PROTOCOL_VERSION,
26252
26260
  capabilities: {
26253
- tools: {}
26261
+ tools: {},
26262
+ resources: {},
26263
+ prompts: {},
26264
+ resourceTemplates: {},
26265
+ experimental: {}
26254
26266
  },
26255
26267
  clientInfo: {
26256
26268
  name: "automatosx",
@@ -28056,6 +28068,93 @@ var CodexEventNormalizer = class extends BaseEventNormalizer {
28056
28068
  }
28057
28069
  };
28058
28070
 
28071
+ // src/mcp/resource-templates.ts
28072
+ init_esm_shims();
28073
+ var AGENT_TEMPLATE_NAME = "agent_profile";
28074
+ var AGENT_URI_TEMPLATE = "agent/{agent}";
28075
+ var WORKSPACE_PRD_TEMPLATE_NAME = "workspace_prd_file";
28076
+ var WORKSPACE_PRD_URI_TEMPLATE = "workspace/prd/{path}";
28077
+ var WORKSPACE_TMP_TEMPLATE_NAME = "workspace_tmp_file";
28078
+ var WORKSPACE_TMP_URI_TEMPLATE = "workspace/tmp/{path}";
28079
+ var RESOURCE_TEMPLATES = [
28080
+ {
28081
+ name: AGENT_TEMPLATE_NAME,
28082
+ uriTemplate: AGENT_URI_TEMPLATE,
28083
+ description: "Render an AutomatosX agent profile by name",
28084
+ mimeType: "text/markdown",
28085
+ variableDefinitions: [
28086
+ { name: "agent", description: "Agent name", required: true }
28087
+ ]
28088
+ },
28089
+ {
28090
+ name: WORKSPACE_PRD_TEMPLATE_NAME,
28091
+ uriTemplate: WORKSPACE_PRD_URI_TEMPLATE,
28092
+ description: "Read a PRD workspace file (automatosx/PRD)",
28093
+ mimeType: "text/markdown",
28094
+ variableDefinitions: [
28095
+ { name: "path", description: "Relative path under automatosx/PRD", required: true }
28096
+ ]
28097
+ },
28098
+ {
28099
+ name: WORKSPACE_TMP_TEMPLATE_NAME,
28100
+ uriTemplate: WORKSPACE_TMP_URI_TEMPLATE,
28101
+ description: "Read a temporary workspace file (automatosx/tmp)",
28102
+ mimeType: "text/markdown",
28103
+ variableDefinitions: [
28104
+ { name: "path", description: "Relative path under automatosx/tmp", required: true }
28105
+ ]
28106
+ }
28107
+ ];
28108
+ function listResourceTemplates() {
28109
+ return RESOURCE_TEMPLATES;
28110
+ }
28111
+ async function resolveResourceTemplate(uri, variables, profileLoader, workspaceManager) {
28112
+ if (uri === AGENT_URI_TEMPLATE) {
28113
+ const agent = variables?.agent;
28114
+ if (!agent) {
28115
+ throw new Error("Missing required variable: agent");
28116
+ }
28117
+ const profile = await profileLoader.loadProfile(agent);
28118
+ const summary = [
28119
+ `# ${agent}`,
28120
+ profile.role ? `**Role:** ${profile.role}` : "",
28121
+ profile.abilities?.length ? `**Abilities:** ${profile.abilities.join(", ")}` : "",
28122
+ "",
28123
+ profile.systemPrompt || "No system prompt defined."
28124
+ ].filter(Boolean).join("\n");
28125
+ return {
28126
+ uri: `agent/${agent}`,
28127
+ name: `Agent: ${agent}`,
28128
+ description: `AutomatosX agent profile for ${agent}`,
28129
+ mimeType: "text/markdown",
28130
+ contents: [
28131
+ { type: "text", text: summary },
28132
+ { type: "application/json", json: profile }
28133
+ ]
28134
+ };
28135
+ }
28136
+ if (uri === WORKSPACE_PRD_URI_TEMPLATE || uri === WORKSPACE_TMP_URI_TEMPLATE) {
28137
+ const path7 = variables?.path;
28138
+ if (!path7) {
28139
+ throw new Error("Missing required variable: path");
28140
+ }
28141
+ const isPrd = uri === WORKSPACE_PRD_URI_TEMPLATE;
28142
+ const readFn = isPrd ? workspaceManager.readPRD.bind(workspaceManager) : workspaceManager.readTmp.bind(workspaceManager);
28143
+ const content = await readFn(path7);
28144
+ return {
28145
+ uri: `${isPrd ? "prd" : "tmp"}/${path7}`,
28146
+ name: `${isPrd ? "PRD" : "Tmp"}: ${path7}`,
28147
+ description: `Workspace ${isPrd ? "PRD" : "tmp"} file`,
28148
+ mimeType: "text/markdown",
28149
+ contents: [
28150
+ { type: "text", text: content },
28151
+ { type: "application/json", json: { path: path7, content, workspace: isPrd ? "PRD" : "tmp" } }
28152
+ ]
28153
+ };
28154
+ }
28155
+ throw new Error(`Unknown resource template: ${uri}`);
28156
+ }
28157
+
28059
28158
  // src/mcp/server.ts
28060
28159
  var CLIENT_PATTERNS = [
28061
28160
  [["claude"], "claude"],
@@ -28091,6 +28190,8 @@ var McpServer = class _McpServer {
28091
28190
  // Track client-initiated cancellations
28092
28191
  requestControllers = /* @__PURE__ */ new Map();
28093
28192
  // Abort long-running handlers
28193
+ toolAllowlist;
28194
+ authToken;
28094
28195
  // v10.5.0: MCP Session for Smart Routing
28095
28196
  session = null;
28096
28197
  // v10.6.0: MCP Client Pool for cross-provider execution
@@ -28099,6 +28200,7 @@ var McpServer = class _McpServer {
28099
28200
  eventBridge = null;
28100
28201
  streamingNotifier = null;
28101
28202
  enableStreamingNotifications = true;
28203
+ negotiatedProtocolVersion = MCP_PROTOCOL_VERSION;
28102
28204
  // Shared services (initialized once per server)
28103
28205
  router;
28104
28206
  memoryManager;
@@ -28112,6 +28214,12 @@ var McpServer = class _McpServer {
28112
28214
  if (options.debug) {
28113
28215
  setLogLevel("debug");
28114
28216
  }
28217
+ if (options.toolAllowlist?.length) {
28218
+ this.toolAllowlist = new Set(options.toolAllowlist);
28219
+ }
28220
+ if (options.authToken) {
28221
+ this.authToken = options.authToken;
28222
+ }
28115
28223
  this.enableStreamingNotifications = options.enableStreamingNotifications ?? true;
28116
28224
  this.version = getVersion();
28117
28225
  this.ajv = new Ajv({ allErrors: true });
@@ -28121,6 +28229,24 @@ var McpServer = class _McpServer {
28121
28229
  streamingNotifications: this.enableStreamingNotifications
28122
28230
  });
28123
28231
  }
28232
+ /** Determine if negotiated protocol is v2 */
28233
+ isV2Protocol() {
28234
+ return this.negotiatedProtocolVersion === MCP_SUPPORTED_VERSIONS[0];
28235
+ }
28236
+ /** Build capability set based on negotiated protocol */
28237
+ buildCapabilities() {
28238
+ const base = { tools: {} };
28239
+ if (this.isV2Protocol()) {
28240
+ return {
28241
+ ...base,
28242
+ resources: {},
28243
+ prompts: {},
28244
+ resourceTemplates: {},
28245
+ experimental: {}
28246
+ };
28247
+ }
28248
+ return base;
28249
+ }
28124
28250
  /**
28125
28251
  * Get static tool schemas (no initialization required)
28126
28252
  * Returns tool schemas that can be provided during MCP handshake
@@ -28500,6 +28626,14 @@ Use this tool first to understand what AutomatosX offers.`,
28500
28626
  return await this.handleResourcesList(request, responseId);
28501
28627
  case "resources/read":
28502
28628
  return await this.handleResourceRead(request, responseId);
28629
+ case "resources/templates/list":
28630
+ return await this.handleResourceTemplatesList(request, responseId);
28631
+ case "resources/templates/read":
28632
+ return await this.handleResourceTemplateRead(request, responseId);
28633
+ case "prompts/list":
28634
+ return await this.handlePromptsList(request, responseId);
28635
+ case "prompts/get":
28636
+ return await this.handlePromptGet(request, responseId);
28503
28637
  case "$/cancelRequest":
28504
28638
  return this.handleCancelRequest(request, responseId);
28505
28639
  default:
@@ -28538,9 +28672,12 @@ Use this tool first to understand what AutomatosX offers.`,
28538
28672
  clientName: clientInfo.name,
28539
28673
  normalizedProvider: this.session.normalizedProvider
28540
28674
  });
28675
+ const requestedProtocol = request.params?.protocolVersion;
28676
+ const negotiated = MCP_SUPPORTED_VERSIONS.find((version) => version === requestedProtocol) ?? MCP_SUPPORTED_VERSIONS[0];
28677
+ this.negotiatedProtocolVersion = negotiated;
28541
28678
  const response = {
28542
- protocolVersion: MCP_PROTOCOL_VERSION,
28543
- capabilities: { tools: {} },
28679
+ protocolVersion: negotiated,
28680
+ capabilities: this.buildCapabilities(),
28544
28681
  serverInfo: { name: "automatosx", version: this.version }
28545
28682
  };
28546
28683
  logger.info("[MCP Server] Initialize handshake complete (< 1ms)");
@@ -28554,7 +28691,11 @@ Use this tool first to understand what AutomatosX offers.`,
28554
28691
  */
28555
28692
  handleToolsList(_request, id) {
28556
28693
  logger.debug("[MCP Server] Tools list requested (static schemas)");
28557
- const tools = _McpServer.getStaticToolSchemas();
28694
+ const tools = _McpServer.getStaticToolSchemas().map((schema) => ({
28695
+ ...schema,
28696
+ // If allowlist is set, hide tools not allowed
28697
+ ...this.toolAllowlist && !this.toolAllowlist.has(schema.name) ? { hidden: true } : {}
28698
+ }));
28558
28699
  return { jsonrpc: "2.0", id, result: { tools } };
28559
28700
  }
28560
28701
  /**
@@ -28571,6 +28712,81 @@ Use this tool first to understand what AutomatosX offers.`,
28571
28712
  }));
28572
28713
  return { jsonrpc: "2.0", id, result: { resources } };
28573
28714
  }
28715
+ /**
28716
+ * Handle resources/templates/list request (v2 capability)
28717
+ */
28718
+ async handleResourceTemplatesList(_request, id) {
28719
+ if (!this.isV2Protocol()) {
28720
+ return this.createErrorResponse(id, -32601 /* MethodNotFound */, "resources/templates/list is only available in MCP v2");
28721
+ }
28722
+ await this.ensureInitialized();
28723
+ const resourceTemplates = listResourceTemplates();
28724
+ return { jsonrpc: "2.0", id, result: { resourceTemplates } };
28725
+ }
28726
+ /**
28727
+ * Handle prompts/list request (expose common starter prompts)
28728
+ */
28729
+ async handlePromptsList(_request, id) {
28730
+ await this.ensureInitialized();
28731
+ const prompts = [
28732
+ {
28733
+ name: "agent_context",
28734
+ description: "Get agent context and system prompt for a given agent name",
28735
+ arguments: [{ name: "agent", required: true, description: "Agent name" }]
28736
+ },
28737
+ {
28738
+ name: "status",
28739
+ description: "Get AutomatosX MCP status summary"
28740
+ }
28741
+ ];
28742
+ return { jsonrpc: "2.0", id, result: { prompts } };
28743
+ }
28744
+ /**
28745
+ * Handle prompts/get request
28746
+ */
28747
+ async handlePromptGet(request, id) {
28748
+ await this.ensureInitialized();
28749
+ const name = request.params?.name;
28750
+ if (!name) {
28751
+ return this.createErrorResponse(id, -32602 /* InvalidParams */, "Prompt name is required");
28752
+ }
28753
+ switch (name) {
28754
+ case "agent_context": {
28755
+ const agent = request.params?.arguments?.agent;
28756
+ if (!agent) {
28757
+ return this.createErrorResponse(id, -32602 /* InvalidParams */, "agent argument is required");
28758
+ }
28759
+ try {
28760
+ const profile = await this.profileLoader.loadProfile(agent);
28761
+ const content = [
28762
+ { type: "text", text: `System prompt for ${agent}:
28763
+ ${profile.systemPrompt || "No system prompt defined."}` },
28764
+ { type: "application/json", json: profile }
28765
+ ];
28766
+ return { jsonrpc: "2.0", id, result: { prompt: { name, description: "Agent context", arguments: [{ name: "agent", required: true }] }, content } };
28767
+ } catch (error) {
28768
+ return this.createErrorResponse(id, -32603 /* InternalError */, `Failed to load agent: ${error.message}`);
28769
+ }
28770
+ }
28771
+ case "status": {
28772
+ const summary = {
28773
+ version: this.version,
28774
+ providerCount: this.router?.providerCount ?? 0,
28775
+ streamingNotifications: this.enableStreamingNotifications
28776
+ };
28777
+ const content = [
28778
+ { type: "text", text: `AutomatosX MCP status:
28779
+ Version: ${summary.version}
28780
+ Providers: ${summary.providerCount}
28781
+ Streaming: ${summary.streamingNotifications}` },
28782
+ { type: "application/json", json: summary }
28783
+ ];
28784
+ return { jsonrpc: "2.0", id, result: { prompt: { name, description: "AutomatosX status" }, content } };
28785
+ }
28786
+ default:
28787
+ return this.createErrorResponse(id, -32601 /* MethodNotFound */, `Prompt not found: ${name}`);
28788
+ }
28789
+ }
28574
28790
  /**
28575
28791
  * Handle resources/read request
28576
28792
  */
@@ -28599,6 +28815,30 @@ Use this tool first to understand what AutomatosX offers.`,
28599
28815
  return this.createErrorResponse(id, -32603 /* InternalError */, `Failed to read resource: ${error.message}`);
28600
28816
  }
28601
28817
  }
28818
+ /**
28819
+ * Handle resources/templates/read request (v2 capability)
28820
+ */
28821
+ async handleResourceTemplateRead(request, id) {
28822
+ if (!this.isV2Protocol()) {
28823
+ return this.createErrorResponse(id, -32601 /* MethodNotFound */, "resources/templates/read is only available in MCP v2");
28824
+ }
28825
+ await this.ensureInitialized();
28826
+ const uri = request.params?.uri;
28827
+ try {
28828
+ if (!uri) {
28829
+ return this.createErrorResponse(id, -32602 /* InvalidParams */, "Missing resource template URI");
28830
+ }
28831
+ const resolved = await resolveResourceTemplate(
28832
+ uri,
28833
+ request.params?.variables,
28834
+ this.profileLoader,
28835
+ this.workspaceManager
28836
+ );
28837
+ return { jsonrpc: "2.0", id, result: resolved };
28838
+ } catch (error) {
28839
+ return this.createErrorResponse(id, -32603 /* InternalError */, `Failed to read resource template: ${error.message}`);
28840
+ }
28841
+ }
28602
28842
  /**
28603
28843
  * Validate tool input against its JSON schema.
28604
28844
  * Returns null if valid, or error message string if invalid.
@@ -28673,6 +28913,16 @@ Use this tool first to understand what AutomatosX offers.`,
28673
28913
  const { name, arguments: args } = request.params;
28674
28914
  logger.info("[MCP Server] Tool call", { tool: name });
28675
28915
  const requestId = id ?? null;
28916
+ if (this.toolAllowlist && !this.toolAllowlist.has(name)) {
28917
+ return this.createErrorResponse(id, -32600 /* InvalidRequest */, `Tool not allowed: ${name}`);
28918
+ }
28919
+ const schema = this.toolSchemas.find((t) => t.name === name);
28920
+ if (schema?.requiresAuth && this.authToken) {
28921
+ const provided = args?.auth_token;
28922
+ if (provided !== this.authToken) {
28923
+ return this.createErrorResponse(id, -32600 /* InvalidRequest */, "Unauthorized: invalid auth token");
28924
+ }
28925
+ }
28676
28926
  const abortController = requestId !== null ? new AbortController() : null;
28677
28927
  if (requestId !== null && abortController) {
28678
28928
  this.requestControllers.set(requestId, abortController);
package/dist/mcp/index.js CHANGED
@@ -4182,7 +4182,8 @@ function getVersion() {
4182
4182
 
4183
4183
  // src/mcp/types.ts
4184
4184
  init_esm_shims();
4185
- var MCP_PROTOCOL_VERSION = "2024-11-05";
4185
+ var MCP_PROTOCOL_VERSION = "2024-12-05";
4186
+ var MCP_SUPPORTED_VERSIONS = ["2024-12-05", "2024-11-05"];
4186
4187
 
4187
4188
  // src/mcp/server.ts
4188
4189
  init_logger();
@@ -5363,7 +5364,7 @@ var PRECOMPILED_CONFIG = {
5363
5364
  "enableFreeTierPrioritization": true,
5364
5365
  "enableWorkloadAwareRouting": true
5365
5366
  },
5366
- "version": "12.3.0"
5367
+ "version": "12.3.1"
5367
5368
  };
5368
5369
 
5369
5370
  // src/core/config/schemas.ts
@@ -8352,6 +8353,13 @@ var Router = class {
8352
8353
  }
8353
8354
  }
8354
8355
  }
8356
+ /**
8357
+ * Get the number of configured providers.
8358
+ * @returns Number of providers registered with this router
8359
+ */
8360
+ get providerCount() {
8361
+ return this.providers.length;
8362
+ }
8355
8363
  /**
8356
8364
  * Warm up provider availability caches immediately.
8357
8365
  * Phase 3 (v5.6.3): Eliminates cold-start latency on first request.
@@ -20627,7 +20635,11 @@ var McpClient = class _McpClient extends EventEmitter {
20627
20635
  const params = {
20628
20636
  protocolVersion: MCP_PROTOCOL_VERSION,
20629
20637
  capabilities: {
20630
- tools: {}
20638
+ tools: {},
20639
+ resources: {},
20640
+ prompts: {},
20641
+ resourceTemplates: {},
20642
+ experimental: {}
20631
20643
  },
20632
20644
  clientInfo: {
20633
20645
  name: "automatosx",
@@ -22433,6 +22445,93 @@ var CodexEventNormalizer = class extends BaseEventNormalizer {
22433
22445
  }
22434
22446
  };
22435
22447
 
22448
+ // src/mcp/resource-templates.ts
22449
+ init_esm_shims();
22450
+ var AGENT_TEMPLATE_NAME = "agent_profile";
22451
+ var AGENT_URI_TEMPLATE = "agent/{agent}";
22452
+ var WORKSPACE_PRD_TEMPLATE_NAME = "workspace_prd_file";
22453
+ var WORKSPACE_PRD_URI_TEMPLATE = "workspace/prd/{path}";
22454
+ var WORKSPACE_TMP_TEMPLATE_NAME = "workspace_tmp_file";
22455
+ var WORKSPACE_TMP_URI_TEMPLATE = "workspace/tmp/{path}";
22456
+ var RESOURCE_TEMPLATES = [
22457
+ {
22458
+ name: AGENT_TEMPLATE_NAME,
22459
+ uriTemplate: AGENT_URI_TEMPLATE,
22460
+ description: "Render an AutomatosX agent profile by name",
22461
+ mimeType: "text/markdown",
22462
+ variableDefinitions: [
22463
+ { name: "agent", description: "Agent name", required: true }
22464
+ ]
22465
+ },
22466
+ {
22467
+ name: WORKSPACE_PRD_TEMPLATE_NAME,
22468
+ uriTemplate: WORKSPACE_PRD_URI_TEMPLATE,
22469
+ description: "Read a PRD workspace file (automatosx/PRD)",
22470
+ mimeType: "text/markdown",
22471
+ variableDefinitions: [
22472
+ { name: "path", description: "Relative path under automatosx/PRD", required: true }
22473
+ ]
22474
+ },
22475
+ {
22476
+ name: WORKSPACE_TMP_TEMPLATE_NAME,
22477
+ uriTemplate: WORKSPACE_TMP_URI_TEMPLATE,
22478
+ description: "Read a temporary workspace file (automatosx/tmp)",
22479
+ mimeType: "text/markdown",
22480
+ variableDefinitions: [
22481
+ { name: "path", description: "Relative path under automatosx/tmp", required: true }
22482
+ ]
22483
+ }
22484
+ ];
22485
+ function listResourceTemplates() {
22486
+ return RESOURCE_TEMPLATES;
22487
+ }
22488
+ async function resolveResourceTemplate(uri, variables, profileLoader, workspaceManager) {
22489
+ if (uri === AGENT_URI_TEMPLATE) {
22490
+ const agent = variables?.agent;
22491
+ if (!agent) {
22492
+ throw new Error("Missing required variable: agent");
22493
+ }
22494
+ const profile = await profileLoader.loadProfile(agent);
22495
+ const summary = [
22496
+ `# ${agent}`,
22497
+ profile.role ? `**Role:** ${profile.role}` : "",
22498
+ profile.abilities?.length ? `**Abilities:** ${profile.abilities.join(", ")}` : "",
22499
+ "",
22500
+ profile.systemPrompt || "No system prompt defined."
22501
+ ].filter(Boolean).join("\n");
22502
+ return {
22503
+ uri: `agent/${agent}`,
22504
+ name: `Agent: ${agent}`,
22505
+ description: `AutomatosX agent profile for ${agent}`,
22506
+ mimeType: "text/markdown",
22507
+ contents: [
22508
+ { type: "text", text: summary },
22509
+ { type: "application/json", json: profile }
22510
+ ]
22511
+ };
22512
+ }
22513
+ if (uri === WORKSPACE_PRD_URI_TEMPLATE || uri === WORKSPACE_TMP_URI_TEMPLATE) {
22514
+ const path7 = variables?.path;
22515
+ if (!path7) {
22516
+ throw new Error("Missing required variable: path");
22517
+ }
22518
+ const isPrd = uri === WORKSPACE_PRD_URI_TEMPLATE;
22519
+ const readFn = isPrd ? workspaceManager.readPRD.bind(workspaceManager) : workspaceManager.readTmp.bind(workspaceManager);
22520
+ const content = await readFn(path7);
22521
+ return {
22522
+ uri: `${isPrd ? "prd" : "tmp"}/${path7}`,
22523
+ name: `${isPrd ? "PRD" : "Tmp"}: ${path7}`,
22524
+ description: `Workspace ${isPrd ? "PRD" : "tmp"} file`,
22525
+ mimeType: "text/markdown",
22526
+ contents: [
22527
+ { type: "text", text: content },
22528
+ { type: "application/json", json: { path: path7, content, workspace: isPrd ? "PRD" : "tmp" } }
22529
+ ]
22530
+ };
22531
+ }
22532
+ throw new Error(`Unknown resource template: ${uri}`);
22533
+ }
22534
+
22436
22535
  // src/mcp/server.ts
22437
22536
  var CLIENT_PATTERNS = [
22438
22537
  [["claude"], "claude"],
@@ -22468,6 +22567,8 @@ var McpServer = class _McpServer {
22468
22567
  // Track client-initiated cancellations
22469
22568
  requestControllers = /* @__PURE__ */ new Map();
22470
22569
  // Abort long-running handlers
22570
+ toolAllowlist;
22571
+ authToken;
22471
22572
  // v10.5.0: MCP Session for Smart Routing
22472
22573
  session = null;
22473
22574
  // v10.6.0: MCP Client Pool for cross-provider execution
@@ -22476,6 +22577,7 @@ var McpServer = class _McpServer {
22476
22577
  eventBridge = null;
22477
22578
  streamingNotifier = null;
22478
22579
  enableStreamingNotifications = true;
22580
+ negotiatedProtocolVersion = MCP_PROTOCOL_VERSION;
22479
22581
  // Shared services (initialized once per server)
22480
22582
  router;
22481
22583
  memoryManager;
@@ -22489,6 +22591,12 @@ var McpServer = class _McpServer {
22489
22591
  if (options.debug) {
22490
22592
  setLogLevel("debug");
22491
22593
  }
22594
+ if (options.toolAllowlist?.length) {
22595
+ this.toolAllowlist = new Set(options.toolAllowlist);
22596
+ }
22597
+ if (options.authToken) {
22598
+ this.authToken = options.authToken;
22599
+ }
22492
22600
  this.enableStreamingNotifications = options.enableStreamingNotifications ?? true;
22493
22601
  this.version = getVersion();
22494
22602
  this.ajv = new Ajv({ allErrors: true });
@@ -22498,6 +22606,24 @@ var McpServer = class _McpServer {
22498
22606
  streamingNotifications: this.enableStreamingNotifications
22499
22607
  });
22500
22608
  }
22609
+ /** Determine if negotiated protocol is v2 */
22610
+ isV2Protocol() {
22611
+ return this.negotiatedProtocolVersion === MCP_SUPPORTED_VERSIONS[0];
22612
+ }
22613
+ /** Build capability set based on negotiated protocol */
22614
+ buildCapabilities() {
22615
+ const base = { tools: {} };
22616
+ if (this.isV2Protocol()) {
22617
+ return {
22618
+ ...base,
22619
+ resources: {},
22620
+ prompts: {},
22621
+ resourceTemplates: {},
22622
+ experimental: {}
22623
+ };
22624
+ }
22625
+ return base;
22626
+ }
22501
22627
  /**
22502
22628
  * Get static tool schemas (no initialization required)
22503
22629
  * Returns tool schemas that can be provided during MCP handshake
@@ -22877,6 +23003,14 @@ Use this tool first to understand what AutomatosX offers.`,
22877
23003
  return await this.handleResourcesList(request, responseId);
22878
23004
  case "resources/read":
22879
23005
  return await this.handleResourceRead(request, responseId);
23006
+ case "resources/templates/list":
23007
+ return await this.handleResourceTemplatesList(request, responseId);
23008
+ case "resources/templates/read":
23009
+ return await this.handleResourceTemplateRead(request, responseId);
23010
+ case "prompts/list":
23011
+ return await this.handlePromptsList(request, responseId);
23012
+ case "prompts/get":
23013
+ return await this.handlePromptGet(request, responseId);
22880
23014
  case "$/cancelRequest":
22881
23015
  return this.handleCancelRequest(request, responseId);
22882
23016
  default:
@@ -22915,9 +23049,12 @@ Use this tool first to understand what AutomatosX offers.`,
22915
23049
  clientName: clientInfo.name,
22916
23050
  normalizedProvider: this.session.normalizedProvider
22917
23051
  });
23052
+ const requestedProtocol = request.params?.protocolVersion;
23053
+ const negotiated = MCP_SUPPORTED_VERSIONS.find((version) => version === requestedProtocol) ?? MCP_SUPPORTED_VERSIONS[0];
23054
+ this.negotiatedProtocolVersion = negotiated;
22918
23055
  const response = {
22919
- protocolVersion: MCP_PROTOCOL_VERSION,
22920
- capabilities: { tools: {} },
23056
+ protocolVersion: negotiated,
23057
+ capabilities: this.buildCapabilities(),
22921
23058
  serverInfo: { name: "automatosx", version: this.version }
22922
23059
  };
22923
23060
  logger.info("[MCP Server] Initialize handshake complete (< 1ms)");
@@ -22931,7 +23068,11 @@ Use this tool first to understand what AutomatosX offers.`,
22931
23068
  */
22932
23069
  handleToolsList(_request, id) {
22933
23070
  logger.debug("[MCP Server] Tools list requested (static schemas)");
22934
- const tools = _McpServer.getStaticToolSchemas();
23071
+ const tools = _McpServer.getStaticToolSchemas().map((schema) => ({
23072
+ ...schema,
23073
+ // If allowlist is set, hide tools not allowed
23074
+ ...this.toolAllowlist && !this.toolAllowlist.has(schema.name) ? { hidden: true } : {}
23075
+ }));
22935
23076
  return { jsonrpc: "2.0", id, result: { tools } };
22936
23077
  }
22937
23078
  /**
@@ -22948,6 +23089,81 @@ Use this tool first to understand what AutomatosX offers.`,
22948
23089
  }));
22949
23090
  return { jsonrpc: "2.0", id, result: { resources } };
22950
23091
  }
23092
+ /**
23093
+ * Handle resources/templates/list request (v2 capability)
23094
+ */
23095
+ async handleResourceTemplatesList(_request, id) {
23096
+ if (!this.isV2Protocol()) {
23097
+ return this.createErrorResponse(id, -32601 /* MethodNotFound */, "resources/templates/list is only available in MCP v2");
23098
+ }
23099
+ await this.ensureInitialized();
23100
+ const resourceTemplates = listResourceTemplates();
23101
+ return { jsonrpc: "2.0", id, result: { resourceTemplates } };
23102
+ }
23103
+ /**
23104
+ * Handle prompts/list request (expose common starter prompts)
23105
+ */
23106
+ async handlePromptsList(_request, id) {
23107
+ await this.ensureInitialized();
23108
+ const prompts = [
23109
+ {
23110
+ name: "agent_context",
23111
+ description: "Get agent context and system prompt for a given agent name",
23112
+ arguments: [{ name: "agent", required: true, description: "Agent name" }]
23113
+ },
23114
+ {
23115
+ name: "status",
23116
+ description: "Get AutomatosX MCP status summary"
23117
+ }
23118
+ ];
23119
+ return { jsonrpc: "2.0", id, result: { prompts } };
23120
+ }
23121
+ /**
23122
+ * Handle prompts/get request
23123
+ */
23124
+ async handlePromptGet(request, id) {
23125
+ await this.ensureInitialized();
23126
+ const name = request.params?.name;
23127
+ if (!name) {
23128
+ return this.createErrorResponse(id, -32602 /* InvalidParams */, "Prompt name is required");
23129
+ }
23130
+ switch (name) {
23131
+ case "agent_context": {
23132
+ const agent = request.params?.arguments?.agent;
23133
+ if (!agent) {
23134
+ return this.createErrorResponse(id, -32602 /* InvalidParams */, "agent argument is required");
23135
+ }
23136
+ try {
23137
+ const profile = await this.profileLoader.loadProfile(agent);
23138
+ const content = [
23139
+ { type: "text", text: `System prompt for ${agent}:
23140
+ ${profile.systemPrompt || "No system prompt defined."}` },
23141
+ { type: "application/json", json: profile }
23142
+ ];
23143
+ return { jsonrpc: "2.0", id, result: { prompt: { name, description: "Agent context", arguments: [{ name: "agent", required: true }] }, content } };
23144
+ } catch (error) {
23145
+ return this.createErrorResponse(id, -32603 /* InternalError */, `Failed to load agent: ${error.message}`);
23146
+ }
23147
+ }
23148
+ case "status": {
23149
+ const summary = {
23150
+ version: this.version,
23151
+ providerCount: this.router?.providerCount ?? 0,
23152
+ streamingNotifications: this.enableStreamingNotifications
23153
+ };
23154
+ const content = [
23155
+ { type: "text", text: `AutomatosX MCP status:
23156
+ Version: ${summary.version}
23157
+ Providers: ${summary.providerCount}
23158
+ Streaming: ${summary.streamingNotifications}` },
23159
+ { type: "application/json", json: summary }
23160
+ ];
23161
+ return { jsonrpc: "2.0", id, result: { prompt: { name, description: "AutomatosX status" }, content } };
23162
+ }
23163
+ default:
23164
+ return this.createErrorResponse(id, -32601 /* MethodNotFound */, `Prompt not found: ${name}`);
23165
+ }
23166
+ }
22951
23167
  /**
22952
23168
  * Handle resources/read request
22953
23169
  */
@@ -22976,6 +23192,30 @@ Use this tool first to understand what AutomatosX offers.`,
22976
23192
  return this.createErrorResponse(id, -32603 /* InternalError */, `Failed to read resource: ${error.message}`);
22977
23193
  }
22978
23194
  }
23195
+ /**
23196
+ * Handle resources/templates/read request (v2 capability)
23197
+ */
23198
+ async handleResourceTemplateRead(request, id) {
23199
+ if (!this.isV2Protocol()) {
23200
+ return this.createErrorResponse(id, -32601 /* MethodNotFound */, "resources/templates/read is only available in MCP v2");
23201
+ }
23202
+ await this.ensureInitialized();
23203
+ const uri = request.params?.uri;
23204
+ try {
23205
+ if (!uri) {
23206
+ return this.createErrorResponse(id, -32602 /* InvalidParams */, "Missing resource template URI");
23207
+ }
23208
+ const resolved = await resolveResourceTemplate(
23209
+ uri,
23210
+ request.params?.variables,
23211
+ this.profileLoader,
23212
+ this.workspaceManager
23213
+ );
23214
+ return { jsonrpc: "2.0", id, result: resolved };
23215
+ } catch (error) {
23216
+ return this.createErrorResponse(id, -32603 /* InternalError */, `Failed to read resource template: ${error.message}`);
23217
+ }
23218
+ }
22979
23219
  /**
22980
23220
  * Validate tool input against its JSON schema.
22981
23221
  * Returns null if valid, or error message string if invalid.
@@ -23050,6 +23290,16 @@ Use this tool first to understand what AutomatosX offers.`,
23050
23290
  const { name, arguments: args2 } = request.params;
23051
23291
  logger.info("[MCP Server] Tool call", { tool: name });
23052
23292
  const requestId = id ?? null;
23293
+ if (this.toolAllowlist && !this.toolAllowlist.has(name)) {
23294
+ return this.createErrorResponse(id, -32600 /* InvalidRequest */, `Tool not allowed: ${name}`);
23295
+ }
23296
+ const schema = this.toolSchemas.find((t) => t.name === name);
23297
+ if (schema?.requiresAuth && this.authToken) {
23298
+ const provided = args2?.auth_token;
23299
+ if (provided !== this.authToken) {
23300
+ return this.createErrorResponse(id, -32600 /* InvalidRequest */, "Unauthorized: invalid auth token");
23301
+ }
23302
+ }
23053
23303
  const abortController = requestId !== null ? new AbortController() : null;
23054
23304
  if (requestId !== null && abortController) {
23055
23305
  this.requestControllers.set(requestId, abortController);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defai.digital/automatosx",
3
- "version": "12.3.0",
3
+ "version": "12.3.1",
4
4
  "description": "Provider-agnostic AI orchestration platform with 20+ specialized agents, persistent memory, and multi-provider routing for Claude Code, Gemini CLI, Codex CLI, GLM, and Grok",
5
5
  "type": "module",
6
6
  "publishConfig": {