mcpx-py is a Python library that enables interaction with various Large Language Models (LLMs) using mcp.run tools, supporting models from PydanticAI, OpenAI, Ollama, and Gemini. mcpx-py is a Python library

16
0

mcpx-py

A Python library for interacting with LLMs using mcp.run tools. It supports various AI providers through PydanticAI.

Features

AI Provider Support

mcpx-py supports all models supported by PydanticAI

Dependencies

  • uv
  • npm
  • ollama (optional)

mcp.run Setup

An mcp.run session ID is required, obtainable via npx --yes -p @dylibso/mcpx gen-session. This can be written to a configuration file or stored in the MPC_RUN_SESSION_ID environment variable.

Python Usage

Installation

Install using uv add mcpx-py or pip install mcpx-py.

Example code

The library offers a Chat class for interacting with LLMs. It supports models like Claude, OpenAI, Ollama, and Gemini. You can send messages and receive responses, with options for structured output using Pydantic BaseModel. Examples are available in the examples/ directory.

Command Line Usage

Installation

Install via uv tool install mcpx-py or from git.

Running

The mcpx-client tool allows chatting with LLMs (mcpx-client chat), listing available tools (mcpx-client list), and calling specific tools (mcpx-client tool eval-js '{"code": "2+2"}').

LLM Configuration

Configuration steps are provided for Claude, OpenAI, Gemini, Ollama, and Llamafile, including API key setup and Ollama model pulling.

Repository

DY
dylibso

dylibso/mcpx-py

Created

December 4, 2024

Updated

March 28, 2025

Language

Python

Category

AI