Files
Athena-Deck/integrations/opencode-athena/gitea-launch.py

44 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Launch the official Gitea MCP without exposing credentials in config/output."""
import os
from pathlib import Path
import subprocess
import sys
HOST = "https://git.casaderoll.de"
TOOLS = (
"get_me,list_my_repos,search_repos,get_repository_tree,get_file_contents,"
"get_dir_contents,list_branches,list_commits,get_commit,list_issues,"
"issue_read,list_pull_requests,pull_request_read,search_issues"
)
def main():
env = dict(os.environ, GIT_TERMINAL_PROMPT="0")
try:
result = subprocess.run(
["git", "credential", "fill"],
input="protocol=https\nhost=git.casaderoll.de\n\n",
text=True, capture_output=True, timeout=10, env=env,
)
fields = dict(
line.split("=", 1) for line in result.stdout.splitlines() if "=" in line
)
secret = fields.get("password") if result.returncode == 0 else None
if not secret:
raise RuntimeError("Missing credential")
env.update(
GITEA_HOST=HOST, GITEA_ACCESS_TOKEN=secret,
GITEA_DEBUG="false", GITEA_INSECURE="false",
)
binary = Path.home() / ".local/share/opencode/gitea-mcp/1.8.1/gitea-mcp"
os.execve(str(binary), [str(binary), "-t", "stdio", "-r", "-O", TOOLS], env)
except Exception:
# Never include subprocess output, credential fields or exception text.
print("Gitea MCP could not start. Check its binary and Git credential helper privately.", file=sys.stderr)
return 1
if __name__ == "__main__":
sys.exit(main())