Skip to content

Support dynamic tool provider callback (e.g. ToolProvider / ToolSupplier) #1029

@Jackprogramer

Description

@Jackprogramer

Currently McpSyncServer stores tools in a CopyOnWriteArrayList that is read directly on each tools/list request. To
make tools dynamic, users must manually call addTool() / removeTool() + notifyToolsListChanged() to keep the internal
list in sync with an external source (e.g. a database).

This works, but it pushes synchronization logic into application code — every place that creates/updates/deletes a
tool must also update the server, which is error-prone and tightly couples business logic to the MCP server instance.

Proposal: Add a pluggable ToolProvider (or ToolSupplier) callback interface that the server invokes on each tools/list
request, so users can supply tools from any dynamic source without manual sync:

@FunctionalInterface
public interface SyncToolProvider {
List listTools(McpSyncServerExchange exchange);
}

This way, toolsListRequestHandler would call the provider instead of reading from the static list, and users simply
implement the interface to query a database, call an API, etc. — no addTool/removeTool/notifyToolsListChanged
bookkeeping needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions