This document describes how to publish the grafana-loki-mcp package to PyPI.
Make sure you have the following tools installed:
- Python 3.10 or higher
buildandtwinepackagesmakecommand
pip install build twineThere are two ways to update the version:
The project provides convenient make commands to bump the version:
# Bump patch version (0.1.0 -> 0.1.1)
make bump-patch
# Bump minor version (0.1.0 -> 0.2.0)
make bump-minor
# Bump major version (0.1.0 -> 1.0.0)
make bump-majorThese commands will:
- Update the version in
grafana_loki_mcp/__version__.py - Commit the change
- Create a git tag
- Remind you to push the changes and tags
After running one of these commands, push the changes:
git push && git push --tagsThis will trigger the GitHub Actions workflow to automatically build and publish the package to PyPI.
If you prefer to update the version manually:
- Update the version in
grafana_loki_mcp/__version__.py - Commit the changes:
git add grafana_loki_mcp/__version__.py
git commit -m "Bump version to x.y.z"
git tag vx.y.z
git push origin main --tagsBuild the package using make:
make buildThis will create both source distribution ( .tar.gz ) and wheel ( .whl ) files in the dist/ directory.
It's recommended to test the package on TestPyPI before publishing to the main PyPI repository:
make test-publishThen install and test the package from TestPyPI:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ grafana-loki-mcpOnce you've verified that the package works correctly, you can manually upload it to PyPI:
make publishYou'll need to enter your PyPI username and password.
The project is configured to automatically publish to PyPI when a new tag is pushed:
- Update the version using one of the methods above
- Push the tag to GitHub
- The GitHub Actions workflow will build and publish the package to PyPI
For this to work, you need to set up a PyPI API token as a GitHub secret named PYPI_API_TOKEN .
After publishing, verify that the package can be installed from PyPI:
pip install grafana-loki-mcpAfter publishing, you can clean up the build artifacts:
make clean