-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Feature Request: Dynamic Tool Registration Based on Authentication Context
Is your feature request related to a problem? Please describe.
The MCP server only supports static tool registration at startup or based on notifications which requires session management. This forces applications that need user-specific tools to either:
- Register all possible tools upfront (security/performance issues)
- Use hacky workarounds that override request handlers
We need to provide different tools based on the authenticated user's permissions and context.
Describe the solution you'd like
Add a dynamic tool registration mechanism that allows tools to be discovered at runtime based on authentication context:
interface DynamicToolProvider {
discoverTools(authInfo: AuthInfo): Promise<Tool[]>;
createTool(name: string, args: unknown): RegisteredTool;
}
mcpServer.registerDynamicToolProvider(provider: DynamicToolProvider): void;
Describe alternatives you've considered
Current Workaround: Override listTools
and callTool
handlers, access private _registeredTools
with @ts-expect-error
, duplicate schema conversion logic.
Notifications Approach: I know it's possible to achieve this using MCP notifications, but that requires implementing session management which adds significant complexity that do not overlap with the vision of making MCP server simple using HTTP Streamable API.
Additional context
We currently use this for dynamic actions based on user permissions in our Port platform. The workaround works but is fragile and duplicates logic that should be handled by the SDK.