Commit Graph

10 Commits

Author SHA1 Message Date
88c16c840b feat: Add Docker infrastructure with Caddy and startup scripts (#25, #26)
Issue #25 - Docker multi-service infrastructure:
- Create docker/Dockerfile with multi-stage build, git support, port 8080
- Create docker/docker-compose.yml with app + Caddy services
- Create docker/Caddyfile for HTTPS termination and reverse proxy
- Create docker/.env.example with configuration template

Issue #26 - Startup scripts and tests:
- Create scripts/start.sh for production startup with env validation
- Create scripts/healthcheck.sh for Docker health checks
- Add health endpoint tests to test_mcp_endpoints.py
- Fix middleware order (HealthCheckBypass must wrap BearerAuth)
- Fix pyproject.toml testpaths to use 'tests' directory
- Update test_config.py for new defaults (0.0.0.0:8080)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 21:11:29 -05:00
809eef132a feat: add marketplace dependency and update project config
- Add gitea-mcp-server git dependency from marketplace
- Update version to 0.2.0
- Update entry point to server_http:main
- Add MCP and Caddy environment variables to .env.example
- Update uvicorn and starlette versions
- Add pyjwt for authentication
- Regenerate requirements.txt with all dependencies

Closes #22

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 18:05:07 -05:00
5075139841 refactor: Rename package to gitea_mcp_remote and update configuration
Issue #19 - Foundation for Sprint 01: Core Architecture Correction

Changes:
- Renamed package directory: gitea_http_wrapper -> gitea_mcp_remote
- Updated config/settings.py:
  - Made gitea_repo optional (allow None)
  - Added mcp_auth_mode field (default: "optional")
  - Changed HTTP defaults: 0.0.0.0:8080 (was 127.0.0.1:8000)
  - Removed get_gitea_mcp_env() method (no longer needed)
- Updated all import paths throughout codebase
- Updated filtering/filter.py: Changed ValueError to warning when both
  enabled_tools and disabled_tools are specified
- Updated test files with new import paths
- Updated test_filtering.py to test warning instead of ValueError
- Updated pyproject.toml, pytest.ini, and README.md references

All modules preserved - only import paths and configuration updated.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 17:59:57 -05:00
c9961293d9 chore: release version 1.0.0
- Add CHANGELOG.md documenting complete architectural rebuild
- Bump version to 1.0.0 (breaking changes from wrapper pattern)
- Complete Sprint 02: Corrective Rebuild

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 16:55:08 -05:00
4f43109797 fix: resolve test failures and remove unavailable dependency
- Remove gitea-mcp-server from dependencies (not yet on PyPI)
- Add starlette to dependencies (needed for middleware)
- Fix HealthCheckBypassMiddleware to actually bypass auth via request.state flag
- Fix test_required_fields to not require gitea_repo (optional for PMO mode)
- Update pytest testpaths to correct location

All 30 tests now pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 16:35:57 -05:00
1c63210f1d Create test suite for wrapper functionality
This commit implements a comprehensive test suite for the HTTP wrapper components.

Test coverage:
- test_config.py: Configuration loader and validation tests
  - Required field validation
  - URL validation and formatting
  - Port range validation
  - Tool list parsing (enabled/disabled)
  - Environment variable generation
  - .env file loading

- test_filtering.py: Tool filtering tests
  - Passthrough mode (no filtering)
  - Whitelist mode (enabled_tools)
  - Blacklist mode (disabled_tools)
  - Tool list filtering
  - MCP response filtering
  - Edge cases (empty lists, missing names)

- test_middleware.py: HTTP authentication tests
  - BearerAuthMiddleware with/without token
  - Valid/invalid token handling
  - Missing/malformed Authorization headers
  - HTTP status codes (401, 403)
  - HealthCheckBypassMiddleware
  - Custom health check paths
  - Middleware ordering

Test infrastructure:
- conftest.py: Shared fixtures for common test data
- pytest.ini: Test configuration and markers
- Updated dev dependencies with test frameworks

Test execution:
- Run all tests: pytest
- Run with coverage: pytest --cov=gitea_http_wrapper
- Run specific test: pytest src/gitea_http_wrapper/tests/test_config.py

This test suite validates all wrapper components except the main server (which would require integration tests with a real Gitea MCP server).

Closes #17

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 16:11:39 -05:00
0e0c34f735 Create correct directory structure and dependencies
This commit establishes the proper architecture for an HTTP transport wrapper around the official Gitea MCP server, replacing the incorrect standalone implementation.

New structure:
- src/gitea_http_wrapper/ (main package)
  - config/ (configuration loader)
  - middleware/ (HTTP auth middleware)
  - filtering/ (tool filtering for Claude Desktop)
  - tests/ (wrapper test suite)

Updated dependencies:
- mcp>=0.9.0 (MCP SDK for HTTP transport)
- uvicorn>=0.27.0 (ASGI server)
- pydantic>=2.0.0 (config validation)
- pydantic-settings>=2.0.0 (settings management)
- gitea-mcp-server>=0.1.0 (official Gitea MCP to wrap)

Created requirements.txt for Docker deployment convenience.

This architecture correctly separates concerns:
1. Official Gitea MCP server handles Gitea API operations
2. HTTP wrapper provides transport, auth, and filtering

Closes #10

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 16:07:06 -05:00
2230bceb51 test: add comprehensive test suite - Closes #7
Added comprehensive test coverage for all tool modules:

Test Files Created:
- tests/conftest.py: Shared fixtures for all tests
- tests/test_issues.py: Complete coverage for issue tools
- tests/test_labels.py: Complete coverage for label tools
- tests/test_milestones.py: Complete coverage for milestone tools

Test Coverage:
- Tool definition validation (schema structure)
- Handler function routing
- Successful API response formatting
- Error handling (GiteaClientError)
- Required parameter validation
- Optional parameter handling
- Mock Gitea API responses

Configuration Updates:
- Added pytest-cov>=4.0.0 to dev dependencies
- Created run_tests.sh script for easy test execution

All tests use pytest-asyncio for async functions and mock the
GiteaClient to avoid real API calls. Tests validate tool schemas,
handler routing, response formatting, and error handling.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 15:30:09 -05:00
1e0d896d87 feat: implement MCP server core and authentication
Implemented MCP server core infrastructure with authentication and HTTP client:

- Created auth.py for API token management
  - Loads GITEA_API_URL and GITEA_API_TOKEN from environment
  - Uses python-dotenv for .env file support
  - Validates required configuration on initialization
  - Provides authentication headers for API requests

- Created client.py with base HTTP client
  - GiteaClient class using httpx AsyncClient
  - Async HTTP methods: get(), post(), patch(), delete()
  - Comprehensive error handling for HTTP status codes
  - Custom exception hierarchy for different error types
  - Configurable timeout (default 30s)

- Updated server.py with MCP server setup
  - Initialized MCP server with StdioServerTransport
  - Integrated AuthConfig and GiteaClient
  - Registered placeholder tool handlers (list_repositories, create_issue, create_pull_request)
  - Added CLI with --help and --version options
  - Proper error handling for configuration failures

- Updated pyproject.toml
  - Added console script entry point: gitea-mcp

- Created comprehensive unit tests
  - test_auth.py: Tests for AuthConfig validation and headers
  - test_client.py: Tests for GiteaClient initialization and error handling

All acceptance criteria met:
- MCP server initializes with StdioServerTransport
- Authentication loads from environment variables
- Base HTTP client with auth headers implemented
- Error handling for API connection failures
- Server reports available tools (placeholders for future issues)

Closes #2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 15:05:25 -05:00
95ed3d81cf feat: initialize Python project structure
- Create pyproject.toml with project metadata
- Add dependencies: mcp, httpx, python-dotenv
- Set up src/gitea_mcp package structure with __init__.py files
- Create placeholder server.py for MCP server implementation
- Add tools subdirectory for future tool implementations
- Create tests directory structure
- Update .gitignore with comprehensive Python exclusions
- Add README.md with project overview

Uses modern src-layout with pyproject.toml (no setup.py).
Project is ready for MCP server implementation.

Closes #1

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 14:56:34 -05:00