Repository navigation
Support for Parameter Passing in MCP Configuration and Runtime Context #1023
Description
Description
Title: Support for Parameter Passing in MCP Configuration and Runtime Context
Issue Description:
I would like to request support for parameter passing in MCP (Model Context Protocol) in two key scenarios:
1. Configuration-time Parameter Passing
Use Case: When configuring streamable HTTP connections, there's a need to pass business-specific parameters to the MCP server during initialization.
Request:
- How can we configure additional business parameters in the MCP configuration?
- What's the proper way for MCP servers to receive and process these configuration parameters?
- Is there a dedicated entry point or configuration section for custom parameters?
Example Scenario:
{"mcpServers": {
"weather": {
"url": "http://localhost:8000/mcp",
"transport": "streamable_http",
"customParams": {
"apiKey": "xxx",
"environment": "production",
"businessConfig": {...}
}
}
}
}2. Runtime Context Parameter Passing
Use Case: During MCP tool invocation, there's a need to pass sensitive or context-specific parameters that should:
- Be accessible to the MCP server tools
- Remain hidden from the AI model for security reasons
- Be transmitted transparently through the MCP protocol
Request:
- Support for header-like parameter passing mechanism in MCP SDK
- Secure context parameter transmission that bypasses model visibility
- Runtime parameter injection for tool execution
Previous Implementation Reference:
In previous business implementations, we used HTTP headers to pass such parameters. We're looking for similar functionality in the MCP SDK.
Expected Behavior:
// Client side - passing context parameters
await mcpClient.callTool('my-tool', {arguments: {...},
context: {userId: "user123",
sessionId: "session456",
securityToken: "token789"// Hidden from model}
});
// Server side - accessing context parameters
function myTool(args, context) {
const userId = context.userId;const securityToken = context.securityToken;
// Tool implementation
}Would appreciate guidance on current capabilities and potential roadmap for these features.
References
No response
Activity
tsitsimis commentedon Aug 5, 2025
That would be very useful, lack of this feature led us use the alternative fastmcp that supports it: https://gofastmcp.com/patterns/tool-transformation
maxisbey commentedon Jul 24, 2026
Both of these have a channel in v2:
Connection-time parameters. The
mcpServersJSON is your host's config format rather than something the SDK defines, but connection-scoped values (an API key, an environment, a tenant) travel as HTTP headers: set them on anhttpx2.AsyncClientand pass it viastreamable_http_client(url, http_client=...)(Bring your ownhttpx2.AsyncClient), then read them in the handler withctx.headers(The Context).Per-call context hidden from the model. That's the request's
_metafield: the client sendscall_tool(name, arguments, meta={...}), it rides alongside the model-authoredargumentsrather than inside them, and the handler reads it asctx.request_context.metaonMCPServer(orctx.metaon the low-levelServer).Example
One caveat: headers and
_metaare both client-supplied input, so they're fine for a locale or a feature flag but shouldn't be trusted as identity; for that, use OAuth (Authorization).Closing this as part of a wider backlog cleanup around the v2 release. Feel free to reopen if this is still relevant.
AI Disclaimer