Allow dynamic generation of tool definition in MCP Server

未关闭
#626 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
java

调研方向

首先跟踪启动期间调用 ToolCallbackProvider.getToolCallbacks 的位置,以及 MCP 服务器处理 tools/list 请求的位置。添加所请求的 flag,使 tools/list 可以选择使用缓存的回调,或再次获取这些回调,然后使用现有的服务器测试验证 flag 的两种设置和动态工具定义。

由索引模型根据 Issue 内容生成。

描述

enhancement feature/repositories

Please do a quick search on GitHub issues first, the feature you are about to request might have already been requested.

Expected Behavior
Add a boolean property/flag called "callGetToolCallbacksEverytime".
If the flag is set to true then everytime an MCP server receives a tools/list request, the MCP server should call getToolCallbacks on registered ToolCallbackProvider. This will allow an MCP Server's implementation to dynamically generate ToolDefinition based on the request. All the implementation will need to do is provide a custom ToolCallbackProvider and also set the flag to true. If the flag is set to "false" then the current behaviour of calling getToolCallbacks only during startup is used.

Current Behavior

In the current behavior, i configured a custom ToolCallbackProvider to override the "description" that is generated for my tool. However, my tool callback provider's "getToolCallbacks" method is only called once during application startup. When my MCP Client sends a "tools/list" request, the MCP Server returns the tool definitions it computed at application startup. It doesn't try to get the new list from ToolCallbackProvider.

In the current behavior, getToolCallbacks is called on a ToolCallbackProvider only at startup. This makes it impossible to generate tool definition dynamically i.e. when "tools/list" request is received.

Context

My use case requires me to generate tool description dynamically based on the user of the MCP Client. MCP Client invokes a "tools/list" request but my Spring AI based MCP Server returns tooldefinition that it computed at the application startup. In my use case i would like to generate description for my tool dynamically everytime the MCP Server receives a "tools/list" request.

主要语言
Java
星标
3.7k
派生
1.1k
平均合并
1 天 15 小时
30 天内合并 PR
9

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/java-sdk 的其他 Issue

查看 modelcontextprotocol/java-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。