Repository navigation
Conversation
Optional tool arguments used zod .optional(), which accepts undefined but rejects null. Some MCP clients send null for arguments they leave unset, so nextjs_index and nextjs_call failed with "Invalid argument". Make those two fields .nullish(), treat a null port as omitted in nextjs_index, and keep the advertised JSON schema in sync with what the server accepts. Agent: claude
Replace the real-port nextjs_index null e2e case with a nextjs_call case against a loopback fake /_next/mcp endpoint, so no real dev server can change the result. Describe null args as treated like omitted in both nextjs_call descriptions, and add a mocked nextjs_index null-port case. Agent: claude
…reate the temp home Agent: claude
Cite the sources for the null handling and SIGKILL comments. Agent: claude
Author
|
Checking in on this one. Is there anything I should change to get it ready to merge? Happy to rebase or adjust. |
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.
Fixes #161
Problem
nextjs_index(port) andnextjs_call(args) reject an explicitnullwithInvalid argument '...', even though both are optional. The cause is zod:ZodOptional._parsereturnsundefinedunchanged and passes every other value,nullincluded, to its inner type, which then fails (node_modules/zod/v3/types.js:3310-3317, zod 3.25.76).Fix
Both fields use
.nullish(), which is.nullable().optional()(node_modules/zod/v3/types.js:295-297);ZodNullableacceptsnull(types.js:3329-3336), sonulland a missing value both mean unset. A nullportruns auto-discovery, as an omitted one does. A nullargsbecomes{}, as a missing one does. Thenextjs_indexport andnextjs_callargs descriptions and the README say so.The advertised JSON Schema now allows
null, matching the server. Treatingnullas omitted inparseToolArgs(src/index.ts:107) would leave the schema rejecting it.Callers checked:
src/index.ts(a null port reachesnextjs_index);src/tools/nextjs_call.ts(does not call it);browser-eval.tsandnextjs-docs.ts(own handlers, unchanged).Tests: null cases in
test/unit/tool-input-schema.test.ts, a mocked null-port case intest/unit/nextjs-index-validation.test.ts, and an end-to-endnextjs_callcase intest/e2e/mcp-registration.test.ts(fake endpoint, isolated home directory).Ran live: JSON-RPC over stdio into
node dist/index.jsbuilt at 0181404, sendingnextjs_index {"port": null}andnextjs_call {"port": 4555, "toolName": "get_errors", "args": null}. Both return tool results with no JSON-RPC error:No running Next.js dev servers with MCP enabled foundandCannot connect to Next.js dev server on port 4555. Pre-fix commit 1e8dcfa returnedInvalid argument 'port'andInvalid argument 'args'.AI disclosure: written and checked with AI assistance, including the tests and the live run; I take responsibility for it.