Skip to content

fix(tests): update MCP server test mocks to match production API - #22198

Merged
jquinter merged 1 commit into
mainfrom
fix/mcp-server-test-mock-mismatch
Feb 26, 2026
Merged

fix(tests): update MCP server test mocks to match production API#22198
jquinter merged 1 commit into
mainfrom
fix/mcp-server-test-mock-mismatch

Conversation

@jquinter

Copy link
Copy Markdown
Contributor

Summary

  • Fix 8 failing MCP server tests caused by a mock/production API mismatch
  • Tests were mocking filter_server_ids_by_ip (old API) but server.py now calls filter_server_ids_by_ip_with_info which returns a (server_ids, blocked_count) tuple
  • Updated all 8 mock sites to use the correct method name and return (server_ids, 0)

Failing tests fixed

  • test_get_tools_from_mcp_servers_continues_when_one_server_fails
  • test_get_tools_from_mcp_servers_handles_all_servers_failing
  • test_list_tools_filters_by_key_team_permissions
  • test_list_tools_multiple_servers_prefixed_names
  • test_list_tools_single_server_unprefixed_names
  • test_list_tools_strips_prefix_when_matching_permissions
  • test_list_tools_with_no_tool_permissions_shows_all
  • test_list_tools_with_team_tool_permissions_inheritance

Test plan

  • All 8 previously failing tests now pass

🤖 Generated with Claude Code

The tests were mocking `filter_server_ids_by_ip` but the production
code in server.py now calls `filter_server_ids_by_ip_with_info` which
returns a (server_ids, blocked_count) tuple. Update all 8 mock sites
to use the correct method name and return signature.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Feb 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Building Building Preview, Comment Feb 26, 2026 4:12pm

Request Review

@greptile-apps

greptile-apps Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes 8 failing MCP server tests by updating mock method names and return values to match the current production API. The production code (server.py, rest_endpoints.py) now calls filter_server_ids_by_ip_with_info which returns a (server_ids, blocked_count) tuple, but the test mocks were still using the old filter_server_ids_by_ip method that returns only the server IDs list.

  • All 8 mock assignments updated from filter_server_ids_by_ip to filter_server_ids_by_ip_with_info
  • Return values changed from server_ids to (server_ids, 0) to match the tuple signature
  • No production code changes; tests only
  • All tests remain mock-only with no real network calls

Confidence Score: 5/5

  • This PR is safe to merge — it only updates test mocks to match the existing production API with no risk of side effects.
  • The change is minimal, mechanical, and test-only. Each of the 8 modifications is identical: renaming the mocked method and updating the return type to match the production signature. I verified the production code in both server.py and rest_endpoints.py calls filter_server_ids_by_ip_with_info and expects a tuple return. No production code is modified.
  • No files require special attention.

Important Files Changed

Filename Overview
tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py Updated 8 mock sites from filter_server_ids_by_ip to filter_server_ids_by_ip_with_info with correct (server_ids, 0) tuple return, matching the production API in server.py and rest_endpoints.py.

Sequence Diagram

sequenceDiagram
    participant Test as Test Mock
    participant Manager as MCPServerManager
    participant Server as server.py / rest_endpoints.py

    Note over Server: Production code calls<br/>filter_server_ids_by_ip_with_info()
    Server->>Manager: filter_server_ids_by_ip_with_info(server_ids, client_ip)
    Manager-->>Server: (filtered_ids, blocked_count)

    Note over Test: Before fix (old mock)
    Test->>Manager: filter_server_ids_by_ip(server_ids, client_ip)
    Manager-->>Test: server_ids (list only)
    Note over Test: ❌ AttributeError — method not found

    Note over Test: After fix (new mock)
    Test->>Manager: filter_server_ids_by_ip_with_info(server_ids, client_ip)
    Manager-->>Test: (server_ids, 0) (tuple)
    Note over Test: ✅ Tests pass
Loading

Last reviewed commit: ace49b1

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@jquinter
jquinter merged commit 4419c7a into main Feb 26, 2026
33 of 35 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…k-mismatch

fix(tests): update MCP server test mocks to match production API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant