This guide explains how to deploy code-trajectory-mcp to TestPyPI (for testing) and PyPI (for production).
- Go to https://test.pypi.org/account/register/
- Create an account
- Verify your email
- Log in to TestPyPI
- Go to Account Settings
- Scroll to "API tokens"
- Click "Add API token"
- Set name (e.g., "code-trajectory-upload")
- Set scope to "Entire account" (or specific project if you've created it)
- Copy the generated token (starts with
pypi-) - Important: Save this token securely - you won't see it again!
Create or edit ~/.pypirc (Windows: %USERPROFILE%\.pypirc):
[distutils]
index-servers =
pypi
testpypi
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-YOUR_TOKEN_HERE
[pypi]
repository = https://pypi.org/legacy/
username = __token__
password = pypi-YOUR_TOKEN_HERE_WHEN_READYNote: Replace pypi-YOUR_TOKEN_HERE with your actual token.
.\deploy-testpypi.ps1This script will:
- Clean old build artifacts
- Build the package
- Upload to TestPyPI
- Test installation from TestPyPI
# 1. Clean old builds
Remove-Item -Recurse -Force dist -ErrorAction SilentlyContinue
# 2. Build the package
uv build
# 3. Install twine (if not already installed)
uv pip install twine
# 4. Upload to TestPyPI
twine upload --repository testpypi dist/*
# You'll be prompted for username and password:
# Username: __token__
# Password: pypi-YOUR_TOKEN_HERE# Using pip
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ code-trajectory
# Using uv
uv pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ code-trajectoryNote: --extra-index-url https://pypi.org/simple/ is needed because dependencies (like mcp, gitpython) are on regular PyPI, not TestPyPI.
# Check version
code-trajectory --version
# Or test with uvx
uvx --from code-trajectory --index-url https://test.pypi.org/simple/ code-trajectory- Create PyPI account at https://pypi.org/account/register/
- Generate API token (same process as TestPyPI)
- Update
~/.pypircwith PyPI credentials
# 1. Clean and build
Remove-Item -Recurse -Force dist -ErrorAction SilentlyContinue
uv build
# 2. Upload to PyPI
twine upload dist/*You can automate deployment with GitHub Actions. Create .github/workflows/publish.yml:
name: Publish to PyPI
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v1
- name: Set up Python
run: uv python install 3.14
- name: Build package
run: uv build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
uv pip install twine
twine upload dist/*Add PYPI_API_TOKEN to your GitHub repository secrets.
If code-trajectory is already taken on PyPI, you'll need to:
- Choose a different name in
pyproject.toml - Rebuild and reupload
PyPI doesn't allow re-uploading the same version. You need to:
- Increment version in
pyproject.toml - Rebuild and reupload
TestPyPI doesn't have all packages. When installing from TestPyPI, always use:
--extra-index-url https://pypi.org/simple/Current version: 0.1.1 (in pyproject.toml)
To update version:
- Edit
pyproject.toml - Update
version = "0.1.2"(or whatever the new version is) - Commit changes
- Create new git tag:
git tag v0.1.2 - Push tag:
git push origin v0.1.2 - Build and deploy
- Package name:
code-trajectory - Import name:
code_trajectory - Entry point:
code-trajectorycommand - TestPyPI URL: https://test.pypi.org/project/code-trajectory/
- PyPI URL: https://pypi.org/project/code-trajectory/ (when published)
# Check what will be included in the package
uv build --outdir dist-test
# Check package contents
tar -tzf dist/code_trajectory-0.1.1.tar.gz
# Validate package before upload
twine check dist/*