MCP server for Forgejo: connects LLM clients to issues, pull requests, repos, and more via the Model Context Protocol. Works standalone as an MCP server, as an OpenCode plugin, or directly as a CLI for the terminal. One tool, three ways to access the same Forgejo API.
  • TypeScript 99.6%
  • Shell 0.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Sebastian Schulz a526b23419
All checks were successful
ci / test (pull_request) Successful in 1m46s
fix(ci): raise the Node heap so tsc fits
2026-11-22 15:53:15 +00:00
.forgejo/workflows fix(ci): raise the Node heap so tsc fits 2026-11-22 15:53:15 +00:00
docs refactor(cli): group the review verbs under pr review 2026-10-18 20:52:35 +00:00
scripts refactor(tests): migrate from bun:test to vitest for Node.js compatibility 2026-11-22 11:24:34 +00:00
src fix(tests): finish the vitest migration in the review tests 2026-11-22 15:47:43 +00:00
.envrc docs: rename forgejo-mcp references to forgejoctl across all docs 2026-09-01 09:38:59 +00:00
.gitignore feat(core): add swagger-derived api types to source tree 2026-08-25 21:49:00 +00:00
AGENTS.md docs(agents): add knip to the lint gate list 2026-09-09 13:13:57 +00:00
biome.json fix(lint): delete unused run_id, exclude generated api-schema.ts from biome, apply biome formatting 2026-09-01 15:22:39 +00:00
bun.lock fix(shared): restore deleted modules and fix Bun.file polyfill bug 2026-11-22 11:24:34 +00:00
knip.jsonc fix(auth): restore defaultReader and fix test-runner regressions 2026-11-22 11:24:34 +00:00
LICENSE Initial commit 2026-08-25 08:56:38 +00:00
mise.toml refactor(tests): migrate from bun:test to vitest for Node.js compatibility 2026-11-22 11:24:34 +00:00
opencode.jsonc fix(lint): resolve pre-existing biome errors blocking CI 2026-09-04 21:03:14 +00:00
package.json fix(shared): restore deleted modules and fix Bun.file polyfill bug 2026-11-22 11:24:34 +00:00
README.md docs: settle the pagination contract and the S5 claims 2026-10-18 15:11:12 +00:00
tsconfig.json feat: scaffold hello-world across all three adapters 2026-08-25 12:27:46 +00:00
vitest.config.ts fix(auth): restore defaultReader and fix test-runner regressions 2026-11-22 11:24:34 +00:00

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_requests
  • get_pull_request
  • get_pull_request_diff
  • list_pull_request_files
  • list_pull_request_commits
  • create_pull_request
  • update_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_issues
  • get_issue
  • create_issue
  • update_issue
  • list_issue_comments
  • create_issue_comment

Actions

  • list_action_runs
  • get_action_run
  • list_action_run_jobs
  • get_action_run_job_log
  • get_action_run_logs
  • watch_action_run
  • dispatch_workflow
  • cancel_action_run

Releases & tags

Manage repository releases and git tags.

  • list_releases
  • get_release
  • create_release
  • update_release
  • delete_release
  • list_tags
  • get_tag
  • create_tag
  • delete_tag
  • list_release_assets
  • delete_release_asset
  • release_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. bunx defaults to npmjs.org and will not find it there. Add a .npmrc so 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