You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support for per session dynamic tools/prompts #216
Is your feature request related to a problem? Please describe.
Currently if we call AddPrompt/AddTool, it adds the prompt/tool for all sessions. We don't have a way to dynamically add/remove a tool or prompt just for a specific session.
Describe the solution you'd like
Add AddPrompt/AddTool (and remove) to ServerSession as well to allow adding tools/prompts only to 1 session.
The MCP server loads different prompts and tools depending on the project type (e.g., Java, Python, JavaScript). We currently rely on the MCP root directory to determine the project context and load the appropriate resources. To work around limitations, we're using AddReceivingMiddleware to intercept and filter the tools/list and prompts/list methods. However, this approach doesn't work after initialization, as we have no way to trigger a list update event for just that single session.
Instead of exposing all prompts at once, I'd like to expose a tool like search for prompts based on some context, so initially, it would load no prompt, then when that tool is been called, it will dynamically add prompts based on the input, and just for that 1 session.
Why not create a separate server for each session, if this is desirable? This is why the (for example) HTTP handlers accept a function to get the server.
One of the reasons for passing a getServer callback to the HTTP handlers is so that they can support this type of per-session configurability.
hmm, that's a good idea, I haven't thought about using server that way, I was considering mcp server as a 1-1 mapping with http server, and handle multiple sessions within the same server, but maybe that would just work for my use case
Activity
jba commentedon Jul 31, 2025
Can you give an example of how this would be useful?
kzwang commentedon Jul 31, 2025
There are 2 use cases we'd benefit from this:
findleyr commentedon Jul 31, 2025
Why not create a separate server for each session, if this is desirable? This is why the (for example) HTTP handlers accept a function to get the server.
One of the reasons for passing a
getServercallback to the HTTP handlers is so that they can support this type of per-session configurability.kzwang commentedon Jul 31, 2025
hmm, that's a good idea, I haven't thought about using server that way, I was considering mcp server as a 1-1 mapping with http server, and handle multiple sessions within the same server, but maybe that would just work for my use case
jba commentedon Aug 5, 2025
Closing. Re-open if needed.