Repository navigation
fix(typescript): compile MCP server when the document defines no servers - #216
Open
AshGodfrey wants to merge 1 commit into
Open
AshGodfrey wants to merge 1 commit into
AshGodfrey wants to merge 1 commit into
Conversation
The generated src/lib/config.ts only declares SDKOptions.serverIdx (or SDKOptions.server for named servers) when the document has a server with an absolute URL. The MCP server templates emitted the server-index flag and the serverIdx pass-through whenever any servers object existed, including the implicit default or relative-only servers, which left the generated MCP server referencing SDKOptions["serverIdx"] and failing to compile. Gate those three places on the same predicate config.ts uses.
There was a problem hiding this comment.
No issues found across 5 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Fixes generated TypeScript MCP server compilation when the OpenAPI document defines no absolute servers by gating serverIdx/server pass-through on the same HasAbsoluteURL predicate config.ts uses; output for absolute-server documents is unchanged.
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack
View guided diff | Turn on auto-fix | Re-trigger cubic
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.
Why
With
enableMCPServer: true, a TypeScript SDK generated from a document that defines noservers(or only relative ones) failsnpm run build:src/lib/config.tsonly declaresSDKOptions.serverIdx(orSDKOptions.serverfor named servers) when the document has a server with an absolute URL. The MCP server templates emitted the--server-indexflag and theserverIdxpass-through whenever any servers object existed, which is always the case because the generator injects an implicit/server.What changed
templates/templates/typescriptv2/mcp-server/{cli/start/impl.ts,cli/start/command.ts,server.ts,create-mcp-server.ts}.stmplnow gate the server-selection flag, theserverIdx/serverdependency field and its pass-through on the same$hasServerspredicateconfig.ts.stmpluses.create-mcp-server.ts.stmplgains that predicate definition.Generated output is unchanged for documents that define an absolute server. For documents with no servers or only relative servers the MCP server no longer emits the
--server-indexflag, which never had a valid value there, and compiles.The
mcp-typescripttarget is not affected: itsconfig.tsalways declaresserverIdx, and its MCP templates already use the matching predicate.Testing
servers,enableMCPServer: true,zodVersion: v3: reproduced the three errors above onmain; with this changenpm run buildpasses andmcp start --helpshows no--server-index.servers: [/relative-url]: builds..speakeasy/), builds, andmcp start --helpstill lists--server-index.npm run format,make check-template-typescriptv2,make lint: clean.enableMCPServer: false, so this path is not exercised there.Public-safety check
.claude/skills/public-repo-communication/SKILL.md).git diff --check.Summary by cubic
Fixes TypeScript compilation of the generated MCP server when the OpenAPI document defines no servers or only relative ones. The MCP templates always emitted the
--server-indexflag andserverIdx/serverpass-through whenever a servers object existed, butconfig.tsonly declares those fields when a server has an absolute URL, sonpm run buildfailed withTS2339/TS2353errors.serverIdx/serverpass-through on the same$hasServerspredicateconfig.tsuses.mcp-typescripttarget already used the matching predicate and is unaffected.Written for commit 6f47860. Summary will update on new commits.