feat: Remove old server and create MCP base server structure

- Delete old subprocess-based server.py
- Create new server_http.py with base structure for MCP Streamable HTTP protocol
- Update __init__.py to import from server_http
- Health check endpoint in place
- Middleware integration ready for MCP endpoints

Issue #24 will add the actual MCP protocol endpoints.

Closes #23

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-03 18:07:51 -05:00
parent 809eef132a
commit fb8cc08112
3 changed files with 75 additions and 321 deletions

View File

@@ -0,0 +1,69 @@
"""
Gitea MCP Remote — HTTP server with MCP Streamable HTTP protocol.
This module imports tool definitions from the marketplace gitea-mcp-server
package and serves them over HTTP with authentication.
"""
import logging
import uvicorn
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route
from gitea_mcp_remote.config import load_settings
from gitea_mcp_remote.middleware import BearerAuthMiddleware, HealthCheckBypassMiddleware
from gitea_mcp_remote.filtering import ToolFilter
logger = logging.getLogger(__name__)
async def health_check(request):
"""Health check endpoint - bypasses authentication."""
return JSONResponse({"status": "ok"})
def create_app():
"""Create the Starlette application with middleware."""
settings = load_settings()
# Set up tool filtering
tool_filter = ToolFilter(
enabled_tools=settings.enabled_tools_list,
disabled_tools=settings.disabled_tools_list,
)
# Convert to list for marketplace API
tool_names = None # means "all"
if tool_filter.enabled_tools:
tool_names = list(tool_filter.enabled_tools)
# TODO: Issue #24 will add MCP protocol endpoints
# from mcp_server import get_tool_definitions, create_tool_dispatcher, GiteaClient, GiteaConfig
routes = [
Route("/health", health_check, methods=["GET"]),
# MCP endpoints will be added in Issue #24
]
app = Starlette(routes=routes)
# Apply middleware (order matters - health bypass first)
app = HealthCheckBypassMiddleware(app)
if settings.auth_token:
app = BearerAuthMiddleware(app, token=settings.auth_token)
return app
def main():
"""Entry point for the gitea-mcp-remote command."""
settings = load_settings()
app = create_app()
logger.info(f"Starting Gitea MCP Remote on {settings.http_host}:{settings.http_port}")
uvicorn.run(app, host=settings.http_host, port=settings.http_port)
if __name__ == "__main__":
main()