# plugin_github — GitHub MCP connector for SCORPIOX BOT A zero-dependency, pure C99, clean-room connector that gives any SCORPIOX BOT agent five GitHub tools over MCP stdio, and a dark/light setup page for the credential that powers them. ```json {"name":"github","desc":"GitHub tools","kind":"mcp","mcp":true,"daemon":false,"menus":false,"verified":"mock"} ``` * **One binary, five modes:** `--meta` discovery, `--mcp` stdio JSON-RPC 2.0, `--schema`, a bot-themed setup page (`GET`), and a node-auth-gated control API (`?action=`). * **Zero runtime dependencies:** no libcurl, no OpenSSL, no system CA file. TLS is vendored BearSSL (verified chain + hostname check, compiled-in root store); JSON is vendored yyjson. `ldd` says *not a dynamic executable* on every Linux target; the Windows build is a static PE against `ws2_32` only. * **Clean-room:** no credentials, no host literals, no copied code. Built on the [SCORPIOX BOT Connector SDK](https://git.scorpiox.net/SCORPIOX_INC/scorpiox-bot-connector-sdk) (vendored into `src/`), same shape as `oss-filesystem` / `oss-time` / `oss-fetch` / `oss-websearch` / `oss-webhook`. ## The five tools | Tool | Arguments | REST call | |---|---|---| | `github_get_repo` | `owner`, `repo` | `GET /repos/{owner}/{repo}` | | `github_list_issues` | `owner`, `repo`, `state?` | `GET /repos/{owner}/{repo}/issues?state=…` (pull requests filtered, like the upstream references) | | `github_create_issue` | `owner`, `repo`, `title`, `body?` | `POST /repos/{owner}/{repo}/issues` | | `github_get_pull_request` | `owner`, `repo`, `number` | `GET /repos/{owner}/{repo}/pulls/{number}` | | `github_search_code` | `query` | `GET /search/code?q=…` | Auth is a personal access token in `Authorization: Bearer …` with `X-GitHub-Api-Version: 2022-11-28`. A 429/5xx is retried once honouring `Retry-After` (capped at 5 s); upstream refusals are relayed with GitHub's own `message` — the one fact the user can act on. ## Setup page `Settings → Plugins → github`, or the hub plugin page. Save a PAT (written to `config.json` at mode `0600`, never echoed back — the page only learns whether one is set and which login it belongs to), point the API base at a GitHub Enterprise instance if you like, press **Test connection**, and **Disconnect** wipes the token while keeping the base. Resolution order for both values: `GITHUB_TOKEN` / `GITHUB_API_BASE` environment → `config.json` → default (`https://api.github.com`). ![setup page](docs/ui-1440x900-dark.png) ## Build ```sh make # native -> ./plugin_github make musl # static musl x86_64 make arm64 # static musl aarch64 make win64 # static MinGW PE -> plugin_github.exe make macos # Apple clang (run on a Mac) make asan # ASan + UBSan + _FORTIFY_SOURCE=2 make test # build + the offline suite (mock GitHub, no internet) ``` Install by dropping the binary into `~/.scorpiox/plugins/` (or use the in-bot 1-click installer, which verifies the SHA-256 + magic bytes + `--meta` smoke before the atomic rename). No restart is needed — the node rescans per request, and the single `sx-connector-mcp` router re-reads the plugin registry per call, so an installed connector is immediately callable as `connector_call("github", "github_get_repo", {...})`. ## Tests `tests/run.sh` needs only python3. Sections: `--meta`, `--schema`, then * `tests/mcp.py` drives `--mcp` over stdio against `tests/mockapi.py`, a recording mock: **every tool's HTTP request is asserted from what the mock actually received** — method, path, query, `Authorization` header, JSON body — plus the PR filter, GitHub-message relays, missing-token honesty, the single `503 + Retry-After` retry, and malformed-input survival. * `tests/cgi.py` drives the control API as a real CGI: 401 on every action against a passworded node with no client credential, 0600 `config.json`, save validation, token never present in any response, `clear` semantics. * the whole MCP + CGI pass runs again under ASan/UBSan. * source hygiene greps: no `popen/system/exec/fork` in the connector's own sources, no credential-shaped literals, no LAN addresses, no CDN scripts. `tests/e2e.py` adds Playwright viewport checks (1440/1024/390, dark+light, no console errors, no horizontal overflow, save/test/disconnect behaviour, the token never appearing in the DOM) and writes the `docs/ui-*.png` set. Secret history is gated separately by `scorpiox-cli-botplugin audit ` before any publish. ## Security Read [docs/SECURITY.md](docs/SECURITY.md). The short version: the token lives in a 0600 file and never leaves the process except inside the `Bearer` header to the base you configured; TLS verification cannot be relaxed from a request or the config file; everything a stranger can write on GitHub is copied, sanitised and escaped before it reaches a reply. ## Verified tier — honest `verified` is `"mock"` by design: CI proves every wire shape against the mock, not against a live account. The release report documents the additional manual smoke against the real `api.github.com`. ## License MIT. Vendored third-party: BearSSL (MIT) in `vendor/bearssl/`, yyjson (MIT) in `vendor/` — licenses alongside. The connector runtime `src/sx_connector.*` is the SCORPIOX BOT Connector SDK (MIT).