diff --git a/integrations/opencode-athena/GITEA-2026-10-14.md b/integrations/opencode-athena/GITEA-2026-10-14.md new file mode 100644 index 0000000..cf5e7d4 --- /dev/null +++ b/integrations/opencode-athena/GITEA-2026-10-14.md @@ -0,0 +1,102 @@ +# Personal Gitea integration and project roots + +## Active setup + +Unraid OpenCode 1.18.34 now has an additional local stdio MCP named `gitea`. +It uses the official Gitea MCP v1.8.1 binary inside the existing container; +no extra container, socket mount or public listener is needed. DuckDuckGo remains. + +Server: https://git.casaderoll.de, account michael. The global AGENTS.md now +includes `gitea-project-rules.md`: "my Git" means this server when no local +project is named, search/list repositories through MCP first, and use durable +checkouts rather than temporary clones for coding. + +`gitea-launch.py` uses Git's configured credential helper in a captured subprocess +and passes the password/token internally as GITEA_ACCESS_TOKEN to the official +MCP. Neither the config nor command arguments contain credentials. The wrapper +never prints helper output or exception details. Authentication and a real +search for HORIZON both succeeded with the existing credential. Rotation of the +previously exposed credential remains a separate user action; the integration +does not revoke or rotate it. Updating the Git credential helper also supplies +the credential to newly launched MCP processes; reconnect after rotation. + +The MCP exposes 14 read tools for repository search, trees/files, branches, +commits, issues and pull requests. It does not expose Actions secrets/configuration +tools or write tools. Normal coding, commits and pushes still use Git in the +actual local checkout. This MCP is not a global file-content search index; +`search_repos` searches repositories. Do not infer unavailable code search from +a guessed endpoint returning 404. + +## Correct local project + +The collection `/workspace` contains an empty Git initialization with an ownership +warning and no remote. It is not the user's Gitea server or the HORIZON checkout. +Its metadata and ownership were not removed or altered. + +Created a clean checkout at `/workspace/HORIZON` using a credential-free HTTPS +clone URL and the existing Git credential helper. The directory is on the existing +persistent workspace mount. Verified `git rev-parse` succeeds and status is clean. +OpenCode's `/project/current?directory=/workspace/HORIZON` reports that exact +worktree with `vcs=git`. The browser must open that folder as a project for its +change view to correspond to HORIZON. A read-only inspection naturally has no diff. + +The existing "Search Git for HORIZON" chat was not moved, restarted or rewritten. +Its temporary clone was preserved; only its origin URL was sanitized to the clean +HTTPS URL using `git remote set-url`, with no credential value read into outputs. +No existing source files or uncommitted code were replaced. + +## Restore + +1. Restore the user's private OpenCode home/credential helper through protected + backup, never Git. This repo contains no credential material. +2. Install Python >=3.10 and Git in the OpenCode environment (Alpine packages + python3/git; Debian python3/git). The preceding DuckDuckGo setup already installed + Python 3.14.8 in the current container. An image recreation must retain or + reinstall OS dependencies; a plain restart retains them. +3. Download the official release archive into the user's persistent home: + https://gitea.com/gitea/gitea-mcp/releases/download/v1.8.1/gitea-mcp_Linux_x86_64.tar.gz + SHA256: `5ed5005e116a5c6e570893a2c6bb8fd034633b67bffd4145e2de1daa7b9fd761`. + Its checksum was compared with the upstream release checksum manifest. + Extract to `~/.local/share/opencode/gitea-mcp/1.8.1/`. + For other architectures use the matching official artifact and verified hash. +4. Install `gitea-launch.py` as `~/.config/opencode/mcp/gitea/launch.py` (0755). + The wrapper uses Path.home(), so native non-root users use their own credential + helper and home. Merge `gitea-mcp.json` into the private config with the command + path adjusted for that user's home. Preserve unrelated config. +5. Append `gitea-project-rules.md` to global AGENTS.md, preserving other rules. + Adjust the persistent project base `/workspace` if a native installation uses + another checkout location. Open the actual checkout as the OpenCode project. + +The binary, launcher, config and rules persist in the existing /root bind mount +at `/mnt/nvme-storage/appdata/OpenCode`; local source checkouts persist in the +existing /workspace mount. This is external OpenCode integration, not a new Deck +runtime or a completed native Deck installer. Full restore onto a fresh host has +not been performed. + +## Activation and validation + +Saved global config on disk. Used the installed server's schema-confirmed +POST /mcp to register this new server for /workspace without global disposal or +container restart. It returned HTTP 200 with both duckduckgo and gitea connected. +Direct stdio MCP tests initialized successfully, listed the selected tools, +authenticated and found `michael/HORIZON` through search_repos. No new model call, +coding chat or speculative web API probe was used for validation. + +The initial hot registration applied only to the already open /workspace instance: +the new HORIZON instance still saw cached pre-Gitea global config. After checking +both known projects for active requests (none), updated only `mcp` through the +schema-confirmed PATCH /global/config (HTTP 200). This reloads configuration and +may discard transient instance state; no active task was interrupted, saved chats +were not migrated or deleted, and no container was restarted. + +The first identical on-disk patch did not invalidate the cache: upstream +Config.updateGlobal invalidates only when file contents change. Set the launch +command to the explicit `/usr/bin/python3` interpreter through the official route, +preserving the entire DuckDuckGo MCP entry. Do not rely on an HTTP 200 alone; +verify live global config and both project-scoped MCP status endpoints. + +References: +- https://gitea.com/gitea/gitea-mcp +- https://gitea.com/gitea/gitea-mcp/releases/tag/v1.8.1 +- https://opencode.ai/docs/mcp-servers/ +- https://opencode.ai/docs/rules/ diff --git a/integrations/opencode-athena/gitea-launch.py b/integrations/opencode-athena/gitea-launch.py new file mode 100644 index 0000000..1ab1302 --- /dev/null +++ b/integrations/opencode-athena/gitea-launch.py @@ -0,0 +1,43 @@ +#!/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()) diff --git a/integrations/opencode-athena/gitea-mcp.json b/integrations/opencode-athena/gitea-mcp.json new file mode 100644 index 0000000..01f4110 --- /dev/null +++ b/integrations/opencode-athena/gitea-mcp.json @@ -0,0 +1,10 @@ +{ + "mcp": { + "gitea": { + "type": "local", + "command": ["/usr/bin/python3", "/root/.config/opencode/mcp/gitea/launch.py"], + "enabled": true, + "timeout": 15000 + } + } +} diff --git a/integrations/opencode-athena/gitea-project-rules.md b/integrations/opencode-athena/gitea-project-rules.md new file mode 100644 index 0000000..db76a87 --- /dev/null +++ b/integrations/opencode-athena/gitea-project-rules.md @@ -0,0 +1,7 @@ +## Personal Gitea and project selection + +- The user's personal Git/Gitea server is https://git.casaderoll.de, account michael. When asked to search "my Git" without a named local project, use the Gitea MCP repository search/list tools first. Do not interpret the whole /workspace directory as the user's remote Git server. +- For repository overview, file trees, files, issues and pull requests, prefer the Gitea MCP. Repository search finds repositories; it is not a full-text search of every file. Do not infer that code search is unsupported from a 404 on a guessed API endpoint. +- For coding, builds or comprehensive local code search, use a durable checkout under /workspace/. Reuse and inspect an existing checkout before fetching; preserve uncommitted work. Clone with a clean HTTPS URL and Git's configured credential helper, never with credentials embedded in the URL. Do not clone working projects into /tmp. +- Open the actual checkout folder as the OpenCode project so changes and Git operations refer to that repository. A clone into another folder does not change the current chat's project. If the chat is rooted elsewhere, state which project folder the user should open; do not silently migrate or replace their running session. +- Credentials are handled internally by the configured helper/MCP launcher. Never print credential files, credential-helper output, secrets, authorization headers, authenticated URLs or environment dumps. Never place tokens in command-line arguments, remote URLs, model-visible configuration or tool outputs.