Skip to content

Commit a7c7896

Browse files
Remove prefix on over-the-wire ProtocolErrors (#1727)
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
1 parent 72fe68b commit a7c7896

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

packages/core/src/types/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,7 @@ export class ProtocolError extends Error {
23402340
message: string,
23412341
public readonly data?: unknown
23422342
) {
2343-
super(`MCP error ${code}: ${message}`);
2343+
super(message);
23442344
this.name = 'ProtocolError';
23452345
}
23462346

test/integration/test/server.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ test('should wrap unexpected validator errors during elicitInput', async () => {
809809
required: []
810810
}
811811
})
812-
).rejects.toThrow('MCP error -32603: Error validating elicitation response: boom - validator exploded');
812+
).rejects.toThrow('Error validating elicitation response: boom - validator exploded');
813813
});
814814

815815
test('should forward notification options when using elicitation completion notifier', async () => {

test/integration/test/server/elicitation.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
841841
required: ['color']
842842
}
843843
})
844-
).rejects.toThrow(/^MCP error -32602: Elicitation response content does not match requested schema/);
844+
).rejects.toThrow(/^Elicitation response content does not match requested schema/);
845845
});
846846

847847
test(`${validatorName}: should reject invalid selection in single-select titled enum`, async () => {
@@ -875,7 +875,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
875875
required: ['color']
876876
}
877877
})
878-
).rejects.toThrow(/^MCP error -32602: Elicitation response content does not match requested schema/);
878+
).rejects.toThrow(/^Elicitation response content does not match requested schema/);
879879
});
880880

881881
test(`${validatorName}: should reject invalid selection in single-select titled legacy enum`, async () => {
@@ -906,7 +906,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
906906
required: ['color']
907907
}
908908
})
909-
).rejects.toThrow(/^MCP error -32602: Elicitation response content does not match requested schema/);
909+
).rejects.toThrow(/^Elicitation response content does not match requested schema/);
910910
});
911911

912912
// Enums - Invalid - Multi Select - Untitled / Titled
@@ -943,7 +943,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
943943
required: ['color']
944944
}
945945
})
946-
).rejects.toThrow(/^MCP error -32602: Elicitation response content does not match requested schema/);
946+
).rejects.toThrow(/^Elicitation response content does not match requested schema/);
947947
});
948948

949949
test(`${validatorName}: should reject invalid selection in multi-select titled enum`, async () => {
@@ -981,6 +981,6 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
981981
required: ['colors']
982982
}
983983
})
984-
).rejects.toThrow(/^MCP error -32602: Elicitation response content does not match requested schema/);
984+
).rejects.toThrow(/^Elicitation response content does not match requested schema/);
985985
});
986986
}

0 commit comments

Comments
 (0)