17 Declarations at shifted phases🔗ℹ

The SDK uses a locally patched syntax-spec-v3 dependency, based on upstream commit 4ae36610804b58e8f023574bfdcba1b5ae4f7bcd. The original dependency loses a module scope when compiling references to declarations created inside begin-for-syntax. The patch preserves the declaration’s lexical context for module-level generated temporaries. Internal bindings keep the original temporary generation behavior; preserving every internal scope causes ambiguous bindings in an upstream command-line DSL test.

The patch also constructs persistent identifier tables at the binding phase corresponding to the compiler module instance. Comparing all identifiers at phase zero can merge distinct same-spelled local arguments at higher phases, such as the id arguments of unrelated resource and prompt declarations.

scripts/prepare-syntax-spec.py verifies the unchanged vendored snapshot and reproduces the installable dependency at packages/mcp-syntax-spec-v3. Its package and collection name is mcp-syntax-spec-v3, so it can coexist with the upstream syntax-spec-v3 package. The SDK dependency declaration points to this repository’s package subdirectory; consumers of the published source do not need to run the Python preparation script. The reference-compiler patch attaches each delayed default directly to its binding-class transformer, while retaining thread-local scoped overrides. A class first visited in one worker must remain usable when another worker or the main thread accesses its exported binding. Defaults previously stored only in a parameter could be lost across that boundary. Defaults now travel with lexical bindings, without registration in a mutable table. The promise preserves forward references and evaluates a default only when it is first used. Scoped overrides take precedence.

The patch has version 0.1.0.2, required by the SDK package. Preparation performs no network access or package installation. The generated MCP-PATCH.json records the upstream commit and original/patched compiler and binding-table, reference-compiler and binding-generator hashes, plus hashes of the namespaced package files. Use –check to verify the generated package without writing it, or –archive PATH to produce a reproducible source ZIP. See the README for isolated installation and update commands.

dev/check-phase-references.rkt tests declarations and ordinary references at phases 0, 1 and 2 in both MCP and a minimal syntax-spec language that imports no MCP code. MCP cases include schemas, shapes, tools, resources, prompts, workflows, same-spelled arguments and host shadowing. Every case runs in a bounded child process; any failure exits nonzero. tests/phases.rkt includes this probe in routine native verification. Existing tests also cover shifted imports and declaration metadata. This evidence does not establish every combination of phases, extensions and dynamic composition.