Skip to content

Conversation

@zzstoatzz
Copy link
Collaborator

Summary

Fixes the deprecation warning from pydantic-ai by updating the parameter name from mcp_servers to toolsets when instantiating pydantic-ai's Agent.

Closes #1205

Problem

The test suite was showing this deprecation warning:

tests/ai/test_mcp.py::test_mcp_git_server_tool_usage_and_output
  /home/runner/work/marvin/marvin/.venv/lib/python3.11/site-packages/pydantic_ai/agent/__init__.py:310: 
  DeprecationWarning: `mcp_servers` is deprecated, use `toolsets` instead

Solution

Updated the single location where Marvin passes MCP servers to pydantic-ai's Agent constructor:

  • Changed agent_kwargs["mcp_servers"] to agent_kwargs["toolsets"] in src/marvin/agents/agent.py:209

This is an internal implementation detail only. Marvin's public API remains unchanged - users continue to use mcp_servers when creating Marvin Agents.

Testing

✅ Verified the deprecation warning exists on main branch
✅ Confirmed the warning is eliminated with this fix
✅ All MCP-related tests pass:

  • tests/ai/test_mcp.py
  • tests/agents/test_mcp_integration.py

Backwards Compatibility

This change maintains full backwards compatibility:

  • Marvin's public API is unchanged
  • Users continue to pass mcp_servers to Marvin's Agent class
  • Only the internal pydantic-ai integration is updated

🤖 Generated with Claude Code

Updates the pydantic-ai Agent instantiation to use the new 'toolsets'
parameter instead of the deprecated 'mcp_servers' parameter. This change
is internal only - Marvin's public API remains unchanged.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings August 20, 2025 15:09
Copy link
Contributor

Copilot AI left a 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 fixes a deprecation warning from pydantic-ai by updating the parameter name used internally when passing MCP servers to pydantic-ai's Agent constructor.

  • Updates internal parameter from mcp_servers to toolsets to align with pydantic-ai's current API
  • Maintains full backwards compatibility for Marvin's public API
  • Eliminates deprecation warning in test suite

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@zzstoatzz zzstoatzz merged commit d36853a into main Aug 20, 2025
4 checks passed
@zzstoatzz zzstoatzz deleted the fix-mcp-servers-deprecation branch August 20, 2025 15:12
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.

Fix pydantic-ai deprecation: mcp_servers -> toolsets

2 participants