feat!: full-access Gitea MCP server (1.0.0): full API coverage, stdio + streamable HTTP, admin and per-user OAuth #71
No files matched your search
@@ -17,6 +17,17 @@ from aegis_gitea_mcp.config import Settings, get_settings, reset_settings
|
|||||||
from aegis_gitea_mcp.logging_utils import configure_logging
|
from aegis_gitea_mcp.logging_utils import configure_logging
|
||||||
|
|
||||||
|
|
||||||
|
def _port(value: str) -> int:
|
||||||
|
"""Parse ``--port`` (argparse ``type``): an integer from 1 to 65535."""
|
||||||
|
try:
|
||||||
|
port = int(value)
|
||||||
|
except ValueError:
|
||||||
|
raise argparse.ArgumentTypeError("must be an integer from 1 to 65535") from None
|
||||||
|
if not 1 <= port <= 65535:
|
||||||
|
raise argparse.ArgumentTypeError("must be between 1 and 65535")
|
||||||
|
return port
|
||||||
|
|
||||||
|
|
||||||
def build_parser() -> argparse.ArgumentParser:
|
def build_parser() -> argparse.ArgumentParser:
|
||||||
"""Build the argument parser."""
|
"""Build the argument parser."""
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@@ -35,9 +46,8 @@ def build_parser() -> argparse.ArgumentParser:
|
|||||||
serve.add_argument("--host", default=None, help="HTTP bind address (default: MCP_HOST)")
|
serve.add_argument("--host", default=None, help="HTTP bind address (default: MCP_HOST)")
|
||||||
serve.add_argument(
|
serve.add_argument(
|
||||||
"--port",
|
"--port",
|
||||||
type=int,
|
type=_port,
|
||||||
default=None,
|
default=None,
|
||||||
choices=range(1, 65536),
|
|
||||||
metavar="PORT",
|
metavar="PORT",
|
||||||
help="HTTP port (default: MCP_PORT)",
|
help="HTTP port (default: MCP_PORT)",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -33,3 +33,16 @@ def test_package_version_matches_pyproject() -> None:
|
|||||||
|
|
||||||
data = tomllib.loads((Path(__file__).parent.parent / "pyproject.toml").read_text())
|
data = tomllib.loads((Path(__file__).parent.parent / "pyproject.toml").read_text())
|
||||||
assert data["project"]["version"] == __version__
|
assert data["project"]["version"] == __version__
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("value", ["0", "65536", "-1", "http", "80.5"])
|
||||||
|
def test_serve_rejects_bad_ports_with_a_short_message(
|
||||||
|
value: str, capsys: pytest.CaptureFixture[str]
|
||||||
|
) -> None:
|
||||||
|
with pytest.raises(SystemExit) as exit_info:
|
||||||
|
build_parser().parse_args(["serve", "--port", value])
|
||||||
|
|
||||||
|
err = capsys.readouterr().err
|
||||||
|
assert exit_info.value.code == 2
|
||||||
|
assert "--port" in err and "65535" in err
|
||||||
|
assert len(err) < 500
|
||||||
Reference in new issue
Block a user