GitHub Tool
Agent tool for performing authenticated GitHub API actions using per-user stored GitHub credentials.

This node exposes a single tool that routes multiple GitHub-specific actions. It retrieves per-user GitHub configuration from stored API key, performs authenticated requests to the GitHub REST API, decodes file contents when needed, and returns parsed JSON (or raw text when parsing fails). Network and API errors are logged and raised as exceptions.
Actions
- Fetches per-user GitHub config (GITHUB_TOKEN required) RuntimeError if token missing.
- Supports the following actions (action-specific params described briefly below):
- get_repo — get repository metadata. Params: owner, repo (defaults allowed via config).
- list_issues — list issues. Params: owner, repo, state (default "open"), per_page, page.
- get_issue — get single issue. Params: owner, repo, issue_number (required).
- create_issue — create issue. Params: owner, repo, title (required), body, labels, assignees. Returns created issue JSON.
- list_prs — list pull requests. Params: owner, repo, state (default "open"), per_page, page.
- get_pr — get PR. Params: owner, repo, pr_number (required).
- create_pr — create PR. Params: owner, repo, title (required), head (required), base (defaults to cfg.default_branch or "main"), body, maintainer_can_modify.
- merge_pr — merge PR. Params: owner, repo, pr_number (required), commit_title, merge_method (default "merge").
- list_branches — list branches. Params: owner, repo, per_page, page.
- get_file — get file contents/metadata. Params: owner, repo, path (required), ref (defaults to cfg.default_branch or "main"). Returns GitHub content API response.
- create_file — create file. Params: owner, repo, path (required), message (required), content (base64-encoded string required by GitHub), branch, committer. Returns created file response.
- update_file — update file. Params: owner, repo, path (required), message (required), content (base64), branch, sha (required), committer.
- delete_file — delete file. Params: owner, repo, path (required), message (required), sha (required), branch.
- search_code — search code. Params: query (required), per_page, page.
- list_repos — list repos for user or org. Params: org (optional), type (default "owner"), per_page, page.
- create_label — create label. Params: owner, repo, name (required), color (hex without '#', default "4287f5"), description.
- list_labels — list labels. Params: owner, repo, per_page, page.
- add_comment — add comment to issue or PR. Params: owner, repo, issue_number or pr_number (one required), body (required). Returns created comment JSON.
Outputs
- Returns the parsed GitHub API response (JSON-decoded) or raw text if JSON decoding fails.
- For file content responses, use the provided utility
_decode_github_content(item)
to obtain (encoding, raw_bytes). - Errors surface as raised exceptions with logged context (network errors, validation errors, unexpected HTTP status codes).
Behavior and Constraints
- Per-user config: requires a per-user GITHUB_TOKEN provided in the user Secret key store.
- Repo path construction: owner and repo are URL-encoded and combined as "owner/repo". Owner and repo are required for repo-scoped operations; otherwise a ValueError is raised.
- File path encoding: file paths are URL-encoded when used in contents endpoints.
Error Handling
- Missing GitHub token or required config keys raises RuntimeError identifying the missing key.
- Network/request errors raise RuntimeError with logged exception details.
- Non-success HTTP responses raise RuntimeError including HTTP status and response body.
- Action-specific parameter validation errors raise ValueError or Pydantic ValidationError as appropriate.