# mcpx-py

> MCP Client

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

## Overview

- **Category:** AI
- **Language:** Python
- **Stars:** 25
- **Forks:** 0
- **Owner:** dylibso
- **GitHub:** https://github.com/dylibso/mcpx-py
- **Homepage:** https://docs.mcp.run
- **Created:** 2024-12-04T22:21:56+00:00
- **Updated:** 2025-03-28T14:06:58+00:00
- **Source:** https://model-context-protocol.com/clients/python-llm-client-mcp-run-tools

## Setup

## Setup

1.  Get an mcp.run session ID by running: `npx --yes -p @dylibso/mcpx gen-session --write` to generate a new session and write the session ID to a configuration file.
2.  Alternatively, run `npx --yes -p @dylibso/mcpx gen-session` to output the session ID to the console.
3.  Set the `MPC_RUN_SESSION_ID` environment variable with the session ID obtained from the previous step.
4.  For Claude, sign up for an Anthropic API account, get your API key, and set the environment variable: `ANTHROPIC_API_KEY=your_key_here`.
5.  For OpenAI, create an OpenAI account, generate an API key, and set the environment variable: `OPENAI_API_KEY=your_key_here`.
6.  For Gemini, create a Gemini account, generate an API key, and set the environment variable: `GEMINI_API_KEY=your_key_here`.
7.  For Ollama, install Ollama, pull your desired model: `ollama pull llama3.2`, no API key needed.
8.  For Llamafile, download a Llamafile model, make the file executable: `chmod +x your-model.llamafile`, run in JSON API mode: `./your-model.llamafile --json-api --host 127.0.0.1 --port 8080`, and use with the OpenAI provider pointing to `http://localhost:8080`.

## Tools

## Available Tools

1.  AI Provider Support (Supports all models supported by PydanticAI).
2.  Chat with an LLM (Allows interacting with LLMs through the `mcpx-client chat` command).
3.  List tools (Lists available tools using the `mcpx-client list` command).
4.  Call a tool (Calls a specific tool with provided arguments using the `mcpx-client tool` command).

