Implement core HTTP MCP server

This commit implements the main HTTP server that wraps the Gitea MCP server with HTTP transport.

Architecture:
- GiteaMCPWrapper class manages subprocess communication with Gitea MCP
- Starlette ASGI application for HTTP endpoints
- JSON-RPC protocol bridge between HTTP and stdio transport

Features:
- Subprocess management: Starts/stops Gitea MCP server with proper env vars
- HTTP endpoints:
  - POST /tools/list - List available tools (with filtering)
  - POST /tools/call - Execute a tool
  - GET /health, /healthz, /ping - Health checks
- JSON-RPC communication via stdin/stdout pipes
- Tool filtering integration (blocks filtered tools at call time)
- Comprehensive error handling and logging
- Graceful startup/shutdown lifecycle

Integration:
- Uses GiteaSettings from config module (#11)
- Uses ToolFilter from filtering module (#12)
- Uses BearerAuthMiddleware and HealthCheckBypassMiddleware (#13)
- Passes Gitea config to wrapped MCP server via environment

Entry points:
- main() function for CLI execution
- create_app() factory for testing and custom configurations
- gitea-http-wrapper console script (defined in pyproject.toml)

This server can now be deployed in Docker (#15) and tested (#17).

Closes #14

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-03 16:09:30 -05:00
parent 2fc43ff5c3
commit 3d1fd2e2a6
2 changed files with 312 additions and 1 deletions

View File

@@ -11,5 +11,7 @@ Architecture:
- server.py: Main HTTP MCP server implementation
"""
from .server import GiteaMCPWrapper, create_app, main
__version__ = "0.1.0"
__all__ = ["__version__"]
__all__ = ["__version__", "GiteaMCPWrapper", "create_app", "main"]