This guide walks you through publishing the Method CRM MCP Server to PyPI.
-
PyPI Account
- Create account at https://pypi.org/account/register/
- Verify your email address
- Enable 2FA (highly recommended)
-
TestPyPI Account (for testing)
- Create account at https://test.pypi.org/account/register/
- Verify your email address
-
API Tokens
- Generate PyPI API token at https://pypi.org/manage/account/token/
- Generate TestPyPI token at https://test.pypi.org/manage/account/token/
- Save tokens securely (they're shown only once!)
-
Install Build Tools
pip install --upgrade build twine
Edit pyproject.toml and update version:
version = "1.0.0" # Update for each releaseEdit pyproject.toml and replace placeholder email:
authors = [
{name = "Avinash Sangle", email = "your-real-email@example.com"}
]
maintainers = [
{name = "Avinash Sangle", email = "your-real-email@example.com"}
]# Check that all required files exist
ls -la README.md LICENSE pyproject.toml MANIFEST.in
# Check source code structure
tree src/method_mcp# Remove old build artifacts
rm -rf build/ dist/ *.egg-info src/*.egg-info# Build source distribution and wheel
python -m build
# Verify build succeeded
ls -lh dist/
# Should see:
# - method-crm-mcp-1.0.0.tar.gz (source distribution)
# - method_crm_mcp-1.0.0-py3-none-any.whl (wheel)# Inspect wheel contents
unzip -l dist/method_crm_mcp-1.0.0-py3-none-any.whl
# Inspect source distribution
tar -tzf dist/method-crm-mcp-1.0.0.tar.gz# Check package for errors
twine check dist/*
# Should output: "Checking dist/... PASSED"Create ~/.pypirc:
[distutils]
index-servers =
pypi
testpypi
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-AgEIcH...your-testpypi-token-here...
[pypi]
repository = https://upload.pypi.org/legacy/
username = __token__
password = pypi-AgEIcH...your-pypi-token-here...Security Note: Set proper permissions:
chmod 600 ~/.pypirc# Upload to TestPyPI
twine upload --repository testpypi dist/*
# If successful, you'll see:
# Uploading distributions to https://test.pypi.org/legacy/
# Uploading method_crm_mcp-1.0.0-py3-none-any.whl
# Uploading method-crm-mcp-1.0.0.tar.gz# Create clean virtual environment
python -m venv test_env
source test_env/bin/activate # On Windows: test_env\Scripts\activate
# Install from TestPyPI
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
method-crm-mcp
# Test import
python -c "from method_mcp.server import mcp; print('✓ Package works!')"
# Test CLI
python -m method_mcp.server --help
# Cleanup
deactivate
rm -rf test_envVisit: https://test.pypi.org/project/method-crm-mcp/
- Delete the release
- Reuse the version number
- Modify the uploaded files
# Verify version in pyproject.toml
grep "version" pyproject.toml
# Verify all tests pass
pytest
# Verify README renders correctly
python -m readme_renderer README.md
# Check for security issues (optional)
pip install safety
safety check# Upload to production PyPI
twine upload dist/*
# If successful, you'll see:
# Uploading distributions to https://upload.pypi.org/legacy/
# Uploading method_crm_mcp-1.0.0-py3-none-any.whl
# Uploading method-crm-mcp-1.0.0.tar.gz
# View at: https://pypi.org/project/method-crm-mcp/1.0.0/# Create clean environment
python -m venv verify_env
source verify_env/bin/activate
# Install from PyPI
pip install method-crm-mcp
# Verify it works
python -c "from method_mcp.server import mcp; print('✓ Published successfully!')"
# Cleanup
deactivate
rm -rf verify_envVisit: https://pypi.org/project/method-crm-mcp/
# Tag the release
git tag -a v1.0.0 -m "Release v1.0.0 - Published to PyPI"
git push origin v1.0.0Add PyPI installation instructions to GitHub release:
gh release edit v1.0.0 --notes-file - <<EOF
# Installation
\`\`\`bash
pip install method-crm-mcp
\`\`\`
[View on PyPI](https://pypi.org/project/method-crm-mcp/)
[Rest of release notes...]
EOFUpdate README.md installation section:
## Installation
### From PyPI (Recommended)
\`\`\`bash
pip install method-crm-mcp
\`\`\`
### From Source
\`\`\`bash
git clone https://github.com/avisangle/method-crm-mcp.git
cd method-crm-mcp
pip install -e .
\`\`\`- Tweet about the release
- Post in relevant Reddit communities (r/Python, r/programming)
- Share in Discord/Slack communities
- Update MCP servers registry
- Post in Method CRM community forums
You tried to upload a version that already exists. You must:
- Increment version number in
pyproject.toml - Rebuild:
python -m build - Upload again:
twine upload dist/*
Check your ~/.pypirc token or use command line:
twine upload --username __token__ --password pypi-YOUR-TOKEN-HERE dist/*You don't have permissions. Possible causes:
- Wrong API token
- Token doesn't have upload permissions
- Package name already taken by someone else
Choose a different name in pyproject.toml:
name = "method-crm-mcp-avisangle" # Add your usernameFollow SemVer:
- 1.0.0 → 1.0.1: Bug fixes (patch)
- 1.0.0 → 1.1.0: New features (minor)
- 1.0.0 → 2.0.0: Breaking changes (major)
For each new release:
- Update version in
pyproject.toml - Update
CHANGELOG.md(create if needed) - Clean old builds:
rm -rf dist/ - Build:
python -m build - Test on TestPyPI
- Upload to PyPI
- Tag in git:
git tag v1.x.x - Push tag:
git push origin v1.x.x - Create GitHub release
- Never commit
.pypircor API tokens to git - Use API tokens, not passwords
- Enable 2FA on PyPI account
- Rotate tokens periodically (every 6-12 months)
- Use environment variables for CI/CD:
export TWINE_USERNAME=__token__ export TWINE_PASSWORD=pypi-YOUR-TOKEN twine upload dist/*
Create .github/workflows/publish.yml:
name: Publish to PyPI
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*Add PYPI_API_TOKEN to GitHub repository secrets.
- PyPI Documentation: https://packaging.python.org/
- Twine Documentation: https://twine.readthedocs.io/
- Setuptools Documentation: https://setuptools.pypa.io/
- Python Packaging Guide: https://packaging.python.org/tutorials/packaging-projects/
If you encounter issues:
- Check PyPI Help
- Search Python Packaging Discussions
- Open an issue in this repository
Good luck with your PyPI publication! 🚀