Skip to content

Conversation

@peteski22
Copy link
Contributor

@peteski22 peteski22 commented Nov 13, 2025

  • Add optional servers parameter to filter tools by server name
  • Support single server, multiple servers, or all servers (default)
  • Silently skip non-existent servers for graceful handling
  • Add comprehensive unit tests for all filtering scenarios
  • Update README with usage examples
  • Maintains full backward compatibility

Summary by CodeRabbit

Release Notes

  • New Features

    • Tool retrieval now supports optional server filtering, allowing clients to fetch tools from specific servers by name or retrieve all available tools across all servers.
  • Documentation

    • Updated with practical examples demonstrating server filtering capabilities and multi-server tool retrieval.

- Add optional servers parameter to filter tools by server name
- Support single server, multiple servers, or all servers (default)
- Silently skip non-existent servers for graceful handling
- Add comprehensive unit tests for all filtering scenarios
- Update README with usage examples
- Maintains full backward compatibility
@peteski22 peteski22 added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 13, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Walkthrough

Updates the agent_tools() method to support optional server-based filtering via a new servers parameter. Adds documentation examples and unit tests demonstrating filtering capabilities for retrieving tools from specific servers or all servers.

Changes

Cohort / File(s) Summary
Documentation updates
README.md
Adds example usage of agent_tools() API in Agentic Usage section, including fetching all tools, filtering by specific servers, and fetching from multiple servers.
Core implementation
src/mcpd/mcpd_client.py
Updates agent_tools() method signature to accept optional servers: list[str] | None parameter. Implementation now filters tools by specified servers, silently skipping non-existent servers, while preserving default behaviour of returning all tools when parameter is omitted.
Test coverage
tests/unit/test_mcpd_client.py
Adds comprehensive unit tests for agent_tools() filtering logic, validating single server filtering, multiple server filtering, non-existent server handling, empty server list handling, and default behaviour with no parameter provided.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add server filtering to agent_tools() method' directly and clearly summarises the main change: adding an optional servers parameter to the agent_tools() method for filtering tools by server name.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch peteski22/agent-tools-server-filtering

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b48657b and 0e525b0.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • src/mcpd/mcpd_client.py (4 hunks)
  • tests/unit/test_mcpd_client.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/unit/test_mcpd_client.py (2)
src/mcpd/mcpd_client.py (3)
  • McpdClient (56-838)
  • agent_tools (370-450)
  • servers (216-263)
tests/conftest.py (1)
  • client (51-52)
🔇 Additional comments (4)
README.md (1)

93-101: Excellent documentation of the new filtering capability.

The examples clearly demonstrate the three primary use cases for the new servers parameter. The progression from fetching all tools to filtering by single/multiple servers makes the API intuitive and easy to understand.

src/mcpd/mcpd_client.py (2)

370-370: Well-designed API with clear parameter documentation.

The optional servers parameter maintains backward compatibility whilst adding useful filtering capability. The type hint and documentation clearly convey the behaviour: None returns all tools, whilst a list filters to specific servers.

Also applies to: 381-386


413-416: Docstring examples enhance API discoverability.

Including usage examples directly in the method docstring helps developers understand the filtering capability without needing to consult external documentation.

tests/unit/test_mcpd_client.py (1)

146-226: Comprehensive test coverage validates all filtering scenarios.

The test suite thoroughly covers:

  • Positive cases: Single server filtering (147-162) and multiple server filtering (165-181)
  • Edge cases: Nonexistent servers (184-194) and empty server lists (197-207)
  • Backward compatibility: Default behaviour without the parameter (210-225)

Each test properly verifies both the returned results and the internal interactions with create_function_from_schema, including call counts and arguments. The test structure is clean, focused, and well-documented.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@peteski22 peteski22 requested a review from daavoo November 13, 2025 17:30
Copy link
Contributor

@daavoo daavoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment but otherwise lgtm

@peteski22 peteski22 merged commit afcb2b9 into main Nov 13, 2025
8 checks passed
@peteski22 peteski22 deleted the peteski22/agent-tools-server-filtering branch November 13, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants