Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/scenarios/client/draft-result-fields.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ describe('http-custom-headers mock results (2026-07-28)', () => {
method: 'tools/list',
params: {}
});
expect(list.body.result).toMatchObject(CACHEABLE_FIELDS);
expect(list.body.result).toMatchObject({
resultType: 'complete',
cacheScope: 'private'
});
expect(list.body.result.ttlMs).toBeGreaterThan(0);

const call = await post(serverUrl, {
jsonrpc: '2.0',
Expand Down
82 changes: 80 additions & 2 deletions src/scenarios/client/http-custom-headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ async function post(
serverUrl: string,
body: object,
headers: Record<string, string> = {}
): Promise<void> {
await fetch(serverUrl, {
): Promise<{ status: number; body: any }> {
const response = await fetch(serverUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -28,6 +28,7 @@ async function post(
},
body: JSON.stringify(body)
});
return { status: response.status, body: await response.json() };
}

function idsOf(checks: { id: string }[]): Set<string> {
Expand Down Expand Up @@ -150,6 +151,83 @@ describe('HttpCustomHeadersScenario (SEP-2243) check IDs', () => {
await scenario.stop();
}
});

it('serves a fresh tools/list TTL before requiring schema-derived custom headers', async () => {
const scenario = new HttpCustomHeadersScenario();
const { serverUrl } = await scenario.start(testScenarioContext());
try {
const toolsList = await post(serverUrl, {
jsonrpc: '2.0',
id: 1,
method: 'tools/list'
});
const schemaIsFresh = toolsList.body.result.ttlMs > 0;

const nonAscii = 'Hello, 世界';
const nonAsciiB64 = Buffer.from(nonAscii, 'utf-8').toString('base64');
await post(
serverUrl,
{
jsonrpc: '2.0',
id: 2,
method: 'tools/call',
params: {
name: 'test_custom_headers',
arguments: {
region: 'us-west1',
priority: 42,
non_ascii_val: nonAscii,
query: 'SELECT 1'
}
}
},
schemaIsFresh
? {
'Mcp-Method': 'tools/call',
'Mcp-Name': 'test_custom_headers',
'Mcp-Param-Region': 'us-west1',
'Mcp-Param-Priority': '42',
'Mcp-Param-NonAscii': `=?base64?${nonAsciiB64}?=`
}
: {}
);
await post(
serverUrl,
{
jsonrpc: '2.0',
id: 3,
method: 'tools/call',
params: {
name: 'test_custom_headers_null',
arguments: {
region: 'us-east1',
priority: 1,
verbose: null,
query: 'SELECT 1'
}
}
},
schemaIsFresh
? {
'Mcp-Method': 'tools/call',
'Mcp-Name': 'test_custom_headers_null',
'Mcp-Param-Region': 'us-east1',
'Mcp-Param-Priority': '1'
}
: {}
);

expect(toolsList.body.result.ttlMs).toBeGreaterThan(0);
const checks = scenario.getChecks();
for (const id of CUSTOM_HEADERS_DECLARED_CHECK_IDS) {
const statuses = statusesFor(checks, id);
expect(statuses.length, id).toBeGreaterThan(0);
expect(statuses, id).not.toContain('FAILURE');
}
} finally {
await scenario.stop();
}
});
});

describe('HttpInvalidToolHeadersScenario (SEP-2243) check IDs', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/scenarios/client/http-custom-headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class HttpCustomHeadersScenario extends BaseHttpScenario {
id: request.id,
result: {
resultType: 'complete',
ttlMs: 0,
ttlMs: 300000,
cacheScope: 'private',
tools: [
{
Expand Down