MCP SDK for Python 2

Last reviewed Oct 12, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Python 3155 lines · 3.8K tokens
  2. MCP SDK for Python 288 lines · 4K tokens
Total243 lines · 7.8K tokens

CWE Coverage

  • 20
  • 22
  • 23
  • 36
  • 59
  • 78
  • 89
  • 95
  • 116
  • 117
  • 201
  • 208
  • 209
  • 214
  • 250
  • 295
  • 306
  • 319
  • 328
  • 338
  • 345
  • 346
  • 347
  • 367
  • 379
  • 409
  • 416
  • 426
  • 427
  • 470
  • 488
  • 502
  • 522
  • 524
  • 532
  • 611
  • 613
  • 674
  • 732
  • 770
  • 772
  • 776
  • 807
  • 829
  • 841
  • 862
  • 863
  • 916
  • 918
  • 1104
  • 1284
  • 1333
  • 1395
  • 1426
  • 1427

Prompt Preview

Apply the Python 3 baseline first. These rules cover MCP SDK for Python 2 servers and clients, transports, authentication, tools, resources, prompts, elicitation, lifecycle, logging, and deployment.

Version scope

  • Follow the newest 2.x release: only the newest release of the line receives fixes, including fixes shipped in a new minor. Keep mcp and mcp-types at the matching versions the SDK requires, and do not loosen its dependencies to resolve an installation.
  • Use a security-supported CPython minor verified with the deployed SDK and integrations. The 2.3.0 package permits Python 3.10 or later and advertises and runs CI for 3.10 through 3.14; 3.10 is end of life. Use 3.11 through 3.14 within that matrix, and verify 3.15 separately before deploying it. Retain the distinct AnyIO and Starlette requirements for Python 3.14.

Server identity and transport

  • Use stdio only across a trusted local process boundary and use authenticated HTTPS for remote MCP servers.
  • Choose Client(..., mode=...) in trusted configuration: the default mode="auto" probes 2026-07-28 and falls back to the legacy initialization era on failure, so inspect client.protocol_version and reject legacy semantics when they are not explicitly supported.
  • Do not mistake mode="2026-07-28" for peer discovery: a version pin sends no probe or handshake and leaves server_info and capabilities empty unless a trusted prior_discover is supplied; authenticate the transport peer independently.
  • Bind authenticated identity and tenant context to each request and any legacy server session and