@remixhq/mcp 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +41 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/dist/server.js +41 -2
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -255,6 +255,15 @@ function normalizeByMessage(err) {
|
|
|
255
255
|
category: "remote_state"
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
|
+
if (statusCode === 409) {
|
|
259
|
+
return makeNormalized({
|
|
260
|
+
code: ERROR_CODES.REMOTE_ERROR,
|
|
261
|
+
message,
|
|
262
|
+
hint,
|
|
263
|
+
retryable: true,
|
|
264
|
+
category: "remote_state"
|
|
265
|
+
});
|
|
266
|
+
}
|
|
258
267
|
if (message.includes("Timed out") || message.includes("failed") || message.includes("error state")) {
|
|
259
268
|
return makeNormalized({
|
|
260
269
|
code: ERROR_CODES.REMOTE_ERROR,
|
|
@@ -431,7 +440,6 @@ function makeSuccessResult(envelope) {
|
|
|
431
440
|
function makeErrorResult(envelope) {
|
|
432
441
|
return {
|
|
433
442
|
content: [{ type: "text", text: toJsonText(envelope) }],
|
|
434
|
-
structuredContent: envelope,
|
|
435
443
|
isError: true
|
|
436
444
|
};
|
|
437
445
|
}
|
|
@@ -1816,6 +1824,24 @@ function buildErrorEnvelope(tool, requestId, error) {
|
|
|
1816
1824
|
recommendedNextActions
|
|
1817
1825
|
};
|
|
1818
1826
|
}
|
|
1827
|
+
function buildOutputValidationErrorEnvelope(tool, requestId, error) {
|
|
1828
|
+
return {
|
|
1829
|
+
schemaVersion: SCHEMA_VERSION,
|
|
1830
|
+
ok: false,
|
|
1831
|
+
tool,
|
|
1832
|
+
requestId: requestId ?? null,
|
|
1833
|
+
error: {
|
|
1834
|
+
code: ERROR_CODES.INTERNAL_ERROR,
|
|
1835
|
+
message: "Tool output failed validation against its declared MCP schema.",
|
|
1836
|
+
hint: error.issues.map((issue) => `${issue.path.join(".") || "output"}: ${issue.message}`).join("; "),
|
|
1837
|
+
retryable: false,
|
|
1838
|
+
category: "internal"
|
|
1839
|
+
},
|
|
1840
|
+
warnings: [],
|
|
1841
|
+
risks: ["The MCP server returned an output shape that did not match the tool descriptor."],
|
|
1842
|
+
recommendedNextActions: ["Report this MCP schema mismatch with the tool name and error hint."]
|
|
1843
|
+
};
|
|
1844
|
+
}
|
|
1819
1845
|
function registerTool(server, context, params) {
|
|
1820
1846
|
const errorSchema = makeErrorSchema();
|
|
1821
1847
|
server.registerTool(
|
|
@@ -1834,7 +1860,20 @@ function registerTool(server, context, params) {
|
|
|
1834
1860
|
assertToolAccess(context.policy, params.access);
|
|
1835
1861
|
const result = await params.run(rawArgs);
|
|
1836
1862
|
const envelope = buildSuccessEnvelope(params.name, requestId, result);
|
|
1837
|
-
params.outputSchema.
|
|
1863
|
+
const parsedEnvelope = params.outputSchema.safeParse(envelope);
|
|
1864
|
+
if (!parsedEnvelope.success) {
|
|
1865
|
+
const errorEnvelope = buildOutputValidationErrorEnvelope(params.name, requestId, parsedEnvelope.error);
|
|
1866
|
+
context.logger.log({
|
|
1867
|
+
level: "error",
|
|
1868
|
+
message: "tool_output_validation_failed",
|
|
1869
|
+
tool: params.name,
|
|
1870
|
+
requestId: errorEnvelope.requestId,
|
|
1871
|
+
durationMs: Date.now() - startedAt,
|
|
1872
|
+
result: "error",
|
|
1873
|
+
errorCode: errorEnvelope.error.code
|
|
1874
|
+
});
|
|
1875
|
+
return makeErrorResult(errorEnvelope);
|
|
1876
|
+
}
|
|
1838
1877
|
context.logger.log({
|
|
1839
1878
|
level: "info",
|
|
1840
1879
|
message: "tool_completed",
|