fix(server): validate Content-Type by parsed media type instead of substring match (#2441)

This commit is contained in:
Felix Weinberger 2026-07-06 20:29:58 +01:00 • committed by GitHub
commit 561c6d8345
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,7 +8,7 @@
* the stateless legacy fallback unaffected.
*/
import { check, parseExampleArgs } from '@mcp-examples/shared';
import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
import { Client, isJsonContentType, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
const { url } = parseExampleArgs();
@ -39,7 +39,7 @@ const probe = await fetch(url, {
}
})
});
check.match(probe.headers.get('content-type') ?? '', /application\/json/);
check.equal(isJsonContentType(probe.headers.get('content-type')), true);
check.equal(probe.status, 200);
// High-level: the regular Client works unchanged.