fix(module): prefer structuredContent in code mode dispatch#207
Merged
HugoRCD merged 2 commits intonuxt-modules:mainfrom Apr 7, 2026
Merged
fix(module): prefer structuredContent in code mode dispatch#207HugoRCD merged 2 commits intonuxt-modules:mainfrom
HugoRCD merged 2 commits intonuxt-modules:mainfrom
Conversation
When a tool handler returns structuredContent (the MCP spec's typed data channel), buildDispatchFunctions() ignored it and fell through to extracting text from content[].text — silently losing IDs, booleans, and nested objects. This broke operation chaining where a returned ID is needed for follow-up calls.
…edContent handling Updated the codemode tests to utilize a mockMcpExtra function, ensuring that structuredContent is correctly processed in tool handlers. Changed tool definitions from McpToolDefinition to McpToolDefinitionListItem for better type alignment.
Contributor
|
@Mat4m0 is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Thank you for following the naming conventions! 🙏 |
commit: |
This was referenced Apr 6, 2026
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.
The problem
structuredContentsilently dropped in code mode dispatch (data loss)When a tool handler returns
structuredContent(the MCP spec's typed data channel), the dispatch function inbuildDispatchFunctions()ignores it entirely and falls through to extracting text fromresult.content[].text. This silently loses IDs, booleans, and nested objects — the agent receives a stringified summary instead of the actual structured data.This breaks any workflow that chains operations using returned data:
Root cause
buildDispatchFunctions()went straight toresult.contenttext extraction without ever checkingresult.structuredContent.Solution
Added a
structuredContentcheck before the text extraction fallback:When
structuredContentis present, it is returned directly — preserving typed fields (booleans, numbers, nested objects, IDs) for use in sandbox code. When absent, the existingcontent[].textextraction continues to work unchanged.Files changed
index.tsbuildDispatchFunctions(): checkresult.structuredContentbefore text extractioncodemode.test.tsTest coverage
5 new tests in
test/codemode.test.ts:All 150 tests pass (20 test files).
Test plan
pnpm testpasses (150/150)structuredContentwith an ID → sandbox code receives the ID, uses it in a follow-up callcontent[].text(no structuredContent) → existing behavior unchangedAI tools used