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

@ -1,4 +1,5 @@
import type { FetchLike } from '@modelcontextprotocol/core-internal';
import { isJsonContentType } from '@modelcontextprotocol/core-internal';
import type { Mocked, MockedFunction, MockInstance } from 'vitest';
import type { OAuthClientProvider } from '../../src/client/auth';
@ -1016,7 +1017,7 @@ describe('createMiddleware', () => {
const transformMiddleware = createMiddleware(async (next, input, init) => {
const response = await next(input, init);
if (response.headers.get('content-type')?.includes('application/json')) {
if (isJsonContentType(response.headers.get('content-type'))) {
const data = (await response.json()) as Record<string, unknown>;
const transformed = { ...data, timestamp: 123_456_789 };