Skip to main content
Glama

mcp-run-python

Official
by pydantic
third-party-tools.md4.5 kB
# Third-Party Tools Pydantic AI supports integration with various third-party tool libraries, allowing you to leverage existing tool ecosystems in your agents. ## MCP Tools {#mcp-tools} See the [MCP Client](./mcp/client.md) documentation for how to use MCP servers with Pydantic AI as [toolsets](toolsets.md). ## LangChain Tools {#langchain-tools} If you'd like to use a tool from LangChain's [community tool library](https://python.langchain.com/docs/integrations/tools/) with Pydantic AI, you can use the [`tool_from_langchain`][pydantic_ai.ext.langchain.tool_from_langchain] convenience method. Note that Pydantic AI will not validate the arguments in this case -- it's up to the model to provide arguments matching the schema specified by the LangChain tool, and up to the LangChain tool to raise an error if the arguments are invalid. You will need to install the `langchain-community` package and any others required by the tool in question. Here is how you can use the LangChain `DuckDuckGoSearchRun` tool, which requires the `ddgs` package: ```python {test="skip"} from langchain_community.tools import DuckDuckGoSearchRun from pydantic_ai import Agent from pydantic_ai.ext.langchain import tool_from_langchain search = DuckDuckGoSearchRun() search_tool = tool_from_langchain(search) agent = Agent( 'google-gla:gemini-2.0-flash', tools=[search_tool], ) result = agent.run_sync('What is the release date of Elden Ring Nightreign?') # (1)! print(result.output) #> Elden Ring Nightreign is planned to be released on May 30, 2025. ``` 1. The release date of this game is the 30th of May 2025, which is after the knowledge cutoff for Gemini 2.0 (August 2024). If you'd like to use multiple LangChain tools or a LangChain [toolkit](https://python.langchain.com/docs/concepts/tools/#toolkits), you can use the [`LangChainToolset`][pydantic_ai.ext.langchain.LangChainToolset] [toolset](toolsets.md) which takes a list of LangChain tools: ```python {test="skip"} from langchain_community.agent_toolkits import SlackToolkit from pydantic_ai import Agent from pydantic_ai.ext.langchain import LangChainToolset toolkit = SlackToolkit() toolset = LangChainToolset(toolkit.get_tools()) agent = Agent('openai:gpt-4o', toolsets=[toolset]) # ... ``` ## ACI.dev Tools {#aci-tools} If you'd like to use a tool from the [ACI.dev tool library](https://www.aci.dev/tools) with Pydantic AI, you can use the [`tool_from_aci`][pydantic_ai.ext.aci.tool_from_aci] convenience method. Note that Pydantic AI will not validate the arguments in this case -- it's up to the model to provide arguments matching the schema specified by the ACI tool, and up to the ACI tool to raise an error if the arguments are invalid. You will need to install the `aci-sdk` package, set your ACI API key in the `ACI_API_KEY` environment variable, and pass your ACI "linked account owner ID" to the function. Here is how you can use the ACI.dev `TAVILY__SEARCH` tool: ```python {test="skip"} import os from pydantic_ai import Agent from pydantic_ai.ext.aci import tool_from_aci tavily_search = tool_from_aci( 'TAVILY__SEARCH', linked_account_owner_id=os.getenv('LINKED_ACCOUNT_OWNER_ID'), ) agent = Agent( 'google-gla:gemini-2.0-flash', tools=[tavily_search], ) result = agent.run_sync('What is the release date of Elden Ring Nightreign?') # (1)! print(result.output) #> Elden Ring Nightreign is planned to be released on May 30, 2025. ``` 1. The release date of this game is the 30th of May 2025, which is after the knowledge cutoff for Gemini 2.0 (August 2024). If you'd like to use multiple ACI.dev tools, you can use the [`ACIToolset`][pydantic_ai.ext.aci.ACIToolset] [toolset](toolsets.md) which takes a list of ACI tool names as well as the `linked_account_owner_id`: ```python {test="skip"} import os from pydantic_ai import Agent from pydantic_ai.ext.aci import ACIToolset toolset = ACIToolset( [ 'OPEN_WEATHER_MAP__CURRENT_WEATHER', 'OPEN_WEATHER_MAP__FORECAST', ], linked_account_owner_id=os.getenv('LINKED_ACCOUNT_OWNER_ID'), ) agent = Agent('openai:gpt-4o', toolsets=[toolset]) ``` ## See Also - [Function Tools](tools.md) - Basic tool concepts and registration - [Toolsets](toolsets.md) - Managing collections of tools - [MCP Client](mcp/client.md) - Using MCP servers with Pydantic AI - [LangChain Toolsets](toolsets.md#langchain-tools) - Using LangChain toolsets - [ACI.dev Toolsets](toolsets.md#aci-tools) - Using ACI.dev toolsets

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pydantic/pydantic-ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server