EVEMISSTechnology

Repository guide · source walkthrough · v2

modelcontextprotocol / python-sdk · Source walkthrough

A reading order for the analyzed revision of this Python repository. It covers the orientation files, the conformance client's execution story, eight core library functions under src/mcp, a lab-selected library reading set, and test code where the static graph shows stronger coupling. All block descriptions are static inferences.

License
MIT · open-source license
Analyzed revision · last verified
77001c96f9507be0f4d009b83210a384a5e08bda ·

modelcontextprotocol/python-sdk source walkthrough

Terms used on this page
Entrypoint record
A file the analyzer marks as a place where execution can start. When it carries a __main__ guard excerpt, the file contains an if __name__ == "__main__": block and the excerpt shows what that block calls; without an excerpt, the file was flagged by its name only.
Bounded static execution path
A call chain reconstructed from the source code without running it, stopped after a fixed number of steps. It shows how far the code can be followed on paper, not what happens at run time.
Unresolved boundary
Where a static path stops because the next call goes into an external library or cannot be resolved without running the code. It marks the edge of this analysis, not a defect in the repository.
Static relations
Calls and imports found in the source. "External or unresolved" relations point outside the analyzed files.
Module role
The analyzer's label for a file, inferred from how many calls go in and out (for example core, entry/orchestration, leaf). It describes a position in the call graph, not the authors' design.
Test-like files
Files whose names or locations look like tests. This analysis counts them; it does not run them.
Observed · inferred · author-claimed · unresolved
How each statement is supported: read directly from the analyzed files; derived by the analyzer from them; stated by the repository's authors (metadata, README); or not established by this analysis.
Verified
Two uses on these pages. In an analyzer record ("verified provenance", "a verified entrypoint") it means the record was read directly from the analyzed files, which these guides call observed; for an entrypoint, the __main__ guard text is present. Since the analyzer fix of 2026-10-04, a file that only has an entrypoint-like name such as cli.py or main.py is recorded as inferred; guides analyzed before that still call such a file verified, and it is still only a guess about how the file is used. It does not mean the code was run or tested. "Last verified" is the date the guide last passed the lab's checks against the analysis record of the stated revision; it is not a review of the repository itself.

How to use this walkthrough

This walkthrough has four stops that follow the analyzer's own lessons: orientation, execution story, core code, and where changes ripple. Every line range is written as path:start-end and refers to the files of analyzed revision 77001c96f9507be0f4d009b83210a384a5e08bda. A block is the analyzer's line-addressable unit of code. Each block description below is the analyzer's inference and carries a confidence value. It is not a confirmed reading of the code.

Stop 1: Orientation

The orientation lesson points to six file-level module blocks, and none of them is in library code. One is a conformance client under the CI files, and five are documentation tutorial files. For each block, the analyzer says only that it represents the analyzed source file and provides its file-level container, at confidence 0.76. The parser found a __main__ guard in each of these six files. Separately, the analyzer's teaching claims recommend reading README.md, pyproject.toml, LICENSE and the conformance client early.

  • .github/actions/conformance/client.py:1-644: module block for the conformance client file.
  • docs_src/apps/tutorial001_client.py:1-20: module block, tutorial file.
  • docs_src/caching/tutorial003.py:1-34: module block, tutorial file.
  • docs_src/client/tutorial001_client.py:1-15: module block, tutorial file.
  • docs_src/client/tutorial002.py:1-17: module block, tutorial file.
  • docs_src/client/tutorial003.py:1-20: module block, tutorial file.

Stop 2: Execution story

The execution-story lesson covers three blocks of the conformance client, all outside library code: its direct-execution guard, its file-level block and its main function. The analysis reports 658 bounded execution paths. Five of them are listed here, and all five start at this file's __main__ guard. Each ends at an unresolved boundary in a call to logging.basicConfig, logging.getLogger, os.environ.get, len or print. One of the analyzer's own teaching claims says no bounded static execution path is available, which conflicts with these listed paths, so treat runtime flow as not established.

  • .github/actions/conformance/client.py:643-644: main_guard __main__. The analyzer says it gates code that runs when the file is executed directly rather than imported (confidence 0.99).
  • .github/actions/conformance/client.py:1-644: module block, the file-level container (confidence 0.76).
  • .github/actions/conformance/client.py:618-640: function main, signature def main() -> None:. Static structure suggests it encapsulates an operation with 18 downstream call or import relations (confidence 0.76).

