@mozilla-ai/mcpd 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -609,12 +609,20 @@ import {
609
609
  ToolExecutionError, // Tool execution failed
610
610
  ValidationError, // Input validation failed
611
611
  TimeoutError, // Operation timed out
612
+ PipelineError, // Pipeline processing failed
612
613
  } from "@mozilla-ai/mcpd";
613
614
 
614
615
  try {
615
616
  const result = await client.servers.unknown.tools.tool();
616
617
  } catch (error) {
617
- if (error instanceof ToolNotFoundError) {
618
+ if (error instanceof PipelineError) {
619
+ // Pipeline failure - a required plugin failed during processing.
620
+ console.error(`Pipeline ${error.pipelineFlow} failure:`, error.message);
621
+ if (error.pipelineFlow === "response") {
622
+ // Tool was called but results cannot be delivered.
623
+ console.error("A required plugin failed during response processing");
624
+ }
625
+ } else if (error instanceof ToolNotFoundError) {
618
626
  console.error(
619
627
  `Tool not found: ${error.toolName} on server ${error.serverName}`,
620
628
  );
@@ -626,6 +634,20 @@ try {
626
634
  }
627
635
  ```
628
636
 
637
+ ### PipelineError
638
+
639
+ The `PipelineError` is thrown when mcpd's plugin pipeline fails. This indicates a problem with a plugin or an external system that a plugin depends on (e.g., audit service, authentication provider), not a problem with your request or the tool itself.
640
+
641
+ - **Response Pipeline Failure** (`pipelineFlow === 'response'`): The upstream request was processed (the tool was called), but results cannot be returned because a required plugin (like audit logging) failed during response processing. This does not indicate whether the tool itself succeeded or failed.
642
+ - **Request Pipeline Failure** (`pipelineFlow === 'request'`): The request was rejected before reaching the upstream server because a required plugin (like authentication) failed during request processing.
643
+
644
+ Properties:
645
+
646
+ - `message: string` - Descriptive error message
647
+ - `serverName?: string` - The server name (when called through tool execution)
648
+ - `operation?: string` - The operation (e.g., "time.get_current_time")
649
+ - `pipelineFlow?: 'request' | 'response'` - Which pipeline flow failed
650
+
629
651
  ## Development
630
652
 
631
653
  ### Setup
@@ -1 +1 @@
1
- {"version":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O,EAAE,oBAAoB,GAC5B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CA+DvC"}
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,16 @@
1
1
  import { ErrorModel } from './types';
2
+ /**
3
+ * Pipeline flow constant for request processing failures.
4
+ */
5
+ export declare const PIPELINE_FLOW_REQUEST: "request";
6
+ /**
7
+ * Pipeline flow constant for response processing failures.
8
+ */
9
+ export declare const PIPELINE_FLOW_RESPONSE: "response";
10
+ /**
11
+ * Pipeline flow indicating where in the pipeline the failure occurred.
12
+ */
13
+ export type PipelineFlow = typeof PIPELINE_FLOW_REQUEST | typeof PIPELINE_FLOW_RESPONSE;
2
14
  /**
3
15
  * Base exception for all mcpd SDK errors.
4
16
  *
@@ -110,4 +122,60 @@ export declare class TimeoutError extends McpdError {
110
122
  readonly timeout: number | undefined;
111
123
  constructor(message: string, operation?: string, timeout?: number, cause?: Error);
112
124
  }
125
+ /**
126
+ * Raised when required pipeline processing fails.
127
+ *
128
+ * This indicates that required processing failed in the mcpd pipeline.
129
+ * The error occurs when a required plugin (such as authentication, validation,
130
+ * audit logging, monitoring, or response transformation) fails during request
131
+ * or response processing.
132
+ *
133
+ * Pipeline Flow Distinction:
134
+ * - **response-pipeline-failure**: The upstream request was processed (the tool
135
+ * was called), but results cannot be returned due to a required response
136
+ * processing step failure. Note: This does not indicate whether the tool
137
+ * itself succeeded or failed - only that the response cannot be delivered.
138
+ *
139
+ * - **request-pipeline-failure**: The request was rejected before reaching the
140
+ * upstream server due to a required request processing step failure (such as
141
+ * authentication, authorization, validation, or rate limiting plugin failure).
142
+ *
143
+ * This typically indicates a problem with a plugin or an external system
144
+ * that a plugin depends on (e.g., audit service, authentication provider).
145
+ * Retrying is unlikely to help as this usually indicates a configuration
146
+ * or dependency problem rather than a transient failure.
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * import { McpdClient, PipelineError } from '@mozilla-ai/mcpd';
151
+ *
152
+ * const client = new McpdClient({ apiEndpoint: 'http://localhost:8090' });
153
+ *
154
+ * try {
155
+ * const result = await client.servers.time.tools.get_current_time();
156
+ * } catch (error) {
157
+ * if (error instanceof PipelineError) {
158
+ * console.log(`Pipeline failure: ${error.message}`);
159
+ * console.log(`Flow: ${error.pipelineFlow}`);
160
+ *
161
+ * if (error.pipelineFlow === 'response') {
162
+ * console.log('Tool was called but results cannot be delivered');
163
+ * } else {
164
+ * console.log('Request was rejected by pipeline');
165
+ * console.log('Check authentication, authorization, or rate limiting');
166
+ * }
167
+ * }
168
+ * }
169
+ * ```
170
+ *
171
+ * @remarks
172
+ * This exception indicates a problem with a plugin or its dependencies, not
173
+ * with your request or the tool itself.
174
+ */
175
+ export declare class PipelineError extends McpdError {
176
+ readonly serverName: string | undefined;
177
+ readonly operation: string | undefined;
178
+ readonly pipelineFlow: PipelineFlow | undefined;
179
+ constructor(message: string, serverName?: string, operation?: string, pipelineFlow?: PipelineFlow, cause?: Error);
180
+ }
113
181
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;GAMG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAM3C;AAED;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAK3C;AAED;;;;;;;GAOG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAK3C;AAED;;;;;;;GAOG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,SAAgB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEn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;;;;;;;;;;;;;;;;;;;GAiDG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,SAAgB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/C,SAAgB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,SAAgB,YAAY,EAAE,YAAY,GAAG,SAAS,CAAC;gBAGrD,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,YAAY,EAC3B,KAAK,CAAC,EAAE,KAAK;CAShB"}
package/dist/index.d.ts CHANGED
@@ -15,6 +15,6 @@
15
15
  * @packageDocumentation
16
16
  */
17
17
  export { McpdClient } from './client';
18
- export { McpdError, AuthenticationError, ConnectionError, ServerNotFoundError, ServerUnhealthyError, TimeoutError, ToolExecutionError, ToolNotFoundError, ValidationError, } from './errors';
18
+ export { McpdError, AuthenticationError, ConnectionError, PipelineError, PIPELINE_FLOW_REQUEST, PIPELINE_FLOW_RESPONSE, ServerNotFoundError, ServerUnhealthyError, TimeoutError, ToolExecutionError, ToolNotFoundError, ValidationError, type PipelineFlow, } from './errors';
19
19
  export { HealthStatus, HealthStatusHelpers, type JsonSchema, type Tool, type Tools, type ToolAnnotations, type ServerHealth, type ToolsResponse, type HealthResponse, type McpdClientOptions, type ErrorDetail, type ErrorModel, type AgentToolsFormat, type BaseAgentToolsOptions, type ArrayAgentToolsOptions, type ObjectAgentToolsOptions, type MapAgentToolsOptions, type AgentToolsOptions, type Resource, type Resources, type ResourceContent, type ResourceTemplate, type ResourceTemplates, type Prompt, type PromptArgument, type Prompts, type PromptMessage, type PromptGenerateArguments, type GeneratePromptResponseBody, } from './types';
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAChB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,GAChC,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,KAAK,YAAY,GAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,GAChC,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const lruCache = require("lru-cache");
4
4
  const zod = require("zod");
5
+ const PIPELINE_FLOW_REQUEST = "request";
6
+ const PIPELINE_FLOW_RESPONSE = "response";
5
7
  class McpdError extends Error {
6
8
  constructor(message, cause) {
7
9
  super(message);
@@ -88,6 +90,19 @@ class TimeoutError extends McpdError {
88
90
  Error.captureStackTrace(this, this.constructor);
89
91
  }
90
92
  }
93
+ class PipelineError extends McpdError {
94
+ serverName;
95
+ operation;
96
+ pipelineFlow;
97
+ constructor(message, serverName, operation, pipelineFlow, cause) {
98
+ super(message, cause);
99
+ this.name = "PipelineError";
100
+ this.serverName = serverName;
101
+ this.operation = operation;
102
+ this.pipelineFlow = pipelineFlow;
103
+ Error.captureStackTrace(this, this.constructor);
104
+ }
105
+ }
91
106
  var HealthStatus = /* @__PURE__ */ ((HealthStatus2) => {
92
107
  HealthStatus2["OK"] = "ok";
93
108
  HealthStatus2["TIMEOUT"] = "timeout";
@@ -1044,6 +1059,11 @@ const REQUEST_TIMEOUT_SECONDS = 30;
1044
1059
  const SERVER_HEALTH_CACHE_TTL_SECONDS = 10;
1045
1060
  const SERVER_HEALTH_CACHE_MAXSIZE = 100;
1046
1061
  const TOOL_SEPARATOR = "__";
1062
+ const MCPD_ERROR_TYPE_HEADER = "Mcpd-Error-Type";
1063
+ const PIPELINE_ERROR_FLOWS = {
1064
+ "request-pipeline-failure": PIPELINE_FLOW_REQUEST,
1065
+ "response-pipeline-failure": PIPELINE_FLOW_RESPONSE
1066
+ };
1047
1067
  class McpdClient {
1048
1068
  #endpoint;
1049
1069
  #apiKey;
@@ -1130,6 +1150,21 @@ class McpdClient {
1130
1150
  } catch {
1131
1151
  errorModel = null;
1132
1152
  }
1153
+ if (response.status === 500) {
1154
+ const errorType = response.headers.get(MCPD_ERROR_TYPE_HEADER)?.toLowerCase();
1155
+ const flow = errorType ? PIPELINE_ERROR_FLOWS[errorType] : void 0;
1156
+ if (flow) {
1157
+ const message = errorModel?.detail || body || "Pipeline failure";
1158
+ throw new PipelineError(
1159
+ message,
1160
+ void 0,
1161
+ // serverName - enriched by caller if available.
1162
+ void 0,
1163
+ // operation - enriched by caller if available.
1164
+ flow
1165
+ );
1166
+ }
1167
+ }
1133
1168
  if (errorModel && errorModel.detail) {
1134
1169
  const errorDetails = errorModel.errors?.map((e) => `${e.location}: ${e.message}`).join("; ");
1135
1170
  const fullMessage = errorDetails ? `${errorModel.detail} - ${errorDetails}` : errorModel.detail;
@@ -1562,6 +1597,15 @@ class McpdClient {
1562
1597
  }
1563
1598
  return response;
1564
1599
  } catch (error) {
1600
+ if (error instanceof PipelineError) {
1601
+ throw new PipelineError(
1602
+ error.message,
1603
+ serverName,
1604
+ `${serverName}.${toolName}`,
1605
+ error.pipelineFlow,
1606
+ error.cause
1607
+ );
1608
+ }
1565
1609
  if (error instanceof McpdError) {
1566
1610
  throw error;
1567
1611
  }
@@ -1679,6 +1723,9 @@ exports.HealthStatus = HealthStatus;
1679
1723
  exports.HealthStatusHelpers = HealthStatusHelpers;
1680
1724
  exports.McpdClient = McpdClient;
1681
1725
  exports.McpdError = McpdError;
1726
+ exports.PIPELINE_FLOW_REQUEST = PIPELINE_FLOW_REQUEST;
1727
+ exports.PIPELINE_FLOW_RESPONSE = PIPELINE_FLOW_RESPONSE;
1728
+ exports.PipelineError = PipelineError;
1682
1729
  exports.ServerNotFoundError = ServerNotFoundError;
1683
1730
  exports.ServerUnhealthyError = ServerUnhealthyError;
1684
1731
  exports.TimeoutError = TimeoutError;