feat: new settings, CLI skeleton and interface skeletons

Adds the pydantic-settings Settings with validated GITEA_URL, OAuth scopes
and toolsets, the argparse CLI skeleton, catalog.model, identity and
GiteaAPIError. Test fixtures now isolate env, cwd and state paths in tmp.
This commit is contained in:
Latte committed 2026-10-14 15:40:37 +02:00
1 parent 4ac9626eb5
commit b82e2866cb
24 files changed
+1512 -605

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
"""Command line entry point (``aegis-gitea-mcp``).
Subcommands: ``serve`` (default), ``setup`` and ``version``. ``serve`` and
``setup`` are filled in by later chunks.
"""
from __future__ import annotations
import argparse
import sys
from collections.abc import Sequence
from aegis_gitea_mcp import __version__
def build_parser() -> argparse.ArgumentParser:
"""Build the argument parser."""
parser = argparse.ArgumentParser(
prog="aegis-gitea-mcp",
description="MCP server exposing the Gitea API over stdio or streamable HTTP.",
)
subparsers = parser.add_subparsers(dest="command")
serve = subparsers.add_parser("serve", help="run the MCP server (default)")
serve.add_argument(
"--transport",
choices=("stdio", "http"),
default=None,
help="transport to serve (default: MCP_TRANSPORT, else stdio)",
)
subparsers.add_parser("setup", help="interactive setup against a Gitea instance")
subparsers.add_parser("version", help="print the version and exit")
return parser
def _not_implemented(command: str) -> int:
"""Report an unbuilt command and return the usage-error exit code."""
print(f"aegis-gitea-mcp {command}: not implemented yet", file=sys.stderr)
return 2
def main(argv: Sequence[str] | None = None) -> int:
"""Run the CLI and return the process exit code."""
args = build_parser().parse_args(argv)
command = args.command or "serve"
if command == "version":
print(__version__)
return 0
return _not_implemented(command)
if __name__ == "__main__": # pragma: no cover
raise SystemExit(main())