Stop 3: Core code

All eight blocks of the analyzer's core-code lesson lie in library code under src/mcp. Each is a function block at confidence 0.76. For each one, the analyzer's note says static structure suggests it encapsulates an operation with the listed number of downstream call or import relations.

  • src/mcp/server/streamable_http.py:558-726: function StreamableHTTPServerTransport._handle_post_request, 55 relations.
  • src/mcp/server/auth/handlers/token.py:103-275: function TokenHandler.handle, 54 relations.
  • src/mcp/client/auth/oauth2.py:604-793: function OAuthClientProvider._auth_flow, 49 relations.
  • src/mcp/server/_streamable_http_modern.py:365-527: function handle_modern_request, 48 relations.
  • src/mcp/server/mcpserver/utilities/func_metadata.py:287-490: function func_metadata, 47 relations.
  • src/mcp/shared/jsonrpc_dispatcher.py:319-462: function JSONRPCDispatcher.send_raw_request, 44 relations.
  • src/mcp/client/streamable_http.py:363-446: function StreamableHTTPTransport._handle_post_request, 42 relations.
  • src/mcp/server/sse.py:230-287: function SseServerTransport._handle_post_message, 38 relations.

The library reading set below is not an analyzer lesson. It is the AI Frontier lab's selection from static call degree, taken from code outside tests, docs, examples, scripts and CI. Module roles and block relation counts come from the analyzer's inferences.

src/mcp/cli/cli.py is a leaf/data-boundary candidate with 1 incoming and 0 outgoing calls.

  • src/mcp/cli/cli.py:361-486: function install, 24 relations.
  • src/mcp/cli/cli.py:119-206: function _import_server, 28 relations.

src/mcp/client/__main__.py is an entry candidate with 0 incoming and 0 outgoing calls.

  • src/mcp/client/__main__.py:62-77: function cli, 7 relations.
  • src/mcp/client/__main__.py:32-45: function run_session, 4 relations.

src/mcp/server/__main__.py is an entry candidate with 0 incoming and 0 outgoing calls, and only one block is listed for it.

  • src/mcp/server/__main__.py:17-20: function main, 4 relations.

src/mcp/server/lowlevel/server.py is an entry candidate with 0 incoming and 0 outgoing calls.

  • src/mcp/server/lowlevel/server.py:129-852: class Server, signature class Server(Generic[LifespanResultT]):. It groups related behaviour under one class boundary (confidence 0.99).
  • src/mcp/server/lowlevel/server.py:308-482: function Server.__init__, 10 relations.

Stop 4: Where changes ripple

The change-guide lesson lists six blocks where the static graph shows stronger coupling. All six lie in test code, so the coupling signal at this stop comes from tests rather than library code. The analyzer classes the requirements module that holds two of these blocks as a leaf/data-boundary candidate with 37 incoming calls.

  • tests/interaction/_requirements.py:138-167: class Requirement. It groups related behaviour under one class boundary (confidence 0.97).
  • tests/interaction/_requirements.py:106-116: class ArmExclusion, with the same note (confidence 0.97).
  • tests/server/test_runner.py:117-170: function connected_runner, which connects to 14 downstream call or import relations.
  • tests/server/test_runner.py:156-168: with block inside connected_runner, which scopes operations under a context manager.
  • tests/server/test_runner.py:141-154: straight_line block of sequential statements inside connected_runner.
  • tests/server/test_runner.py:137-138: straight_line block of sequential statements inside connected_runner.

What this walkthrough cannot show

