-
Couldn't load subscription status.
- Fork 2
feat: add provider and action filtering to fetchTools() #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add provider and action filtering to fetchTools() #124
Conversation
This commit introduces comprehensive filtering capabilities to the
fetchTools() method in StackOneToolSet, allowing users to filter tools
by providers and action patterns in addition to the existing account ID
filtering.
Changes:
1. Core Implementation (src/toolsets/stackone.ts):
- Add 'providers' option to FetchToolsOptions interface
* Filters tools by provider names (e.g., ['hibob', 'bamboohr'])
* Case-insensitive matching for robustness
- Add 'actions' option to FetchToolsOptions interface
* Supports exact action name matching
* Supports glob patterns (e.g., '*_list_employees')
- Implement private filterTools() method
* Applies provider filtering by extracting provider from tool name
* Applies action filtering using glob pattern matching
* Filters can be combined for precise tool selection
- Refactor fetchTools() to support new filters
* Maintains backward compatibility with existing account filtering
* Applies filters sequentially for optimal performance
2. Comprehensive Test Coverage (src/toolsets/tests/stackone.mcp-fetch.spec.ts):
- Add 11 new test cases covering:
* Provider-only filtering
* Action filtering with exact matches
* Action filtering with glob patterns (*_list_employees)
* Combined accountIds + actions filtering
* Combined accountIds + providers filtering
* Combined providers + actions filtering
* All three filters combined (accountIds + providers + actions)
* Edge cases (empty filters, non-matching patterns)
- All tests pass (145/145 tests passing)
3. Documentation Updates (README.md):
- Add comprehensive "Filtering Tools with fetchTools()" section
- Document all filtering options with code examples:
* Account ID filtering (both via setAccounts() and options)
* Provider filtering
* Action filtering (exact match and glob patterns)
* Combined filters
- Include use cases for each filtering pattern
4. Enhanced Examples (examples/fetch-tools.ts):
- Transform from single example to comprehensive showcase
- Add 7 distinct examples demonstrating:
* Fetching all tools
* Account ID filtering (two methods)
* Provider filtering
* Action filtering (exact and glob)
* Combined filters
- Each example includes console output for clarity
Technical Details:
- Provider extraction uses tool name convention (provider_action format)
- Glob matching supports wildcards (* and ?) for flexible patterns
- Filters are applied sequentially and can be combined
- All filtering is case-insensitive for providers
- Maintains full backward compatibility with existing code
Testing:
- All 145 tests pass successfully
- Lint checks pass
- No breaking changes to existing API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds provider and action filtering capabilities to the fetchTools() method, enabling users to filter tools by provider names and action patterns (with glob support) in addition to the existing account ID filtering. These filters can be combined for precise tool selection in multi-provider, multi-account scenarios.
Key Changes:
- Added
providersandactionsoptional parameters toFetchToolsOptionsinterface - Implemented
filterTools()private method with case-insensitive provider matching and glob pattern support for actions - Enhanced documentation with filtering examples and use cases
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/toolsets/stackone.ts | Core implementation of provider and action filtering logic with filterTools() method |
| src/toolsets/tests/stackone.mcp-fetch.spec.ts | Comprehensive test suite covering individual filters and combinations |
| examples/fetch-tools.ts | Expanded examples demonstrating all filtering options |
| README.md | Documentation updates with filtering examples and use cases |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 4 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="examples/fetch-tools.ts">
<violation number="1" location="examples/fetch-tools.ts:47">
This provider-only example still inherits the account filter set earlier, so it will not actually demonstrate provider filtering in isolation and may produce empty results when those accounts lack these providers. Please clear the account IDs before this call or pass accountIds explicitly.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
|
|
||
| // Example 4: Filter by providers | ||
| console.log('\n=== Example 4: Filter by providers ==='); | ||
| const toolsByProviders = await toolset.fetchTools({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This provider-only example still inherits the account filter set earlier, so it will not actually demonstrate provider filtering in isolation and may produce empty results when those accounts lack these providers. Please clear the account IDs before this call or pass accountIds explicitly.
Prompt for AI agents
Address the following comment on examples/fetch-tools.ts at line 47:
<comment>This provider-only example still inherits the account filter set earlier, so it will not actually demonstrate provider filtering in isolation and may produce empty results when those accounts lack these providers. Please clear the account IDs before this call or pass accountIds explicitly.</comment>
<file context>
@@ -24,10 +24,59 @@ const toolset = new StackOneToolSet({
+
+// Example 4: Filter by providers
+console.log('\n=== Example 4: Filter by providers ===');
+const toolsByProviders = await toolset.fetchTools({
+ providers: ['hibob', 'bamboohr'],
+});
</file context>
Summary
This PR introduces comprehensive filtering capabilities to the
fetchTools()method inStackOneToolSet, enabling users to filter tools by providers and action patterns with glob support. These new filters can be combined with the existing account ID filtering for precise tool selection.What Changed
Core Implementation
Provider Filtering: Added
providersoption to filter tools by provider names (e.g.,['hibob', 'bamboohr'])provider_actionconventionAction Filtering: Added
actionsoption to filter tools by action patterns['hris_list_employees'])['*_list_employees'])Filter Combination: All filters (accountIds, providers, actions) can be combined for precise control
Code Changes
Modified
src/toolsets/stackone.ts:FetchToolsOptionsinterface withprovidersandactionsfieldsfilterTools()private method for applying filtersfetchTools()to support new filtering logicAdded comprehensive tests in
src/toolsets/tests/stackone.mcp-fetch.spec.ts:Updated documentation in
README.md:Enhanced
examples/fetch-tools.ts:Examples
Filter by Providers
Filter by Actions (Exact Match)
Filter by Actions (Glob Pattern)
Combine Multiple Filters
Why These Changes
These filtering capabilities are essential for:
Testing
Use Cases
actions: ['*_list_*', '*_get_*']providers: ['hibob']actions: ['*_employees*']accountIds: ['acc-123'], providers: ['bamboohr']Related Issues
This feature completes the dynamic tool fetching capabilities introduced in ENG-11034.
Summary by cubic
Adds provider and action filters (with glob patterns) to fetchTools() so you can narrow the tool catalog by provider and operation alongside existing account ID filtering. This delivers the dynamic MCP tool fetching requested in ENG-11034.