fix(module): generate typed return values from tool outputSchema#210
Merged
HugoRCD merged 5 commits intonuxt-modules:mainfrom Apr 7, 2026
Merged
fix(module): generate typed return values from tool outputSchema#210HugoRCD merged 5 commits intonuxt-modules:mainfrom
HugoRCD merged 5 commits intonuxt-modules:mainfrom
Conversation
Tools with outputSchema now emit typed Promise return values in code mode type definitions instead of Promise<unknown>. Small schemas (<=3 primitive fields) are inlined; larger schemas get named interfaces.
…pe generation Added a new function to format TypeScript property keys, ensuring non-safe identifiers are quoted. Introduced a utility to generate schema type information, streamlining the handling of input and output schemas in tools. This improves type safety and clarity in generated type definitions.
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 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
Code mode returns
Promise<unknown>for all tools, even those withoutputSchemaAll tool methods in code mode type definitions show
=> Promise<unknown>regardless of whether the tool defines anoutputSchema. Agents must call a tool and inspect the result to learn its shape, wasting a round trip.Root cause
generateToolTypeInfo()intypes.tsonly processesinputSchemafor parameter types. TheoutputSchemafield is ignored entirely, so every tool's return type defaults toPromise<unknown>.Solution
After input schema processing,
generateToolTypeInfo()now also processestool.outputSchemausing the same schema-to-TypeScript generation path:Promise<{ id: string; ok: boolean }>Promise<WorkspaceOverviewOutput>Promise<unknown>(unchanged behavior)Catalog entries (
generateToolCatalog) also include output interface declarations, so progressive-mode search results show return types too.Note: runtime alignment for returning structured output is handled separately in PR #207. This PR is limited to generating the typed return declarations.
Files changed
packages/nuxt-mcp-toolkit/src/runtime/server/mcp/codemode/types.tsgenerateToolTypeInfo(), shared schema-to-TypeScript generation, valid TS property-key emission, updatedgenerateTypesFromTools()andgenerateToolCatalog()packages/nuxt-mcp-toolkit/test/codemode.test.tsTest plan
pnpm testpassespnpm lintpassesAI tools used