Skip to main content

python-mcp-bootstrap

ci

A small setup helper for Python apps that use MCP.

MCP (Model Context Protocol) is a way for AI assistants to use tools and data. Before one of those apps starts, this helper makes sure it runs on a supported version of Python. If your computer does not have one, it explains what is missing and asks before downloading anything. It never changes the Python that is already installed.

This is a bootstrap for MCP applications, not an MCP implementation. It has no runtime dependency on the MCP SDK and never imports one.

Most people do not need to run this directly. The app's setup script uses it. If you are a developer adding it to an app, jump to For developers.

Do I need this?

  • If an app's setup tells you to run python first_run.py, that script uses this helper. Follow the app's instructions.
  • If you are building or packaging an MCP app and need a first-run Python check, use this library.
  • If you just want to run an app that is already set up, no.

What it does

  1. Looks for Python 3.14 or newer.
  2. Looks for a working .venv in the project.
  3. If the Python or the app environment is missing or incomplete, prints a JSON report with a card and a next command. Nothing is downloaded.
  4. If you agree, the wrapper re-runs with --install-python, which installs what is missing inside the project.
  5. Continues setup with that Python.

It can also check a Python you name:

python first_run.py --python /path/to/python

What it will not do

  • It will not download Python without --install-python.
  • It will not change your system Python or system packages.
  • It will not delete an existing .venv; a wrong one is moved aside.
  • It will not run curl | sh. If uv is missing, it prints a tip with the official uv installation page and stops. It never runs that tip.
  • It will not run commands through a shell.
  • It masks credential-shaped values in its reports and captured output.

For developers

This repository is a library, not the app. The command-line tool is a diagnostic:

python -m python_mcp_bootstrap --check
python -m python_mcp_bootstrap --version

Install from PyPI:

python -m pip install python-mcp-bootstrap

Each release also attaches the wheel, the sdist, and SHA256SUMS to the releases page. Both are built from the same tagged tree, so their digests match.

Use BootstrapSpec and bootstrap() from an app's first-run wrapper:

import sys
from pathlib import Path

from python_mcp_bootstrap import BootstrapSpec, bootstrap


def continue_setup(args: list[str]) -> int:
    # The rest of setup goes here.
    del args
    return 0


root = Path(__file__).resolve().parent
spec = BootstrapSpec(
    app="example-mcp",
    entrypoint="first_run.py",
    env_var="EXAMPLE_MCP_INTERPRETER",
    install_args=("-e", "."),
    verify_import="example_mcp",
    package_main=continue_setup,
)
raise SystemExit(bootstrap(sys.argv[1:], root, spec))

package_main is the function bootstrap() calls when the current Python is already suitable. Pass it: an entry point that calls bootstrap() unconditionally needs somewhere to continue.

The first pass may hand off once, and it records the chosen interpreter in spec.env_var. A later pass that reaches bootstrap() with that variable already set and no continuation gets a missing_continuation report (exit 7) instead of another exec, so the re-exec loop is gone. A wrapper that branches on spec.env_var and skips bootstrap() after the handoff keeps working, which is what the variable is for.

bootstrap() checks --python, the current interpreter, and an existing .venv, in that order. It only offers to install the pinned Python after --install-python. An existing .venv is also checked with verify_import; the check runs isolated (-I -P), so only that venv's installed packages count. If the app or MCP module is missing, the repair card asks for --install-python before running the installer.

install_args are consumer-controlled. Path-like entries are rejected when the spec is built if they are absolute, Windows-rooted, or contain .., including attached short-option values (-t/tmp/x). Venv-redirecting flags (--target, --prefix, --root, --python and their short forms) are rejected. Non-path flags such as --index-url pass through; credentials in reports are masked.

The core is one stdlib-only file, core.py. It must stay importable on Python 3.12 because it runs before the app's dependencies are installed; CI runs the suite on 3.12 as well as on the supported 3.14 and 3.15 interpreters.

Vendoring

Consumers copy core.py and a VENDOR.json manifest instead of taking a runtime dependency:

python scripts/vendor.py \
  --target /path/to/consumer \
  --dest src/example/_vendor/python_mcp_bootstrap.py

Use --check to verify a pinned copy. The example app vendors core.py into examples/_vendor/ and CI runs the same vendor.py --check sequence.

Development

Requires Python 3.14+. The development pin is 3.15.2.

python3 -m venv .venv
. .venv/bin/activate
python -m pip install -e '.[dev]'
python -m pytest --cov=python_mcp_bootstrap --cov-fail-under=90
python -m ruff format --check
python -m ruff check
python -m mypy
python -m build

CI targets Python 3.14.10 and 3.15.2 on Ubuntu, macOS, and Windows, plus a 3.12 compatibility job, a wheel/release gate, and the vendored example first run. main is protected: the release gate, the 3.12 job, and the vendored example run are required before a merge, and force-pushes and deletions are blocked. The OS matrix runs alongside them, so read the run rather than the badge — a queued cell is not green.

License

MIT. See LICENSE.

Metadata

Release files for python-mcp-bootstrap 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-mcp-bootstrap 0.1.0
File Size Uploaded Provenance Actions
python_mcp_bootstrap-0.1.0.tar.gz 34.8 kB With provenance Details for python_mcp_bootstrap-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-mcp-bootstrap 0.1.0
File Interpreter ABI Platform Actions
python_mcp_bootstrap-0.1.0-py3-none-any.whl Python 3 none any Details for python_mcp_bootstrap-0.1.0-py3-none-any.whl

Total release size: 49.5 kB

Release files / python_mcp_bootstrap-0.1.0.tar.gz

Download URL python_mcp_bootstrap-0.1.0.tar.gz
Size 34.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4c9100dc366bb96f83766c61f91675ad146ece182c416d64fe96e19e650e43ac
BLAKE2b-256 checksum
How to use checksums
33420b6e975225b2115f8be018e606c59990538dce91f934db5eb770fd118a80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / python_mcp_bootstrap-0.1.0-py3-none-any.whl

Download URL python_mcp_bootstrap-0.1.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7cf83838bdd0820cd84c4a401d8af145d64e16ebb2c506efe9f0562ba6d4e207
BLAKE2b-256 checksum
How to use checksums
33bf04dfc3db5f809699c6794603fd17bcafa49c6a9fe55a28be79528a0ccb8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for python-mcp-bootstrap 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for python_mcp_bootstrap-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page