Remove prefix on over-the-wire ProtocolErrors (#1727)

Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
This commit is contained in:
Konstantin Konstantinov 2026-03-23 17:46:32 +02:00 • committed by GitHub
commit a7c7896a56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 7 deletions

View file

@ -2340,7 +2340,7 @@ export class ProtocolError extends Error {
message: string,
public readonly data?: unknown
) {
super(`MCP error ${code}: ${message}`);
super(message);
this.name = 'ProtocolError';
}

View file

@ -809,7 +809,7 @@ test('should wrap unexpected validator errors during elicitInput', async () => {
required: []
}
})
).rejects.toThrow('MCP error -32603: Error validating elicitation response: boom - validator exploded');
).rejects.toThrow('Error validating elicitation response: boom - validator exploded');
});
test('should forward notification options when using elicitation completion notifier', async () => {

View file

@ -841,7 +841,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
required: ['color']
}
})
).rejects.toThrow(/^MCP error -32602: Elicitation response content does not match requested schema/);
).rejects.toThrow(/^Elicitation response content does not match requested schema/);
});
test(`${validatorName}: should reject invalid selection in single-select titled enum`, async () => {
@ -875,7 +875,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
required: ['color']
}
})
).rejects.toThrow(/^MCP error -32602: Elicitation response content does not match requested schema/);
).rejects.toThrow(/^Elicitation response content does not match requested schema/);
});
test(`${validatorName}: should reject invalid selection in single-select titled legacy enum`, async () => {
@ -906,7 +906,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
required: ['color']
}
})
).rejects.toThrow(/^MCP error -32602: Elicitation response content does not match requested schema/);
).rejects.toThrow(/^Elicitation response content does not match requested schema/);
});
// Enums - Invalid - Multi Select - Untitled / Titled
@ -943,7 +943,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
required: ['color']
}
})
).rejects.toThrow(/^MCP error -32602: Elicitation response content does not match requested schema/);
).rejects.toThrow(/^Elicitation response content does not match requested schema/);
});
test(`${validatorName}: should reject invalid selection in multi-select titled enum`, async () => {
@ -981,6 +981,6 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
required: ['colors']
}
})
).rejects.toThrow(/^MCP error -32602: Elicitation response content does not match requested schema/);
).rejects.toThrow(/^Elicitation response content does not match requested schema/);
});
}