This walkthrough is limited to what static analysis shows. Reflection, runtime dependency injection, dynamic imports, monkey-patching, generated code, framework runtime wiring and dynamic dispatch are not resolved. Install, run and build inference is partial and no commands are verified, so this walkthrough gives none. The analysis is bounded: files over 400 kB, minified bundles and vendored directories are inventoried but not parsed, and relation extraction is capped. Every block description is an analyzer inference with a confidence value, not proof of runtime behaviour. The uncertainties lesson flags weaker static certainty in two JavaScript files under .github/scripts:

  • .github/scripts/docs_preview.js:1-117: module block (confidence 0.68). The lesson also lists function blocks authorize, permissionFor, comment and upsert inside this file.
  • .github/scripts/docs_preview.test.js:1-241: module block (confidence 0.68). The lesson also lists function blocks pushed and slash inside this file.

What this analysis could not establish

The writing model's own notes on the analysis record. Identifiers such as lim_3, exec_* or claim_… name records of that analysis; the claims table cites the same records.

  • The analyzer's teaching claim that no bounded static execution path is available contradicts the five listed execution paths and the reported total of 658, so runtime flow is treated as not established.
  • The library reading set is described as the most connected modules by static call degree, yet three of the four modules show 0 incoming and 0 outgoing calls in their role records; how the degree was measured is not established.
  • The analyzer's teaching claims name src/mcp/cli/cli.py as a detected starting point, while its repository summary names .github/actions/conformance/client.py; which one is the primary entry is not established.
  • The analysis reports 41452 static relations as external or unresolved, so downstream relation counts on blocks are partial.
  • JavaScript analysis is a bounded heuristic, which may explain the lower confidence of the docs_preview blocks; this is not established by the packet.
Claims and evidence — 34 claims, 34 supported by an independent verifier

Every substantive statement above is a claim bound to grounding IDs of the analyzed revision. Global grounding IDs are namespaced by the analysis run.

