generated from personal-projects/leo-claude-mktplace
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>
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
"""Configuration loader module."""
|
||||
|
||||
from .settings import GiteaSettings, load_settings
|
||||
|
||||
__all__ = ["GiteaSettings", "load_settings"]
|
||||
5
src/gitea_mcp_remote/config/__init__.py
Normal file
5
src/gitea_mcp_remote/config/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""Configuration module for Gitea MCP HTTP transport."""
|
||||
|
||||
from gitea_mcp_remote.config.settings import GiteaSettings, load_settings
|
||||
|
||||
__all__ = ["GiteaSettings", "load_settings"]
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Configuration settings for Gitea HTTP MCP wrapper."""
|
||||
"""Configuration settings for Gitea MCP HTTP transport."""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
@@ -30,18 +30,18 @@ class GiteaSettings(BaseSettings):
|
||||
...,
|
||||
description="Default repository owner/organization",
|
||||
)
|
||||
gitea_repo: str = Field(
|
||||
...,
|
||||
description="Default repository name",
|
||||
gitea_repo: str | None = Field(
|
||||
default=None,
|
||||
description="Default repository name (optional)",
|
||||
)
|
||||
|
||||
# HTTP Server Configuration
|
||||
http_host: str = Field(
|
||||
default="127.0.0.1",
|
||||
default="0.0.0.0",
|
||||
description="HTTP server bind address",
|
||||
)
|
||||
http_port: int = Field(
|
||||
default=8000,
|
||||
default=8080,
|
||||
ge=1,
|
||||
le=65535,
|
||||
description="HTTP server port",
|
||||
@@ -52,6 +52,10 @@ class GiteaSettings(BaseSettings):
|
||||
default=None,
|
||||
description="Bearer token for HTTP authentication (optional)",
|
||||
)
|
||||
mcp_auth_mode: str = Field(
|
||||
default="optional",
|
||||
description="MCP authentication mode: 'required', 'optional', or 'none'",
|
||||
)
|
||||
|
||||
# Tool Filtering Configuration
|
||||
enabled_tools: Optional[str] = Field(
|
||||
@@ -85,15 +89,6 @@ class GiteaSettings(BaseSettings):
|
||||
return None
|
||||
return [tool.strip() for tool in self.disabled_tools.split(",") if tool.strip()]
|
||||
|
||||
def get_gitea_mcp_env(self) -> dict[str, str]:
|
||||
"""Get environment variables for the wrapped Gitea MCP server."""
|
||||
return {
|
||||
"GITEA_BASE_URL": self.gitea_url,
|
||||
"GITEA_API_TOKEN": self.gitea_token,
|
||||
"GITEA_DEFAULT_OWNER": self.gitea_owner,
|
||||
"GITEA_DEFAULT_REPO": self.gitea_repo,
|
||||
}
|
||||
|
||||
|
||||
def load_settings(env_file: Optional[Path] = None) -> GiteaSettings:
|
||||
"""
|
||||
@@ -1,7 +1,10 @@
|
||||
"""Tool filtering for Claude Desktop compatibility."""
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ToolFilter:
|
||||
"""
|
||||
@@ -22,13 +25,11 @@ class ToolFilter:
|
||||
Args:
|
||||
enabled_tools: List of tool names to enable. If None, all tools are enabled.
|
||||
disabled_tools: List of tool names to disable. Takes precedence over enabled_tools.
|
||||
|
||||
Raises:
|
||||
ValueError: If both enabled_tools and disabled_tools are specified.
|
||||
"""
|
||||
if enabled_tools is not None and disabled_tools is not None:
|
||||
raise ValueError(
|
||||
"Cannot specify both enabled_tools and disabled_tools. Choose one filtering mode."
|
||||
logger.warning(
|
||||
"Both enabled_tools and disabled_tools specified. "
|
||||
"Disabled list takes precedence over enabled list."
|
||||
)
|
||||
|
||||
self.enabled_tools = set(enabled_tools) if enabled_tools else None
|
||||
@@ -16,9 +16,9 @@ from starlette.requests import Request
|
||||
from starlette.responses import JSONResponse
|
||||
from starlette.routing import Route
|
||||
|
||||
from gitea_http_wrapper.config import GiteaSettings, load_settings
|
||||
from gitea_http_wrapper.filtering import ToolFilter
|
||||
from gitea_http_wrapper.middleware import (
|
||||
from gitea_mcp_remote.config import GiteaSettings, load_settings
|
||||
from gitea_mcp_remote.filtering import ToolFilter
|
||||
from gitea_mcp_remote.middleware import (
|
||||
BearerAuthMiddleware,
|
||||
HealthCheckBypassMiddleware,
|
||||
)
|
||||
@@ -298,7 +298,7 @@ def main() -> None:
|
||||
|
||||
# Run server
|
||||
uvicorn.run(
|
||||
"gitea_http_wrapper.server:app",
|
||||
"gitea_mcp_remote.server:app",
|
||||
host=settings.http_host,
|
||||
port=settings.http_port,
|
||||
log_level="info",
|
||||
@@ -6,7 +6,7 @@ from pathlib import Path
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from gitea_http_wrapper.config import GiteaSettings, load_settings
|
||||
from gitea_mcp_remote.config import GiteaSettings, load_settings
|
||||
|
||||
|
||||
class TestGiteaSettings:
|
||||
@@ -2,18 +2,24 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from gitea_http_wrapper.filtering import ToolFilter
|
||||
from gitea_mcp_remote.filtering import ToolFilter
|
||||
|
||||
|
||||
class TestToolFilter:
|
||||
"""Test ToolFilter class."""
|
||||
|
||||
def test_init_with_both_lists_raises(self):
|
||||
"""Test that specifying both enabled and disabled lists raises error."""
|
||||
with pytest.raises(ValueError) as exc_info:
|
||||
ToolFilter(enabled_tools=["tool1"], disabled_tools=["tool2"])
|
||||
def test_init_with_both_lists_logs_warning(self, caplog):
|
||||
"""Test that specifying both enabled and disabled lists logs warning."""
|
||||
import logging
|
||||
|
||||
assert "Cannot specify both" in str(exc_info.value)
|
||||
with caplog.at_level(logging.WARNING):
|
||||
filter = ToolFilter(enabled_tools=["tool1"], disabled_tools=["tool2"])
|
||||
|
||||
assert "Both enabled_tools and disabled_tools specified" in caplog.text
|
||||
assert "Disabled list takes precedence" in caplog.text
|
||||
|
||||
# Verify disabled list takes precedence
|
||||
assert not filter.should_include_tool("tool2")
|
||||
|
||||
def test_passthrough_mode(self):
|
||||
"""Test passthrough mode (no filtering)."""
|
||||
@@ -6,7 +6,7 @@ from starlette.responses import JSONResponse
|
||||
from starlette.routing import Route
|
||||
from starlette.testclient import TestClient
|
||||
|
||||
from gitea_http_wrapper.middleware import (
|
||||
from gitea_mcp_remote.middleware import (
|
||||
BearerAuthMiddleware,
|
||||
HealthCheckBypassMiddleware,
|
||||
)
|
||||
Reference in New Issue
Block a user