Skip to content

Conversation

aarora79
Copy link
Contributor

Summary

This PR implements tag-based filtering for the intelligent_tool_finder function and streamlines the agent authentication system.

Enhanced intelligent_tool_finder (Addresses Issue #126)

  • New tags parameter: Filter tools by server tags using AND logic
  • Three operation modes:
    • Semantic search only (current behavior)
    • Tags only (new)
    • Combined semantic + tags (new)
  • Backward compatible: All existing calls work unchanged
  • AI agent safety: Comprehensive warnings against inferring tags

Authentication System Cleanup

  • Streamlined flow: Primary authentication via .oauth-tokens/ directory
  • Removed complexity: Eliminated confusing .env file handling
  • Cleaner UX: No more "ENVIRONMENT CONFIGURATION" banners
  • Preserved fallbacks: System environment variables still supported

Technical Implementation

intelligent_tool_finder Changes

# New signature with optional tags parameter
async def intelligent_tool_finder(
    natural_language_query: Optional[str] = None,
    tags: Optional[List[str]] = None,
    top_k_services: int = 3,
    top_n_tools: int = 1
)

Behavior Matrix

Query Tags Behavior
✅ Provided ❌ None Semantic search only
✅ Provided ✅ Provided Semantic search AND filtered by tags
❌ None ✅ Provided Return tools matching tags only

Bug Fixes

  • Fixed KeyError: Tags-only mode no longer crashes on missing similarity scores
  • Proper logging: Shows "(tags-only mode)" vs similarity scores appropriately

Testing

✅ Verified Scenarios

  • Tags only: tags=["sre"] returns only SRE Gateway tools
  • Combined: Query + tags returns semantically relevant tools from tag-matched services
  • Semantic only: Original behavior preserved exactly
  • Authentication: Clean token-based auth without .env complexity

Test Results

# Tags-only mode working
MCPGW: Service /mcpgw/ does not match required tags ['sre'], has tags ['registry', 'management']. Skipping.
MCPGW: Service /realserverfaketools/ does not match required tags ['sre'], has tags ['demo', 'fake', 'tools', 'testing']. Skipping.
MCPGW: Tags-only mode - 21 tools found without semantic ranking

Documentation Updates

  • Enhanced docstring: Clear usage examples and AI agent warnings
  • Updated schema: mcpgw.json includes new tags parameter with descriptions
  • Agent safety: Explicit warnings about not inferring tags from queries

Benefits

  1. Improved Precision: Filter tools by specific categories
  2. Better UX: Combine semantic search with categorical filtering
  3. AI Agent Efficiency: Enable precise tool discovery using known categories
  4. Performance: Tags-only mode faster than semantic search for category-based discovery
  5. Cleaner Auth: Simplified authentication flow using .oauth-tokens/

Breaking Changes

None - All existing functionality preserved and backward compatible.

Files Changed

  • servers/mcpgw/server.py: Enhanced intelligent_tool_finder with tag support
  • registry/servers/mcpgw.json: Updated tool schema and documentation
  • agents/agent.py: Streamlined authentication, removed .env complexity

Related Issues

Closes #126 - Enhancement: Add tag-based filtering to intelligent tool finder

… authentication

## Enhanced intelligent_tool_finder with tag support
- Add optional 'tags' parameter for filtering tools by server tags using AND logic
- Support three modes: semantic search only, tags only, and combined semantic + tags
- Maintain backward compatibility with existing query-only calls
- Add comprehensive docstring warnings for AI agents about tag usage
- Update mcpgw.json with new tool schema including tags parameter

## Fixed tags-only mode error
- Resolve KeyError when using tags without semantic search
- Add proper logging for tags-only mode vs similarity scores
- Update container with patched server.py to handle missing similarity scores

## Streamlined agent authentication
- Remove complex .env file handling logic from agents/agent.py
- Primary authentication now uses .oauth-tokens/ directory
- Keep simple environment variable fallback for system-level config
- Remove deprecated --user-env-file and --agent-env-file parameters
- Clean up authentication flow to use tokens > ingress.json > Cognito generation

## Related to issue #126
- Implements tag-based filtering enhancement as specified
- Enables precise tool discovery by category with semantic search integration
@aarora79 aarora79 added enhancement New feature or request feature-request New feature or enhancement request labels Sep 20, 2025
Add one-liner to What's New section highlighting the enhanced intelligent_tool_finder
with tag-based filtering capability for precise categorical tool discovery.
@aarora79 aarora79 merged commit 81bd851 into main Sep 20, 2025
5 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature-request New feature or enhancement request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Add tag-based filtering to intelligent_tool_finder
1 participant