Skip to main content
RapidDev - Software Development Agency
mcp-tutorial

How to use uvx to run Python MCP servers

uvx is Python's equivalent of npx — it runs Python-based MCP servers without requiring manual pip install or virtual environment setup. Install uv first with curl -LsSf https://astral.sh/uv/install.sh | sh, then configure your MCP host to use uvx as the command. uvx automatically creates isolated environments and resolves dependencies, making Python MCP servers as easy to run as npm-based ones.

What you'll learn

  • How to install uv and use uvx to run Python MCP servers
  • How to configure uvx-based servers in Claude Desktop and Cursor
  • How to pass environment variables and arguments to Python MCP servers
  • How to troubleshoot common uvx issues
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner6 min read10-15 minPython 3.10+, uv 0.4+, all MCP hostsMarch 2026RapidDev Engineering Team
TL;DR

uvx is Python's equivalent of npx — it runs Python-based MCP servers without requiring manual pip install or virtual environment setup. Install uv first with curl -LsSf https://astral.sh/uv/install.sh | sh, then configure your MCP host to use uvx as the command. uvx automatically creates isolated environments and resolves dependencies, making Python MCP servers as easy to run as npm-based ones.

Running Python MCP Servers with uvx

Python MCP servers are typically distributed as PyPI packages and can be run with uvx, the tool runner included with uv. uvx automatically handles dependency resolution, virtual environment creation, and execution in a single command — no pip install or virtualenv setup needed. This tutorial walks you through installing uv, configuring uvx-based MCP servers, and troubleshooting common issues.

Prerequisites

  • Python 3.10+ installed on your system
  • An MCP host like Claude Desktop or Cursor installed
  • Terminal access for installing uv
  • Basic familiarity with your MCP host's configuration file

Step-by-step guide

1

Install uv on your system

uv is a fast Python package installer and runner developed by Astral (the team behind Ruff). Install it using the official install script. On macOS and Linux, use the curl command below. On Windows, use the PowerShell command. After installation, restart your terminal so the uvx command is available on your PATH.

typescript
1# macOS / Linux
2curl -LsSf https://astral.sh/uv/install.sh | sh
3
4# Windows (PowerShell)
5powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
6
7# Verify installation
8uvx --version

Expected result: uvx --version outputs a version number, confirming uv is installed correctly.

2

Run a Python MCP server with uvx

uvx runs a Python package as a command-line tool in an isolated environment. It downloads the package, installs its dependencies in a temporary virtual environment, and executes it — all in one step. Test this in your terminal first before adding it to your MCP host config. The command syntax is uvx <package-name> followed by any arguments the server needs.

typescript
1# Run the git MCP server
2uvx mcp-server-git --repository /path/to/your/repo
3
4# Run the fetch MCP server
5uvx mcp-server-fetch
6
7# Run a specific version
8uvx mcp-server-git@0.6.0 --repository /path/to/your/repo

Expected result: The MCP server starts and outputs protocol messages to stdout (which you will see as JSON-RPC text in the terminal).

3

Configure uvx-based servers in your MCP host

Add the uvx-based server to your MCP host configuration. Use uvx as the command and put the package name and any arguments in the args array. Add environment variables in the env block just like you would for npx-based servers. The configuration is identical in structure to npx servers — only the command changes.

typescript
1// claude_desktop_config.json
2{
3 "mcpServers": {
4 "git": {
5 "command": "uvx",
6 "args": ["mcp-server-git", "--repository", "/Users/yourname/projects/my-repo"]
7 },
8 "fetch": {
9 "command": "uvx",
10 "args": ["mcp-server-fetch"]
11 }
12 }
13}

Expected result: Your MCP host starts the Python server using uvx and the server's tools appear in the host interface.

4

Fix PATH issues for GUI-launched hosts

Just like npx, GUI applications may not find uvx because they do not inherit your shell's PATH. Use the absolute path to uvx in your configuration. Run which uvx in your terminal to find it. On macOS with the official installer, it is typically at ~/.cargo/bin/uvx or ~/.local/bin/uvx. On Homebrew installations, it is /opt/homebrew/bin/uvx.

typescript
1# Find absolute path
2which uvx
3# Example: /Users/yourname/.local/bin/uvx
4
5# Use absolute path in config
6{
7 "mcpServers": {
8 "git": {
9 "command": "/Users/yourname/.local/bin/uvx",
10 "args": ["mcp-server-git", "--repository", "/path/to/repo"]
11 }
12 }
13}

Expected result: The MCP server starts correctly using the absolute path to uvx.

5

Add environment variables for Python servers

