- TypeScript 99.6%
- Shell 0.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| docs | ||
| scripts | ||
| src | ||
| .envrc | ||
| .gitignore | ||
| AGENTS.md | ||
| biome.json | ||
| bun.lock | ||
| knip.jsonc | ||
| LICENSE | ||
| mise.toml | ||
| opencode.jsonc | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| vitest.config.ts | ||
forgejoctl
Talk to your Forgejo from your terminal, editor, or LLM client. One tool, three ways in.
What you can do
Pull requests
list_pull_requestsget_pull_requestget_pull_request_difflist_pull_request_fileslist_pull_request_commitscreate_pull_requestupdate_pull_request
get_pull_request_diff returns the diff as sliced lines and takes the
same options as a job log — --head-lines, --tail-lines,
--lines/--from, --grep/--context — so a large pull request
never has to arrive whole. --format patch gives you something
git apply accepts.
Issues
list_issuesget_issuecreate_issueupdate_issuelist_issue_commentscreate_issue_comment
Actions
list_action_runsget_action_runlist_action_run_jobsget_action_run_job_logget_action_run_logswatch_action_rundispatch_workflowcancel_action_run
Releases & tags
Manage repository releases and git tags.
list_releasesget_releasecreate_releaseupdate_releasedelete_releaselist_tagsget_tagcreate_tagdelete_taglist_release_assetsdelete_release_assetrelease_asset_upload(CLI only)
Release and tag addressing is tag-only in v1 — pass tag="latest" to get_release to resolve the latest non-prerelease, non-draft release. Assets are addressed by (tag, asset_name). Binary asset upload is intentionally CLI-only: the MCP stdio transport has no binary content blocks for outbound responses, and the CLI is the natural CI consumer with the file path on disk.
A get_version tool is also available for smoke testing.
Raw API passthrough
api(CLI only)
forgejoctl api repos/owner/name
forgejoctl api repos/owner/name/issues -X GET -f state=closed
forgejoctl api repos/owner/name/issues -F title="Broken" -F draft=true
forgejoctl api repos/owner/name/pulls/7 -X PATCH --input patch.json
forgejoctl api repos/owner/name/issues -p --slurp
The endpoint is a path like repos/owner/name; a leading /api/v1 is
added when absent. Owner and repo are never inferred from the current
repository, so write them out. -f sends a string, -F types
true/false/null/integers as JSON literals and reads @file for
the value's content, --input reads a body from a file,
--header 'key: value' adds a request header, -p follows
Link: rel="next", --slurp wraps the pages in one JSON array, and
-i prints the status line and headers as well as the body. -H is
pr create --head in this CLI, so the request header is --header
only.
This verb is deliberately absent from the MCP server and the OpenCode plugin: arbitrary HTTP under the user's token is a privilege escalation for an agent, and a raw response bypasses the curated views the other tools return. See ADR-005.
Three ways to use it
CLI
Install once. Run subcommands from any checkout with an origin remote pointing to your Forgejo host.
bunx @sebatec-eu/forgejoctl version
Or, if you cloned the source:
bun run build
FORGEJO_URL=https://forge.example.org ./dist/forgejoctl version
Note
The package is published to the Forgejo package registry at
https://forge.sebatec.eu/api/packages/sebatec-eu/npm/, not npmjs.org.bunxdefaults to npmjs.org and will not find it there. Add a.npmrcso npm / Bun resolve@sebatec-eu/*from the Forgejo registry. Downloads are public — no token required.
MCP server
Wire it into any MCP-compatible client (Claude Desktop, VS Code, Cursor, OpenCode, etc.) as a local stdio server. The host comes from FORGEJO_URL; owner and repo are passed per call.
{
"mcpServers": {
"forgejo": {
"command": "bunx",
"args": ["@sebatec-eu/forgejoctl"],
"env": { "FORGEJO_URL": "https://forge.example.org" }
}
}
}
OpenCode plugin
Requires OpenCode 2. Point opencode.jsonc at the release tarball under plugins (V2 renamed the V1 plugin key). Call the tools from any OpenCode session in a checkout with an origin remote pointing to your Forgejo host.
{
"plugins": [
"https://forge.sebatec.eu/sebatec-eu/forgejoctl/releases/download/v0.2.0/forgejoctl.tgz"
]
}
Verify the load with opencode plugin list. The plugin shows up as
sebatec-eu.forgejo; a - in the id column means it did not load.
OpenCode installs a package plugin in the background, so give the
command a second run before you believe the -.
Configuration
| Variable | MCP server | CLI / OpenCode plugin | Notes |
|---|---|---|---|
FORGEJO_URL |
required | optional | Default Forgejo host. Scheme included (https://...). |
FORGEJO_TOKEN |
optional | optional | API token, sent as Authorization: token <token>. Fallback when FORGEJO_TOKEN_FILE is unset. |
FORGEJO_TOKEN_FILE |
optional | optional | Path to a file containing the API token. Defaults to /run/secrets/forgejo-token. Takes precedence over FORGEJO_TOKEN. |
The CLI infers host, owner, and repo from the origin git remote. The OpenCode plugin infers only the host from the same remote; repository tools take owner and repo as explicit arguments. FORGEJO_URL is a fallback both consult only when the working directory has no checkout or no origin. For the plugin that directory is ctx.location.directory, the location the plugin instance loaded. The MCP server has no working directory to inspect, so FORGEJO_URL is the only way it learns the host.
Commands
A quick tour:
# Hello world
forgejoctl version
# Pull requests
forgejoctl pr list
forgejoctl pr view 7
forgejoctl pr diff 7 --grep TODO --context 3
forgejoctl pr files 7
forgejoctl pr commits 7
forgejoctl pr create -t "Add feature" -H feature -B main
# Actions
forgejoctl run list
forgejoctl run view --run-index 13
forgejoctl run watch --run-index 13
forgejoctl run dispatch ci.yml --ref main --input env=prod
forgejoctl run logs --run-index 13 --tail-lines 200
# Anything the wrapped operations don't cover
forgejoctl api repos/owner/name/branch_protections
# Releases & tags
forgejoctl release list
forgejoctl release view latest
forgejoctl release view v1.2.3
forgejoctl release create --tag v1.2.3 --name "v1.2.3" --body "release notes"
forgejoctl release update v1.2.3 --name "v1.2.3"
forgejoctl release delete v1.2.3 --delete-tag true
forgejoctl release asset list v1.2.3
forgejoctl release asset upload v1.2.3 dist/foo.tar.gz
forgejoctl tag list
forgejoctl tag view v1.2.3
forgejoctl tag create --tag v1.2.3 --message "annotated tag"
forgejoctl tag delete v1.2.3
Run forgejoctl <subcommand> --help for the full grammar of any subcommand.
Where to go next
- docs/PRD.md — product scope, capabilities, and out-of-scope items.
- docs/ARCHITECTURE.md — core / adapters / shared cwd inference.
- AGENTS.md — contributing, commands, and house rules for developers.
- LICENSE