modelcontextprotocol / modelcontextprotocol/typescript-sdk
Dynamic Tool Registration Based on Authentication Context
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 4
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the SDK's current tool registration flow and the listTools and callTool handlers, including how _registeredTools is used. Define how DynamicToolProvider receives AuthInfo, discovers tools, and creates registered tools at runtime; done means authenticated requests expose only the appropriate tools without requiring session-management notifications or duplicated schema logic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100