python-mcp-bootstrap
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.
Why this is public
This helper runs before an app's dependencies exist, which means it executes
during someone else's setup. A tool in that position should be inspectable
rather than trusted on faith: the source is MIT-licensed, the PyPI wheel and
sdist are the same code published from this repository, and releases from
v0.1.2 onward are checksummed, signed and attested (see
release verification).
It makes no network calls of its own, has no telemetry, and has no runtime
dependency on the MCP SDK. After you pass --install-python, provisioning runs
uv to download the pinned interpreter and install the app's dependencies from
the package index you configured.
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
- Looks for Python 3.14 or newer.
- Looks for a working
.venvin the project. - If the Python or the app environment is missing or incomplete, prints a
JSON report with a
cardand anextcommand. Nothing is downloaded. - If you agree, the wrapper re-runs with
--install-python, which installs what is missing inside the project. - 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. Ifuvis 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
PyPI installs require Python 3.14+. On Python 3.12 or 3.13 the package cannot be
pip-installed; vendoring core.py is the supported path there (see
Vendoring) — core.py is deliberately kept to 3.12 syntax and
stdlib only for exactly that case.
GitHub releases from v0.1.2 onward attach the wheel, the sdist,
SHA256SUMS, Sigstore signature bundles (.sigstore.json), and a signed
build-provenance attestation to the
releases page. All are built from the same tagged tree, so
their digests match. v0.1.0 predates the attestation step: it has
SHA256SUMS and the .sigstore.json signatures, but no
provenance.intoto.jsonl.
Version history as users see it on PyPI:
v0.1.1 was tagged but never published. v0.1.3 exists on GitHub only: PyPI
permanently reserves the filenames of a deleted release, and an earlier
iteration of this repository had published and removed that version. v0.1.4
was skipped for the same filename reason. 0.1.5 is the first installable
release after 0.1.2, and pip install python-mcp-bootstrap resolves to the
newest release.
Verifying releases
To verify a download:
sha256sum -c SHA256SUMS
gh attestation verify python_mcp_bootstrap-<version>-py3-none-any.whl \
--repo 4zhmv6zvj2-afk/python-mcp-bootstrap # releases from v0.1.2 onward
gh attestation verify checks the signed provenance record: which repository,
commit, workflow and builder produced the file. The .sigstore.json bundles
carry the matching keyless signatures for every release that has them; they can
also be checked manually with cosign verify-blob, while gh attestation verify
is the automated provenance path used by the release workflow.
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.
The vendoring tool (scripts/vendor.py) ships in the source tree, not in the
wheel: vendoring requires a source checkout. A PyPI install provides the
contract and the diagnostic CLI, not the vendor command.
- Contract: docs/contract.md
- Integration details: docs/integration.md
- Example first run: examples/first_run.py
- Changelog: CHANGELOG.md
- Contributing and release checks: CONTRIBUTING.md
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 --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 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 macOS 15 job (.github/workflows/macos.yml) runs the same suite on pushes
to main, on tags, and weekly, but not on pull requests: GitHub's macOS arm64
pool is capacity-constrained and must not gate merges.
License
MIT. See LICENSE.
Metadata
Release files for python-mcp-bootstrap 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_mcp_bootstrap-0.1.6.tar.gz | 73.6 kB | With provenance | Details for python_mcp_bootstrap-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_mcp_bootstrap-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for python_mcp_bootstrap-0.1.6-py3-none-any.whl |
Total release size: 90.6 kB
Release files / python_mcp_bootstrap-0.1.6.tar.gz
| Download URL | python_mcp_bootstrap-0.1.6.tar.gz |
|---|---|
| Size | 73.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47d2919cfae91311099abd6646ce3a7f6fce0763ba009fa6bdccf3011e556634
|
|
BLAKE2b-256 checksum How to use checksums |
7a881eeb571db22843fd80072de02b6e65cd9a1aa7fdb2f46c9146d1acc0f752
|
| 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 logRelease files / python_mcp_bootstrap-0.1.6-py3-none-any.whl
| Download URL | python_mcp_bootstrap-0.1.6-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c80d50cc450eb3109ea5cc4ceab54d5c719728af01b3fedf5f7fbf511d949e8d
|
|
BLAKE2b-256 checksum How to use checksums |
e97d618debd50d8a384df330c2d477c280d105961301cb1f30b9908f80d16603
|
| 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 logSecurity for python-mcp-bootstrap 0.1.6
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.
Attestation for python_mcp_bootstrap-0.1.6.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 logA 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.