Claim Epistemic status Verifier Grounding (global IDs)
c1 The walkthrough's stops follow the analyzer's orientation, execution-story, core-code and change-guide lessons, and each stated line range is a block's own line range in the analyzed revision's files. inferred supported analysis_f7d9a9f9559ef565:block_279208c57019b9, analysis_f7d9a9f9559ef565:block_a55be5d7fa1bea, analysis_f7d9a9f9559ef565:block_8d2a03ba2d20be, analysis_f7d9a9f9559ef565:block_db10778e8e33de
c2 A block is the analyzer's line-addressable code unit. The analysis reports 20149 such blocks with evidence-grounded annotations, which are inferences carrying a confidence value. inferred supported analysis_f7d9a9f9559ef565:summary_repository
c3 The orientation lesson lists six file-level module blocks, none in library code. Each is described only as representing and containing the analyzed source file, at confidence 0.76. inferred supported analysis_f7d9a9f9559ef565:block_279208c57019b9, analysis_f7d9a9f9559ef565:block_ed7fac08170f90, analysis_f7d9a9f9559ef565:block_5aa3ace1e95989, analysis_f7d9a9f9559ef565:block_ce2101b3c6b918, analysis_f7d9a9f9559ef565:block_b360e5d81e59c7, analysis_f7d9a9f9559ef565:block_01f6bbd8905f6f
c4 The block .github/actions/conformance/client.py:1-644 is the module block for the conformance client file. inferred supported analysis_f7d9a9f9559ef565:block_279208c57019b9
c5 The five docs_src orientation blocks are module blocks for tutorial files at the listed line ranges. inferred supported analysis_f7d9a9f9559ef565:block_ed7fac08170f90, analysis_f7d9a9f9559ef565:block_5aa3ace1e95989, analysis_f7d9a9f9559ef565:block_ce2101b3c6b918, analysis_f7d9a9f9559ef565:block_b360e5d81e59c7, analysis_f7d9a9f9559ef565:block_01f6bbd8905f6f
c6 A __main__ guard was parsed in each of the six orientation files. observed supported analysis_f7d9a9f9559ef565:py_entry_7ed4238a8b5b, analysis_f7d9a9f9559ef565:py_entry_5d442081d210, analysis_f7d9a9f9559ef565:py_entry_fb08908da90c, analysis_f7d9a9f9559ef565:py_entry_2f2371a70335, analysis_f7d9a9f9559ef565:py_entry_5e69a082cd28, analysis_f7d9a9f9559ef565:py_entry_e6563cc9ae9c
c7 The analyzer's teaching claims recommend reading README.md, pyproject.toml, LICENSE and .github/actions/conformance/client.py early. inferred supported analysis_f7d9a9f9559ef565:claim_5e040738cac5, analysis_f7d9a9f9559ef565:claim_f91db16ab368, analysis_f7d9a9f9559ef565:claim_467994cc62bf, analysis_f7d9a9f9559ef565:claim_0b14ef85fefe
c8 The execution-story lesson covers three blocks of the conformance client, all outside library code: its __main__ guard, its file-level block and its main function. inferred supported analysis_f7d9a9f9559ef565:block_a55be5d7fa1bea, analysis_f7d9a9f9559ef565:block_279208c57019b9, analysis_f7d9a9f9559ef565:block_068853a2fa7f85
c9 The analysis reports 658 bounded execution paths. The five listed start at the conformance client's __main__ guard, and each ends at an unresolved boundary in logging.basicConfig, logging.getLogger, os.environ.get, len or print. inferred supported analysis_f7d9a9f9559ef565:summary_repository, analysis_f7d9a9f9559ef565:exec_5e86e34bd295, analysis_f7d9a9f9559ef565:exec_e6323d56ad9b, analysis_f7d9a9f9559ef565:exec_7bf8b1b02bf8, analysis_f7d9a9f9559ef565:exec_fad222196619, analysis_f7d9a9f9559ef565:exec_f72d6b612163
c10 An analyzer teaching claim states that no bounded static execution path is available. This conflicts with the listed paths, so runtime flow is not established. unresolved supported analysis_f7d9a9f9559ef565:claim_4d30ade3e21e, analysis_f7d9a9f9559ef565:exec_5e86e34bd295
c11 The main_guard block at .github/actions/conformance/client.py:643-644 is described as gating code that runs when the file is executed directly rather than imported, at confidence 0.99. inferred supported analysis_f7d9a9f9559ef565:block_a55be5d7fa1bea, analysis_f7d9a9f9559ef565:py_entry_7ed4238a8b5b
c12 The module block .github/actions/conformance/client.py:1-644 is the file-level container, at confidence 0.76. inferred supported analysis_f7d9a9f9559ef565:block_279208c57019b9
c13 The function block main at .github/actions/conformance/client.py:618-640 has signature def main() -> None: and, per static structure, connects to 18 downstream call or import relations at confidence 0.76. inferred supported analysis_f7d9a9f9559ef565:block_068853a2fa7f85, analysis_f7d9a9f9559ef565:py_func_fff8ff1c2b28
c14 All eight core-code lesson blocks lie in library code under src/mcp. Each is a function block at confidence 0.76 that the analyzer says encapsulates an operation with downstream call or import relations. inferred supported analysis_f7d9a9f9559ef565:block_8d2a03ba2d20be, analysis_f7d9a9f9559ef565:block_13ce28b64fd247, analysis_f7d9a9f9559ef565:block_c9972743aed2da, analysis_f7d9a9f9559ef565:block_c28743422c94ef, analysis_f7d9a9f9559ef565:block_fcfce14b67291b, analysis_f7d9a9f9559ef565:block_e0f831d8e4c0b8, analysis_f7d9a9f9559ef565:block_63ec3f4bff9b0c, analysis_f7d9a9f9559ef565:block_4c5092d5877dbc
c15 The analyzer gives 55, 54, 49 and 48 downstream relations for StreamableHTTPServerTransport._handle_post_request, TokenHandler.handle, OAuthClientProvider._auth_flow and handle_modern_request respectively. inferred supported analysis_f7d9a9f9559ef565:block_8d2a03ba2d20be, analysis_f7d9a9f9559ef565:block_13ce28b64fd247, analysis_f7d9a9f9559ef565:block_c9972743aed2da, analysis_f7d9a9f9559ef565:block_c28743422c94ef, analysis_f7d9a9f9559ef565:py_func_217ddf717c2c
c16 The analyzer gives 47, 44, 42 and 38 downstream relations for func_metadata, JSONRPCDispatcher.send_raw_request, StreamableHTTPTransport._handle_post_request and SseServerTransport._handle_post_message respectively. inferred supported analysis_f7d9a9f9559ef565:block_fcfce14b67291b, analysis_f7d9a9f9559ef565:block_e0f831d8e4c0b8, analysis_f7d9a9f9559ef565:block_63ec3f4bff9b0c, analysis_f7d9a9f9559ef565:block_4c5092d5877dbc, analysis_f7d9a9f9559ef565:py_func_3d6f5950496a
c17 The library reading set is the AI Frontier lab's selection of four modules by static call degree from code outside tests, docs, examples, scripts and CI. It is not an analyzer lesson, and its roles are analyzer inferences. inferred supported analysis_f7d9a9f9559ef565:role_222, analysis_f7d9a9f9559ef565:role_223, analysis_f7d9a9f9559ef565:role_224, analysis_f7d9a9f9559ef565:role_225
c18 src/mcp/cli/cli.py is classed as a leaf/data-boundary candidate with 1 incoming and 0 outgoing calls. inferred supported analysis_f7d9a9f9559ef565:role_222
c19 In src/mcp/cli/cli.py, function install (361-486) connects to 24 downstream relations and function _import_server (119-206) to 28, per the analyzer. inferred supported analysis_f7d9a9f9559ef565:block_25440bdbb3a07c, analysis_f7d9a9f9559ef565:block_7e8e101df55799, analysis_f7d9a9f9559ef565:py_func_8f483801cdfe, analysis_f7d9a9f9559ef565:py_func_a9a974563357
c20 src/mcp/client/__main__.py is classed as an entry candidate with 0 incoming and 0 outgoing calls. inferred supported analysis_f7d9a9f9559ef565:role_223
c21 In src/mcp/client/__main__.py, function cli (62-77) connects to 7 downstream relations and function run_session (32-45) to 4, per the analyzer. inferred supported analysis_f7d9a9f9559ef565:block_ab3649fc22cacb, analysis_f7d9a9f9559ef565:block_9dc0814076532b, analysis_f7d9a9f9559ef565:py_func_77ab420c62fd, analysis_f7d9a9f9559ef565:py_func_ef8e97ee45fb
c22 src/mcp/server/__main__.py is classed as an entry candidate with 0 incoming and 0 outgoing calls. Its one listed block, function main at 17-20, connects to 4 downstream relations. inferred supported analysis_f7d9a9f9559ef565:role_224, analysis_f7d9a9f9559ef565:block_fbad3477952719, analysis_f7d9a9f9559ef565:py_func_50b34871c0e6
c23 src/mcp/server/lowlevel/server.py is classed as an entry candidate with 0 incoming and 0 outgoing calls. inferred supported analysis_f7d9a9f9559ef565:role_225
c24 Class Server (129-852, signature class Server(Generic[LifespanResultT]):) groups related behaviour under one class boundary at confidence 0.99. Server.__init__ (308-482) connects to 10 downstream relations. inferred supported analysis_f7d9a9f9559ef565:block_13bbfa4a3f4e54, analysis_f7d9a9f9559ef565:block_28a524a061025d, analysis_f7d9a9f9559ef565:py_class_47ca6d2441f9
c25 The change-guide lesson lists six blocks with stronger static coupling. All six lie in test code, so this coupling signal comes from tests rather than library code. inferred supported analysis_f7d9a9f9559ef565:block_db10778e8e33de, analysis_f7d9a9f9559ef565:block_c1c2585412b202, analysis_f7d9a9f9559ef565:block_a4244bce87bb67, analysis_f7d9a9f9559ef565:block_9c7142b26735f9, analysis_f7d9a9f9559ef565:block_77e669430655b5, analysis_f7d9a9f9559ef565:block_e4971cd6d2478b
c26 Classes Requirement (138-167) and ArmExclusion (106-116) in tests/interaction/_requirements.py are each described as grouping related behaviour under one class boundary, at confidence 0.97. inferred supported analysis_f7d9a9f9559ef565:block_db10778e8e33de, analysis_f7d9a9f9559ef565:block_c1c2585412b202, analysis_f7d9a9f9559ef565:py_class_3c0016ca138c, analysis_f7d9a9f9559ef565:py_class_968324251552
c27 Function connected_runner (117-170) connects to 14 downstream relations. A with block at 156-168 inside it scopes operations under a context manager. inferred supported analysis_f7d9a9f9559ef565:block_a4244bce87bb67, analysis_f7d9a9f9559ef565:block_9c7142b26735f9, analysis_f7d9a9f9559ef565:py_func_8b3488a911f6
c28 Two straight_line blocks inside connected_runner, at 141-154 and 137-138, group sequential statements. inferred supported analysis_f7d9a9f9559ef565:block_77e669430655b5, analysis_f7d9a9f9559ef565:block_e4971cd6d2478b
c29 The analyzer classes tests/interaction/_requirements.py as a leaf/data-boundary candidate with 37 incoming calls. inferred supported analysis_f7d9a9f9559ef565:role_266
c30 The analysis is static only. Reflection, runtime dependency injection, dynamic imports, monkey-patching, generated code, framework runtime wiring and dynamic dispatch are not resolved. observed supported analysis_f7d9a9f9559ef565:lim_1
c31 Install, run and build inference is partial, and installation commands are not verified. observed supported analysis_f7d9a9f9559ef565:lim_2
c32 The analysis is bounded: files over 400 kB, minified bundles and vendored directories are inventoried but not parsed, and relation extraction is capped per file and per repository. observed supported analysis_f7d9a9f9559ef565:lim_6
c33 Block descriptions are analyzer inferences with confidence values, and static analysis cannot establish all runtime behaviour. inferred supported analysis_f7d9a9f9559ef565:summary_repository, analysis_f7d9a9f9559ef565:claim_7c9925f9c8f4
c34 The uncertainties lesson lists module blocks for .github/scripts/docs_preview.js and docs_preview.test.js at confidence 0.68, plus function blocks authorize, permissionFor, comment, upsert, pushed and slash. inferred supported analysis_f7d9a9f9559ef565:block_ae798d62e65d39, analysis_f7d9a9f9559ef565:block_d47258a292ee5e, analysis_f7d9a9f9559ef565:block_71d5568e8c1200, analysis_f7d9a9f9559ef565:block_c79b1773a0f022, analysis_f7d9a9f9559ef565:block_590bb0f0a1a36f, analysis_f7d9a9f9559ef565:block_1cebd7a1433daa, analysis_f7d9a9f9559ef565:block_700ac72966992b, analysis_f7d9a9f9559ef565:block_e89ca65b03c503

Sources, rights and disclosure · attribution-license-templates/v0.1

Rights notice. Original repository hosted on GitHub. Repository source code, documentation, names, media, and related project materials remain subject to the rights of their respective authors, contributors, and other rights holders and to applicable repository license terms.

Platform notice. GitHub is the source hosting platform for the linked repository. GitHub and related marks are trademarks of GitHub, Inc. EVEMISS Technology is not affiliated with or endorsed by GitHub unless explicitly stated otherwise.

How this page is produced. This page was produced using revision-aware repository analysis and AI-assisted editorial tooling. Technical claims are tied to the analyzed repository revision and may be revalidated when the source repository changes.

AI-assisted analysis. Reviewed by EVEMISS Technology through human–AI collaborative review. · Report a rights concern · Back to the overview