Connect Marvin agents to Model Context Protocol (MCP) servers for extended capabilities.
MCPServer
instances to the mcp_servers
argument when creating your Agent
.
Marvin uses pydantic-ai
under the hood for MCP server interactions. The most common server type you’ll likely use is MCPServerStdio
, which communicates with an MCP server running as a subprocess via its standard input/output.
jsr:@pydantic/mcp-run-python
package is one such server that can be run with Deno.
MCPServerStdio
(e.g., "deno"
or "uvx"
) is available in your system’s PATH or provide the full path to the executable.mcp-server-git
package (runnable with uvx
, part of uv
) provides Git tools over MCP.
mcp_servers
runs:
run_python_code
from the Python server, or git_log
from the Git server) are made available to the LLM just like standard Python tools.MCPServer
instance.examples/agent_mcp.py
This example showcases an agent that uses both a Python interpreter and Git tools via MCP to perform a multi-step task. You can run it locally to see MCP integration in action.
Running the example/agent_mcp.py script
examples/agent_mcp.py
, this typically means having Deno and jsr:@pydantic/mcp-run-python
available, as well as uv
and mcp-server-git
(if you intend to use the git server part).Then, from the root of the Marvin repository, you can run:git_log
and run_python_code
to complete its task.