feat: dynamic tool discovery #198
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement Dynamic Toolset Discovery
Overview
This PR implements dynamic toolset discovery in the MCP server, allowing for more efficient tool management and better scalability. Instead of loading all tools at startup, the server now exposes a core set of tools plus special "meta-tools" that enable the client to discover and enable additional toolsets as needed.
Feature Details
The implementation adds three key tools:
list_available_toolsets
: Lists all available groups of tools and their current statusget_toolset_tools
: Shows the specific tools available within a given toolsetenable_toolset
: Activates a specific toolset, making its tools available for useImplementation
The feature is implemented in a new
dynamic
module with the following structure:types.ts
: Type definitions for toolsets and API responsesschemas.ts
: Zod schemas for request validationtool-definitions.ts
: Definitions for the dynamic discovery toolsindex.ts
: Core implementation of toolset management and request handlersindex.spec.unit.ts
: Comprehensive unit tests for the featureKey aspects of the implementation:
Benefits
Testing
The implementation includes comprehensive unit tests that verify all aspects of the dynamic toolset feature:
Core Functionality Tests
Tool-Specific Tests
Error Handling Tests
All tests are colocated with the implementation code for better maintainability and are run as part of the unit test suite.
Example Usage
tools/list
)list_available_toolsets
get_toolset_tools
enable_toolset
tools/list
calls