Repository navigation
fix: declare @cosyte/fhir optional and run without the MCP SDK - #99
Merged
Merged
Conversation
Declare @cosyte/fhir as an optional dependency at ^0.1.0 beside @cosyte/transform, so an npm install with --legacy-peer-deps keeps it. The published fhir 0.1.5 satisfies transform's ^0.1.0 peer range, and a packed tarball installs with exit 0 under npm install, pnpm add and npm install --legacy-peer-deps, with FHIR parse and convert working in each. An install with --omit=optional crashed at startup on the missing @modelcontextprotocol/sdk. The SDK was already optional; the bins are bundled without code splitting, so the server module reached by a dynamic import was inlined and its static SDK imports hoisted to the top of the bin. Both bins now start the server through src/mcp/launch.ts, which imports the SDK dynamically and maps an absent one to CLI_PARSER_UNAVAILABLE (69) naming the package to install. The request wiring moves to src/mcp/wire.ts, which takes the SDK classes as arguments; the @cosyte/cli/mcp subpath is unchanged. Tests: absent-mcp-sdk.test.ts walks every module either bin reaches and fails on a static SDK import; pnpm smoke runs both built bins with the SDK hidden from the resolver. Docs that called this a known defect, the CLAUDE.md devDependency rule and the ci.yml comment are updated. Claude-Session: https://claude.ai/code/session_01MXLcW95gf97vs9RBU1YsXf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two install fixes, shipped together as one patch (0.1.6).
1.
@cosyte/fhiris declared. It moves fromdevDependenciestooptionalDependenciesat^0.1.0, the same range@cosyte/transformuses. The published fhir (0.1.5) satisfies transform's^0.1.0peer range. Before this, annpm install --legacy-peer-depskept transform and left fhir out, so FHIR andconvertexited 69. TheERESOLVEthat kept it a devDependency (#27) no longer reproduces. The CLAUDE.md rule and theci.ymlcomment are updated to say so.2.
--omit=optionalno longer crashescosyte.@modelcontextprotocol/sdkwas already optional. The fault was in the build: the bins are bundled without code splitting, so the server module thatcosyte mcpreached by a dynamicimport()was inlined into the bin. The bundler then hoisted that module's static SDK imports to the top of the bin, and every command loaded them. Both bins now start the server throughsrc/mcp/launch.ts, which imports the SDK with a dynamicimport()of the package (this stays dynamic in the bundle). An absent SDK maps toCLI_PARSER_UNAVAILABLE(exit 69), which names the package to install. The request wiring moved tosrc/mcp/wire.ts, which takes the SDK classes as arguments. The@cosyte/cli/mcpsubpath API is unchanged. No newCLI_*code was added.Tests:
test/absent-mcp-sdk.test.tschecks the mapping. It also walks every module either bin can reach, following dynamic imports, and fails on a static SDK import. It includes negative controls.pnpm smokeruns both built bins with the SDK hidden from Node's resolver, with a negative control. It reds against the old source.Clean-room proof from the packed tarball (recorded in RELEASING.md):
npm installpnpm addnpm install --legacy-peer-depsnpm install --omit=optionalThe local gate passes in full.
https://claude.ai/code/session_01MXLcW95gf97vs9RBU1YsXf