Streamable HTTP: Content-Type handling is order dependent and accepts invalid values
Maintainer thường phản hồi trong vòng 1 ngày
@jayzuccarelli đang làm issue này rồi.
Từ ngày 12/10/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- backend-api-design, security
Hướng nghiên cứu
Bắt đầu bằng cách đọc các bước kiểm tra Content-Type trong src/mcp/server/transport_security.py và src/mcp/server/streamable_http.py, sau đó lần theo bước kiểm tra tương ứng trong transport hiện đại. Thêm hoặc cập nhật các bài kiểm thử cho những giá trị Content-Type được liệt kê, bao gồm tham số và các giá trị phân tách bằng dấu phẩy. Công việc hoàn tất khi chỉ application/json, có thể kèm tham số, được chấp nhận nhất quán trên tất cả các transport.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Initial Checks
- I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1)
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Release line
2.x (current stable)
Description
The Content-Type header:
- accepts values that are not JSON media types.
application/json, text/plainis accepted and the request is executed, although a comma cannot appear inside a media type. On the modern transportapplication/jsonxis accepted as well - The answer depends on order.
application/json, text/plainis accepted whiletext/plain, application/jsonis rejected, so the same invalid value gets opposite answers.
The first check is a prefix test in the middleware:
# src/mcp/server/transport_security.py
return content_type is not None and content_type.lower().startswith("application/json")
The second splits the value on ; and , and compares the result:
# src/mcp/server/streamable_http.py
content_type_parts = [part.strip() for part in content_type.split(";")[0].split(",")]
return any(part == CONTENT_TYPE_JSON for part in content_type_parts)
The second check rejects application/jsonx. The 2.x modern transport has no equivalent, so it accepts that value.
For reference, the TypeScript SDK answers 415 for application/json, text/plain and for application/jsonx, and mcp-go answers 400 for both.
Reproduction
Against a server started with stateless_http=True, so no session handshake is needed:
curl -s http://127.0.0.1:8901/mcp \
-H 'Content-Type: application/json, text/plain' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"ping","arguments":{}}}'
Observed: 200 with a normal JSON-RPC result, and the tool's handler runs.
Content-Type sent |
Expected | handshake transport (1.x and 2.x) | modern transport (2.x only) |
|---|---|---|---|
application/json |
accepted | 200 |
200 |
application/json; charset=utf-8 |
accepted | 200 |
200 |
application/json, text/plain |
rejected | 200, body executed |
200, body executed |
application/jsonx |
rejected | 415 |
200, body executed |
text/plain, application/json |
rejected | 400 |
400 |
text/plain |
rejected | 400 |
400 |
For modern transport calls were sent with MCP-Protocol-Version: 2026-07-28 plus the Mcp-Method and Mcp-Name headers.
Fix
Parse the media type, the segment before the first ;, and compare it exactly to application/json. Parameters keep working, so application/json; charset=utf-8 is unaffected, while the values above are rejected.
Python & MCP Python SDK
Reproduced on the 2.x line (`2.2.0`, `2.3.0`) and the 1.x line (`1.30.0`)
- Ngôn ngữ chính
- Python
- Star
- 24.6k
- Fork
- 4.2k
- Merge trung bình
- 10 giờ 37 phút
- Pull request đã merge (30 ngày)
- 38
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/python-sdk
-
OAuth token expiry equality boundary causes intermittent downstream test failuresCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
modelcontextprotocol/python-sdk#3729 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/python-sdk#3725 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/python-sdk#3698 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Skills: URI traversal validation skips percent-encoded dot-segmentsCó thể làm lại được @Varshith-Kali đã nhận 7 ngày trước và không có pull request nào đang mở. Đang mởbug v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/python-sdk#3685 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.pyCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
modelcontextprotocol/python-sdk#3673 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/python-sdk
Issue tương tự
-
idxmax/idxmin raise ValueError when a single partition is all-NACó thể đã có người làm @Jason10191019999 đã nhận hôm nay. Đang mởneeds triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Old versions of datamodelsĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
-
[BUG]: Windows GUI package of v1.17.0-rc3 has no GTK DLLsCó thể đã có người làm @andrut-ds đã nhận hôm nay. Đang mởbug CI/CD Pactus-GUI Windows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
pactus-project/pactus#2428 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DiskDataset.reshard() can hang with a zero or negative shard sizeCó thể đã có người làm @Programmer-Develops đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 19 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
GNS3/gns3-server#3017 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày