@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/index.js
CHANGED
|
@@ -251,6 +251,15 @@ function normalizeByMessage(err) {
|
|
|
251
251
|
category: "remote_state"
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
|
+
if (statusCode === 409) {
|
|
255
|
+
return makeNormalized({
|
|
256
|
+
code: ERROR_CODES.REMOTE_ERROR,
|
|
257
|
+
message,
|
|
258
|
+
hint,
|
|
259
|
+
retryable: true,
|
|
260
|
+
category: "remote_state"
|
|
261
|
+
});
|
|
262
|
+
}
|
|
254
263
|
if (message.includes("Timed out") || message.includes("failed") || message.includes("error state")) {
|
|
255
264
|
return makeNormalized({
|
|
256
265
|
code: ERROR_CODES.REMOTE_ERROR,
|
|
@@ -427,7 +436,6 @@ function makeSuccessResult(envelope) {
|
|
|
427
436
|
function makeErrorResult(envelope) {
|
|
428
437
|
return {
|
|
429
438
|
content: [{ type: "text", text: toJsonText(envelope) }],
|
|
430
|
-
structuredContent: envelope,
|
|
431
439
|
isError: true
|
|
432
440
|
};
|
|
433
441
|
}
|
|
@@ -1812,6 +1820,24 @@ function buildErrorEnvelope(tool, requestId, error) {
|
|
|
1812
1820
|
recommendedNextActions
|
|
1813
1821
|
};
|
|
1814
1822
|
}
|
|
1823
|
+
function buildOutputValidationErrorEnvelope(tool, requestId, error) {
|
|
1824
|
+
return {
|
|
1825
|
+
schemaVersion: SCHEMA_VERSION,
|
|
1826
|
+
ok: false,
|
|
1827
|
+
tool,
|
|
1828
|
+
requestId: requestId ?? null,
|
|
1829
|
+
error: {
|
|
1830
|
+
code: ERROR_CODES.INTERNAL_ERROR,
|
|
1831
|
+
message: "Tool output failed validation against its declared MCP schema.",
|
|
1832
|
+
hint: error.issues.map((issue) => `${issue.path.join(".") || "output"}: ${issue.message}`).join("; "),
|
|
1833
|
+
retryable: false,
|
|
1834
|
+
category: "internal"
|
|
1835
|
+
},
|
|
1836
|
+
warnings: [],
|
|
1837
|
+
risks: ["The MCP server returned an output shape that did not match the tool descriptor."],
|
|
1838
|
+
recommendedNextActions: ["Report this MCP schema mismatch with the tool name and error hint."]
|
|
1839
|
+
};
|
|
1840
|
+
}
|
|
1815
1841
|
function registerTool(server, context, params) {
|
|
1816
1842
|
const errorSchema = makeErrorSchema();
|
|
1817
1843
|
server.registerTool(
|
|
@@ -1830,7 +1856,20 @@ function registerTool(server, context, params) {
|
|
|
1830
1856
|
assertToolAccess(context.policy, params.access);
|
|
1831
1857
|
const result = await params.run(rawArgs);
|
|
1832
1858
|
const envelope = buildSuccessEnvelope(params.name, requestId, result);
|
|
1833
|
-
params.outputSchema.
|
|
1859
|
+
const parsedEnvelope = params.outputSchema.safeParse(envelope);
|
|
1860
|
+
if (!parsedEnvelope.success) {
|
|
1861
|
+
const errorEnvelope = buildOutputValidationErrorEnvelope(params.name, requestId, parsedEnvelope.error);
|
|
1862
|
+
context.logger.log({
|
|
1863
|
+
level: "error",
|
|
1864
|
+
message: "tool_output_validation_failed",
|
|
1865
|
+
tool: params.name,
|
|
1866
|
+
requestId: errorEnvelope.requestId,
|
|
1867
|
+
durationMs: Date.now() - startedAt,
|
|
1868
|
+
result: "error",
|
|
1869
|
+
errorCode: errorEnvelope.error.code
|
|
1870
|
+
});
|
|
1871
|
+
return makeErrorResult(errorEnvelope);
|
|
1872
|
+
}
|
|
1834
1873
|
context.logger.log({
|
|
1835
1874
|
level: "info",
|
|
1836
1875
|
message: "tool_completed",
|