fix(plugin-mcp): pass MCP request context through tool callbacks to fetch#2553
Draft
fix(plugin-mcp): pass MCP request context through tool callbacks to fetch#2553
Conversation
|
Co-authored-by: stijnvanhulle <5904681+stijnvanhulle@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix MCP not passing down headers to fetch
fix(plugin-mcp): pass MCP request context through tool callbacks to fetch
Feb 22, 2026
Contributor
|
Auto fix applied for linting and formating |
More templates
@kubb/agent
@kubb/cli
@kubb/core
kubb
@kubb/mcp
@kubb/oas
@kubb/plugin-client
@kubb/plugin-cypress
@kubb/plugin-faker
@kubb/plugin-mcp
@kubb/plugin-msw
@kubb/plugin-oas
@kubb/plugin-react-query
@kubb/plugin-redoc
@kubb/plugin-solid-query
@kubb/plugin-svelte-query
@kubb/plugin-swr
@kubb/plugin-ts
@kubb/plugin-vue-query
@kubb/plugin-zod
unplugin-kubb
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.
MCP-generated tool handlers were discarding the
RequestHandlerExtra(2nd arg ofserver.tool()callbacks), so callers had no way to propagate auth headers or other request context to the underlying API fetch.Changes
plugin-client/src/components/Client.tsx— adds optionalrequestParam?: stringprop; when set, appends, ${requestParam}?: unknownto the generated function signature and passes it as the second arg tofetch(non-configurable path only)plugin-mcp/src/generators/mcpGenerator.tsx— passesrequestParam="request"toClientso every MCP handler accepts and forwards request contextplugin-mcp/src/components/Server.tsx— updatesserver.tool()callback templates to capture and threadrequestthrough to handlers:async (params, request) => handler(params, request)async (_, request) => handler(request)Generated output (before → after)
Before:
After:
✅ Checklist
pnpm run test.🚀 Release Impact
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.