Implement PyPI Account & Publishing Tools

Add comprehensive PyPI publishing and account management functionality:

Features:
- upload_package_to_pypi: Upload distributions to PyPI/TestPyPI with safety checks
- check_pypi_credentials: Validate API tokens and credentials
- get_pypi_upload_history: View upload history for packages with statistics
- delete_pypi_release: Safe release deletion with dry-run and confirmation
- manage_pypi_maintainers: Add/remove/list package maintainers
- get_pypi_account_info: View account details, quotas, and limits

Implementation:
- Created pypi_query_mcp/tools/publishing.py with all 6 functions
- Added PyPIPublishingClient for authenticated API operations
- Comprehensive error handling with custom exceptions
- Full async/await patterns following existing codebase conventions
- Safety checks for destructive operations (deletion requires confirmation)
- Support for both production PyPI and TestPyPI

Integration:
- Added publishing-specific exceptions to core/exceptions.py
- Updated tools/__init__.py with publishing function imports
- Added 6 MCP server endpoints to server.py with proper error handling
- Created comprehensive tests in tests/test_publishing.py

Production-ready code with proper authentication, validation, and safety measures.
This commit is contained in:
Ryan Malloy 2025-08-16 08:52:03 -06:00
parent e205176ace
commit 9f3fd459b3
5 changed files with 2170 additions and 0 deletions

View file

@ -62,3 +62,24 @@ class SearchError(PyPIError):
def __init__(self, message: str, query: str | None = None):
super().__init__(message)
self.query = query
class PyPIAuthenticationError(PyPIError):
"""Raised when PyPI authentication fails."""
def __init__(self, message: str, status_code: int | None = None):
super().__init__(message, status_code)
class PyPIUploadError(PyPIError):
"""Raised when PyPI upload operations fail."""
def __init__(self, message: str, status_code: int | None = None):
super().__init__(message, status_code)
class PyPIPermissionError(PyPIError):
"""Raised when PyPI permission operations fail."""
def __init__(self, message: str, status_code: int | None = None):
super().__init__(message, status_code)