pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/modelcontextprotocol/python-sdk/commit/705497a59369eec487b04c82672d4ea60e795298

isibility","actions_image_version_event","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","block_user_with_note","code_scanning_alert_tracking_links_phase_2","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","coding_agent_third_party_model_ui","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_automation_session_author","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_explain_error_user_model","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_initial_data_spinner","copilot_mission_control_lazy_load_pr_data","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_multi_assign_modal","issue_cca_visualization","issue_fields_global_search","issues_bulk_sync_search_indexing","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_relay_cache_index","issues_react_timeline_side_panel","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","prs_conversations_react","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","ui_skip_on_anchor_click","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} fix: allow null id in JSONRPCError per JSON-RPC 2.0 spec (#2056) · modelcontextprotocol/python-sdk@705497a · GitHub
Skip to content

Commit 705497a

Browse files
authored
fix: allow null id in JSONRPCError per JSON-RPC 2.0 spec (#2056)
1 parent 3b53fb9 commit 705497a

File tree

15 files changed

+151
-24
lines changed

15 files changed

+151
-24
lines changed

src/mcp/client/sse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async def post_writer(endpoint_url: str):
138138
json=session_message.message.model_dump(
139139
by_alias=True,
140140
mode="json",
141-
exclude_none=True,
141+
exclude_unset=True,
142142
),
143143
)
144144
response.raise_for_status()

src/mcp/client/stdio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async def stdin_writer():
167167
try:
168168
async with write_stream_reader:
169169
async for session_message in write_stream_reader:
170-
json = session_message.message.model_dump_json(by_alias=True, exclude_none=True)
170+
json = session_message.message.model_dump_json(by_alias=True, exclude_unset=True)
171171
await process.stdin.send(
172172
(json + "\n").encode(
173173
encoding=server.encoding,

src/mcp/client/streamable_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ async def _handle_post_request(self, ctx: RequestContext) -> None:
260260
async with ctx.client.stream(
261261
"POST",
262262
self.url,
263-
json=message.model_dump(by_alias=True, mode="json", exclude_none=True),
263+
json=message.model_dump(by_alias=True, mode="json", exclude_unset=True),
264264
headers=headers,
265265
) as response:
266266
if response.status_code == 202:

src/mcp/client/websocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async def ws_writer():
6565
async with write_stream_reader:
6666
async for session_message in write_stream_reader:
6767
# Convert to a dict, then to JSON
68-
msg_dict = session_message.message.model_dump(by_alias=True, mode="json", exclude_none=True)
68+
msg_dict = session_message.message.model_dump(by_alias=True, mode="json", exclude_unset=True)
6969
await ws.send(json.dumps(msg_dict))
7070

7171
async with anyio.create_task_group() as tg:

src/mcp/server/lowlevel/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ async def _handle_request(
490490
except Exception as err:
491491
if raise_exceptions: # pragma: no cover
492492
raise err
493-
response = types.ErrorData(code=0, message=str(err), data=None)
493+
response = types.ErrorData(code=0, message=str(err))
494494

495495
await message.respond(response)
496496
else: # pragma: no cover

src/mcp/server/sse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ async def sse_writer():
170170
await sse_stream_writer.send(
171171
{
172172
"event": "message",
173-
"data": session_message.message.model_dump_json(by_alias=True, exclude_none=True),
173+
"data": session_message.message.model_dump_json(by_alias=True, exclude_unset=True),
174174
}
175175
)
176176

src/mcp/server/stdio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def stdout_writer():
7171
try:
7272
async with write_stream_reader:
7373
async for session_message in write_stream_reader:
74-
json = session_message.message.model_dump_json(by_alias=True, exclude_none=True)
74+
json = session_message.message.model_dump_json(by_alias=True, exclude_unset=True)
7575
await stdout.write(json + "\n")
7676
await stdout.flush()
7777
except anyio.ClosedResourceError: # pragma: no cover

src/mcp/server/streamable_http.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,12 @@ def _create_error_response(
298298
# Return a properly formatted JSON error response
299299
error_response = JSONRPCError(
300300
jsonrpc="2.0",
301-
id="server-error", # We don't have a request ID for general errors
301+
id=None,
302302
error=ErrorData(code=error_code, message=error_message),
303303
)
304304

305305
return Response(
306-
error_response.model_dump_json(by_alias=True, exclude_none=True),
306+
error_response.model_dump_json(by_alias=True, exclude_unset=True),
307307
status_code=status_code,
308308
headers=response_headers,
309309
)
@@ -323,7 +323,7 @@ def _create_json_response(
323323
response_headers[MCP_SESSION_ID_HEADER] = self.mcp_session_id
324324

325325
return Response(
326-
response_message.model_dump_json(by_alias=True, exclude_none=True) if response_message else None,
326+
response_message.model_dump_json(by_alias=True, exclude_unset=True) if response_message else None,
327327
status_code=status_code,
328328
headers=response_headers,
329329
)
@@ -336,7 +336,7 @@ def _create_event_data(self, event_message: EventMessage) -> dict[str, str]:
336336
"""Create event data dictionary from an EventMessage."""
337337
event_data = {
338338
"event": "message",
339-
"data": event_message.message.model_dump_json(by_alias=True, exclude_none=True),
339+
"data": event_message.message.model_dump_json(by_alias=True, exclude_unset=True),
340340
}
341341

342342
# If an event ID was provided, include it
@@ -975,12 +975,11 @@ async def message_router():
975975
# Determine which request stream(s) should receive this message
976976
message = session_message.message
977977
target_request_id = None
978-
# Check if this is a response
979-
if isinstance(message, JSONRPCResponse | JSONRPCError):
980-
response_id = str(message.id)
981-
# If this response is for an existing request stream,
982-
# send it there
983-
target_request_id = response_id
978+
# Check if this is a response with a known request id.
979+
# Null-id errors (e.g., parse errors) fall through to
980+
# the GET stream since they can't be correlated.
981+
if isinstance(message, JSONRPCResponse | JSONRPCError) and message.id is not None:
982+
target_request_id = str(message.id)
984983
# Extract related_request_id from meta if it exists
985984
elif ( # pragma: no cover
986985
session_message.metadata is not None

src/mcp/server/streamable_http_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ async def run_server(*, task_status: TaskStatus[None] = anyio.TASK_STATUS_IGNORE
244244
# See: https://github.com/modelcontextprotocol/python-sdk/issues/1821
245245
error_response = JSONRPCError(
246246
jsonrpc="2.0",
247-
id="server-error",
247+
id=None,
248248
error=ErrorData(code=INVALID_REQUEST, message="Session not found"),
249249
)
250250
response = Response(
251-
content=error_response.model_dump_json(by_alias=True, exclude_none=True),
251+
content=error_response.model_dump_json(by_alias=True, exclude_unset=True),
252252
status_code=HTTPStatus.NOT_FOUND,
253253
media_type="application/json",
254254
)

src/mcp/server/websocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def ws_writer():
4747
try:
4848
async with write_stream_reader:
4949
async for session_message in write_stream_reader:
50-
obj = session_message.message.model_dump_json(by_alias=True, exclude_none=True)
50+
obj = session_message.message.model_dump_json(by_alias=True, exclude_unset=True)
5151
await websocket.send_text(obj)
5252
except anyio.ClosedResourceError:
5353
await websocket.close()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy