Files
labyricorn-site/labyricorn_mcp/__main__.py
T
Labyricorn fe6025fa63
Deploy production / deploy (push) Successful in 21s
Add local repository MCP server
2026-08-23 10:48:33 -07:00

37 lines
1.2 KiB
Python

"""Command-line entry point for the stdio MCP server."""
from __future__ import annotations
import argparse
import logging
import sys
from .errors import LabyricornMcpError
from .safety import RepositoryGuard
from .server import StdioMcpServer
def main() -> int:
parser = argparse.ArgumentParser(description="Run the local repository-scoped Labyricorn MCP server over stdio.")
parser.add_argument(
"--repository",
help="Labyricorn repository root. Defaults to LABYRICORN_REPOSITORY, then the current directory.",
)
parser.add_argument("--verbose", action="store_true", help="Write diagnostic detail to stderr.")
arguments = parser.parse_args()
logging.basicConfig(
stream=sys.stderr,
level=logging.INFO if arguments.verbose else logging.WARNING,
format="labyricorn-mcp: %(levelname)s: %(message)s",
)
try:
guard = RepositoryGuard.discover(arguments.repository)
return StdioMcpServer(guard).serve_forever()
except LabyricornMcpError as exc:
print(f"labyricorn-mcp: ERROR: {exc.code}: {exc.message}", file=sys.stderr)
return 2
if __name__ == "__main__":
raise SystemExit(main())