pydantic-mcp

pydantic-mcp

By rectalogic GitHub

Model Context Protocol tool calling support for Pydantic AI

Overview

what is pydantic-mcp?

Pydantic-mcp is a tool that provides Model Context Protocol (MCP) support for Pydantic AI, enabling seamless integration and tool calling capabilities.

how to use pydantic-mcp?

To use pydantic-mcp, create an mcp.ClientSession and call tools = await mcptools(session) to retrieve a list of supported pydantic_ai.Tool instances.

key features of pydantic-mcp?

  • Integration with Model Context Protocol for Pydantic AI.
  • Easy setup with mcp.ClientSession.
  • Access to a variety of tools through MCP.

use cases of pydantic-mcp?

  1. Automating interactions with Pydantic AI tools.
  2. Enhancing data validation and parsing in Python applications.
  3. Facilitating complex data workflows using MCP.

FAQ from pydantic-mcp?

  • What is the purpose of pydantic-mcp?

It provides support for Model Context Protocol tool calling in Pydantic AI applications.

  • Is pydantic-mcp free to use?

Yes! It is open-source and available under the MIT license.

  • What programming language is pydantic-mcp written in?

Pydantic-mcp is written in Python.

Content

pydantic-mcp

PydanticAI now includes support for MCP servers, use that instead

PyPI - Version

Model Context Protocol tool calling support for Pydantic AI.

Just create an mcp.ClientSession and call tools = await mcptools(session) to get a list of pydantic_ai.Tool instances for the supported tools.

Example:

https://github.com/rectalogic/pydantic-mcp/blob/98c4e9abf31837cb48ebeb3eae6cb55b16c841e8/tests/demo.py#L15-L25

Demo

You can run the demo against Groq llama-3.1-8b-instant:

$ export GROQ_API_KEY=xxx
$ uv run tests/demo.py "Read and summarize the file ./LICENSE"
Secure MCP Filesystem Server running on stdio
Allowed directories: [ '/users/aw/projects/rectalogic/pydantic-mcp' ]
The file ./LICENSE is a MIT License agreement. It states that the software is provided "as is" without warranty and that the authors and copyright holders are not liable for any claims, damages, or other liability arising from the software or its use.
No tools information available.
No content found.