[Feature] Dynamic load MCP tools and prompts in runtime.
Search before asking
- [x] I searched in the issues and found nothing similar.
Description
Currently, we load tools and prompts provided by MCP server during the compile time, which requires connecting remote MCP server in compilation. We anticipate the need to support dynamic loading and unloading of tools, and the MCP Server may also dynamically update prompts or tools. In this case, statically obtaining the list of prompts and tools at compile time has limitations.
Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
Hi @wenjin272, this was in my mind when I was implementing MCP, I already have few Ideas about how we can implement this. Should I start a discussion for this if you have not already started it?
Hi @yanand0909, I haven't started this yet, feel free to start a discussion.
Hi Flink Agents maintainers,
I'd like to work on the remaining live-refresh part of this issue.
I'd like to investigate the MCP list-changed notification flow and implement a safe runtime refresh mechanism that handles tool/prompt additions and removals without exposing a partially updated catalog.
I'd also cover duplicate-name conflicts, reconnection, resource cleanup, and concurrent tool lookups during refresh with regression tests.
Could you confirm whether notification-driven refresh is the intended direction for #458? Should the initial implementation target Java MCP servers first, or should it cover both Java and Python?
Thanks!
Thanks @Rishankgupta08 for offering to work on this! Startup discovery has already been implemented in #1373 for #606, so this issue can focus on updates while the job is running.
Could you start a Discussion with a detailed design proposal before implementation? I’d like us to compare notification-driven refresh with alternatives, such as refreshing on demand with an optional TTL, before choosing a direction.
Please cover:
- Tool/prompt additions, removals, and changes to existing definitions, including how newly discovered tools become available to an Agent.
- The full flow from detecting a change to using the updated definitions in model requests and tool execution, with a sequence diagram showing the components and their execution contexts.
- How refresh interacts with in-flight requests, failures, name conflicts, reconnection, and resource cleanup.
- The proposed Java/Python scope, cross-language implications, and how the implementation builds on #1373.
- The behavioral contracts and how they will be tested.
We can then discuss the tradeoffs and agree on the approach and scope for the initial implementation.
Hi @wenjin272,
I've opened a GitHub Discussion with the detailed design proposal for #458, covering the refresh strategies, runtime flow, Java/Python scope, consistency, lifecycle handling, and testing approach.
I've shared the proposal there so we can discuss the trade-offs, refine the design, and agree on the initial implementation scope before I start coding.
Looking forward to your feedback. Thanks!