Many Python MCP servers need API keys or configuration values passed as environment variables. Add them in the env block of your server config, just like npx-based servers. Python servers access these via os.environ. A common pattern is PYTHONUNBUFFERED=1 which forces Python to flush output immediately — important for stdio transport where buffered output can cause communication delays. If you need help configuring complex Python MCP server deployments, the RapidDev engineering team can assist.

typescript
1{
2 "mcpServers": {
3 "custom-python-server": {
4 "command": "uvx",
5 "args": ["my-mcp-server"],
6 "env": {
7 "API_KEY": "your-api-key-here",
8 "PYTHONUNBUFFERED": "1"
9 }
10 }
11 }
12}

Expected result: The Python MCP server receives the environment variables and uses them for configuration and authentication.

Complete working example

claude_desktop_config.json
1{
2 "mcpServers": {
3 "git": {
4 "command": "uvx",
5 "args": [
6 "mcp-server-git",
7 "--repository",
8 "/Users/yourname/projects/my-repo"
9 ]
10 },
11 "fetch": {
12 "command": "uvx",
13 "args": ["mcp-server-fetch"],
14 "env": {
15 "PYTHONUNBUFFERED": "1"
16 }
17 },
18 "sqlite": {
19 "command": "uvx",
20 "args": [
21 "mcp-server-sqlite",
22 "--db-path",
23 "/Users/yourname/data/mydb.sqlite"
24 ]
25 },
26 "custom-api": {
27 "command": "uvx",
28 "args": ["my-custom-mcp-server"],
29 "env": {
30 "API_KEY": "sk-your-key",
31 "BASE_URL": "https://api.example.com",
32 "PYTHONUNBUFFERED": "1"
33 }
34 }
35 }
36}

Common mistakes when using uvx to run Python MCP servers

Why it's a problem: Not installing uv before trying to use uvx

How to avoid: uvx is part of the uv package. Install uv first using curl -LsSf https://astral.sh/uv/install.sh | sh, then restart your terminal.

Why it's a problem: Using pip install instead of uvx for MCP servers

How to avoid: uvx handles everything automatically in an isolated environment. You do not need to create virtualenvs or pip install anything. Just use uvx <package-name>.

Why it's a problem: Not setting PYTHONUNBUFFERED=1 for stdio transport

How to avoid: Python buffers stdout by default, which can delay MCP protocol messages. Add PYTHONUNBUFFERED=1 to the env block to force immediate output flushing.

Why it's a problem: Using a relative path to uvx in the MCP config

How to avoid: GUI applications may not find uvx via PATH. Use the absolute path from which uvx in your config.

Best practices

  • Always set PYTHONUNBUFFERED=1 in the env block for Python MCP servers using stdio transport
  • Use absolute paths to uvx in MCP host configs to avoid PATH resolution issues
  • Test the uvx command in your terminal before adding it to the host config
  • Pin package versions for production stability: uvx mcp-server-git@0.6.0
  • Keep uv updated with uv self update to get the latest package resolution improvements
  • Use the env block for API keys — never modify the Python server code to hardcode secrets

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I want to run a Python-based MCP server using uvx. The package is [package-name] and it needs these arguments: [args]. I am on [macOS/Windows/Linux]. Show me the complete Claude Desktop configuration including environment variables.

MCP Prompt

Help me configure a Python MCP server in my Claude Desktop config. I want to use uvx to run [package-name] with these environment variables: [list]. Show me the configuration with absolute paths for macOS.

Frequently asked questions

What is the difference between uvx and npx?

uvx is for Python packages (PyPI), npx is for JavaScript packages (npm). They serve the same purpose — running packages without installing them globally. Use uvx for Python MCP servers and npx for Node.js MCP servers.

Does uvx install packages permanently?

No, uvx creates temporary isolated environments. Packages are cached locally for faster subsequent runs but are not installed globally or into any project.

Can I use pip instead of uvx?

Technically yes, but uvx is strongly recommended because it handles environment isolation automatically. Using pip can lead to dependency conflicts with other Python packages on your system.

How do I update a Python MCP server installed via uvx?

uvx automatically uses the latest version by default. To force a fresh download, run uvx --reinstall <package-name>. To pin a version, use uvx <package-name>@<version>.

Does uvx work on Windows?

Yes, install uv using the PowerShell command: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex". Unlike npx on Windows, uvx typically works without a cmd wrapper.

Can I run locally developed Python MCP servers with uvx?

For local development, use uv run instead of uvx. Navigate to your server directory and run uv run python server.py. uvx is designed for published packages, while uv run works with local code.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.