modelcontextprotocol / modelcontextprotocol/java-sdk

Allow dynamic generation of tool definition in MCP Server

Aberta
#626 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

enhancement feature/repositories
Linguagem predominante
Java
Estrelas
3.7k
Forks
1.1k
Merge médio
1d 15h
PRs com merge (30d)
9

Descrição

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.

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece rastreando onde ToolCallbackProvider.getToolCallbacks é chamado durante a inicialização e onde o servidor MCP trata as solicitações de tools/list. Adicione a flag solicitada para que tools/list possa escolher entre callbacks armazenados em cache e buscá-los novamente, depois verifique ambas as configurações da flag e as definições dinâmicas de ferramentas com os testes existentes do servidor.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
java
Domínio
backend-api-design
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
45/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.