Skip to content

Commit 3507f94

Browse files
halter73Copilot
andauthored
fix(sep-2243): reject x-mcp-header on number-typed params (#444)
SEP-2243 permits `x-mcp-header` only on integer, string and boolean parameters — "Parameters with type `number` are not permitted" — but the harness never verified the `number` case and its requirement text still described `number` as permitted. PR #371 fixed the positive `http-custom-headers` fixture (priority is now `integer`, `float_val` is served unannotated) but left the two remaining items from #344: - `HttpInvalidToolHeadersScenario` serves invalid tools for every other x-mcp-header constraint but had no number-typed case, so nothing checked that a client excludes such a tool. - `sep-2243.yaml` claimed primitive types are "(number, string, or boolean)" and that "number values" get decimal-string encoding, both of which contradict the released 2026-07-28 spec. Add an `invalid_number_header` tool mapped to the existing `sep-2243-x-mcp-header-primitive-only` requirement (no new check IDs) and correct both requirement texts. traceability.json is updated in place since it embeds the yaml text verbatim; check IDs and statuses are unchanged. Verified against typescript-sdk@main: the new check fails there because the SDK deliberately allow-lists `number` to satisfy the old fixture — a workaround its own source notes as "tracked upstream" and can now drop. The positive scenario still passes 18/18. Closes #344 Co-authored-by: Copilot App <[email protected]>
1 parent 542381b commit 3507f94

4 files changed

Lines changed: 72 additions & 4 deletions

File tree

‎src/scenarios/client/http-custom-headers.test.ts‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ async function post(
3030
});
3131
}
3232

33+
async function postJson(serverUrl: string, body: object): Promise<any> {
34+
const res = await fetch(serverUrl, {
35+
method: 'POST',
36+
headers: {
37+
'Content-Type': 'application/json',
38+
Accept: 'application/json, text/event-stream'
39+
},
40+
body: JSON.stringify(body)
41+
});
42+
return res.json();
43+
}
44+
3345
function idsOf(checks: { id: string }[]): Set<string> {
3446
return new Set(checks.map((c) => c.id));
3547
}
@@ -198,4 +210,42 @@ describe('HttpInvalidToolHeadersScenario (SEP-2243) check IDs', () => {
198210
await scenario.stop();
199211
}
200212
});
213+
214+
it('FAILs primitive-only when the client calls the number-typed tool', async () => {
215+
const scenario = new HttpInvalidToolHeadersScenario();
216+
const { serverUrl } = await scenario.start(testScenarioContext());
217+
try {
218+
const listed = await postJson(serverUrl, {
219+
jsonrpc: '2.0',
220+
id: 1,
221+
method: 'tools/list'
222+
});
223+
// SEP-2243 permits x-mcp-header only on integer/string/boolean, so the
224+
// number-typed tool must be served for the client to reject it.
225+
const numberTool = listed.result.tools.find(
226+
(t: { name: string }) => t.name === 'invalid_number_header'
227+
);
228+
expect(numberTool?.inputSchema.properties.score).toEqual({
229+
type: 'number',
230+
'x-mcp-header': 'Score'
231+
});
232+
233+
await post(serverUrl, {
234+
jsonrpc: '2.0',
235+
id: 2,
236+
method: 'tools/call',
237+
params: { name: 'invalid_number_header', arguments: { score: 1.5 } }
238+
});
239+
const checks = scenario.getChecks();
240+
expect(
241+
statusesFor(checks, 'sep-2243-x-mcp-header-primitive-only')
242+
).toContain('FAILURE');
243+
// The other constraints were not violated.
244+
expect(
245+
statusesFor(checks, 'sep-2243-x-mcp-header-not-empty')
246+
).not.toContain('FAILURE');
247+
} finally {
248+
await scenario.stop();
249+
}
250+
});
201251
});

‎src/scenarios/client/http-custom-headers.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const INVALID_TOOL_CONSTRAINT_IDS: Record<string, string> = {
6868
invalid_object_header: 'sep-2243-x-mcp-header-primitive-only',
6969
invalid_array_header: 'sep-2243-x-mcp-header-primitive-only',
7070
invalid_null_header: 'sep-2243-x-mcp-header-primitive-only',
71+
invalid_number_header: 'sep-2243-x-mcp-header-primitive-only',
7172
invalid_duplicate_same_case: 'sep-2243-x-mcp-header-unique',
7273
invalid_duplicate_diff_case: 'sep-2243-x-mcp-header-unique',
7374
invalid_space_in_name: 'sep-2243-x-mcp-header-charset',
@@ -861,6 +862,23 @@ export class HttpInvalidToolHeadersScenario extends BaseHttpScenario {
861862
}
862863
},
863864

865+
// ── Invalid: x-mcp-header on number type ──
866+
// `number` is a JSON Schema primitive but SEP-2243 excludes it from
867+
// the permitted set: "Parameters with type `number` are not
868+
// permitted." Only integer, string and boolean may be annotated.
869+
{
870+
name: 'invalid_number_header',
871+
description:
872+
'x-mcp-header MUST NOT be on number type (MUST be rejected)',
873+
inputSchema: {
874+
type: 'object',
875+
properties: {
876+
score: { type: 'number', 'x-mcp-header': 'Score' }
877+
},
878+
required: ['score']
879+
}
880+
},
881+
864882
// ── Invalid: duplicate same-case x-mcp-header values ──
865883
{
866884
name: 'invalid_duplicate_same_case',

‎src/seps/sep-2243.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ requirements:
2323
text: 'The x-mcp-header value MUST be case-insensitively unique within a single tool definition.'
2424
url: https://modelcontextprotocol.io/specification/draft/server/tools#custom-headers
2525
- check: sep-2243-x-mcp-header-primitive-only
26-
text: 'x-mcp-header MUST only be applied to parameters with primitive types (number, string, or boolean).'
26+
text: 'x-mcp-header MUST only be applied to parameters with primitive types (integer, string, boolean). Parameters with type `number` are not permitted.'
2727
url: https://modelcontextprotocol.io/specification/draft/server/tools#custom-headers
2828
- check: sep-2243-client-reject-invalid-tool
2929
text: 'Clients MUST reject tool definitions where any x-mcp-header value violates these constraints. Rejection means the client MUST exclude the invalid tool from the set of tools returned by tools/list.'
3030
url: https://modelcontextprotocol.io/specification/draft/server/tools#custom-headers
3131
- check: sep-2243-client-encode-values
32-
text: 'Clients MUST encode parameter values before including them in HTTP headers: number values MUST be converted to their decimal string representation; boolean values MUST be converted to the lowercase strings "true" or "false".'
32+
text: 'Clients MUST encode parameter values before including them in HTTP headers: integer values MUST be converted to their decimal string representation; boolean values MUST be converted to the lowercase strings "true" or "false".'
3333
- check: sep-2243-client-base64-unsafe
3434
text: 'When a value cannot be safely represented as plain ASCII (e.g., contains non-ASCII characters, control characters, or leading/trailing whitespace), clients MUST use Base64 encoding of the UTF-8 representation, wrapped as =?base64?{encoded}?=.'
3535
- check: sep-2243-server-decode-base64

‎src/seps/traceability.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
{
210210
"check": "sep-2243-x-mcp-header-primitive-only",
211211
"status": "tested",
212-
"text": "x-mcp-header MUST only be applied to parameters with primitive types (number, string, or boolean).",
212+
"text": "x-mcp-header MUST only be applied to parameters with primitive types (integer, string, boolean). Parameters with type `number` are not permitted.",
213213
"url": "https://modelcontextprotocol.io/specification/draft/server/tools#custom-headers"
214214
},
215215
{
@@ -221,7 +221,7 @@
221221
{
222222
"check": "sep-2243-client-encode-values",
223223
"status": "tested",
224-
"text": "Clients MUST encode parameter values before including them in HTTP headers: number values MUST be converted to their decimal string representation; boolean values MUST be converted to the lowercase strings \"true\" or \"false\"."
224+
"text": "Clients MUST encode parameter values before including them in HTTP headers: integer values MUST be converted to their decimal string representation; boolean values MUST be converted to the lowercase strings \"true\" or \"false\"."
225225
},
226226
{
227227
"check": "sep-2243-client-base64-unsafe",

0 commit comments

Comments
 (0)