forgejo-mcp-server
An MCP server for Forgejo that lets an assistant inspect repositories and manage issues/pull requests using the caller’s token.
Identify the token’s Forgejo account and list accessible repositories.
List, read, create, comment on, and update issues (state, title, body, labels, assignees).
List and read pull requests, including optional diffs, and open PRs between existing branches.
Inspect branches, commit history, commit CI status, and file/directory contents at a revision.
Choose markdown or JSON output, with pagination and response-size caps.
Provides tools for interacting with a Forgejo instance, enabling repository exploration and management of issues and pull requests, including creating and updating issues, commenting, opening pull requests, and reading branches, commits, and files.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@forgejo-mcp-server list open issues in octocat/hello-world"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
forgejo-mcp-server
An MCP server for Forgejo: it gives an assistant (Claude Code, Cursor…) what it needs to read a repository and manage issues and pull requests without leaving the working session.
It works against any Forgejo instance: the target URL is an environment variable, never a hardcoded value.
Security model
The server holds no authority of its own. It does not own a token — it relays the caller's, and without one it can do nothing.
Token source | |
| the user's own |
| the |
This is not cosmetic. A single server-side token would mean three things: every
write attributed to one person in the Forgejo history, individual permissions
bypassed, and a public URL handing Forgejo access to whoever finds it. The
server refuses to start in http mode if FORGEJO_TOKEN is set.
Two further guards:
The instance URL is fixed server-side, never supplied by the caller, so a model cannot redirect the server at another host (SSRF).
Path segments are encoded one by one, which neutralises
..and slashes injected intoowner,repoor a file path.
The token is never logged, and never echoed back in an error message.
Related MCP server: Git MCP Server
Forgejo token
Create one at <instance>/user/settings/applications with these scopes:
Scope | What it allows |
|
|
| creating and commenting on issues |
| creating pull requests, reading files, branches and commits |
⚠️ Forgejo cannot separate "create a PR" from "write files": both live in
write:repository. The token is therefore broader than the tools exposed here —
no tool in this server modifies a file, but the token itself would allow it
through the API.
An existing token cannot be widened: adding a scope means issuing a new one.
Tools
Tool | Access | Purpose |
| read | token identity (check before writing) |
| read | accessible repositories |
| read | issues, filterable by state/labels/text |
| read | full issue + comments |
| write | open an issue (labels by name) |
| write | comment on an issue or a PR |
| write | close, reopen, retitle, rewrite, relabel, reassign |
| read | pull requests by state |
| read | full PR, optional diff |
| write | open a PR between two branches |
| read | branches and protection |
| read | a branch's history |
| read | CI status of a commit, job by job |
| read | file or directory at a revision |
All of them accept response_format (markdown by default, json for raw
data) and cap their response at 25,000 characters, reporting any cut.
Local use (stdio)
pnpm install
pnpm buildThe token comes from the shell environment, so it is never written to a versioned file:
export FORGEJO_TOKEN="<your token>"
claude mcp add forgejo -e FORGEJO_URL=https://forgejo.example.org -e FORGEJO_TOKEN=$FORGEJO_TOKEN -- node /absolute/path/to/dist/index.jsRailway deployment (http)
Connect the repository as a Railway service, then set:
Variable | Value |
| your instance, e.g. |
|
|
|
|
| optional, saves repeating |
| optional, saves repeating |
Railway requires the domain's target port to be exactly the one the service
listens on, otherwise the platform returns "Application failed to respond". The
server listens on 0.0.0.0:$PORT: setting PORT explicitly and reusing the
same value for the domain removes any ambiguity.
Never set FORGEJO_TOKEN on the service: the server refuses to start,
precisely to prevent that mistake.
railway.json supplies the build, start command and /healthz probe.
Each developer then registers the server with their own token:
claude mcp add --transport http forgejo https://<service>.up.railway.app/mcp \
--header "Authorization: Bearer <your forgejo token>"The service being public is acceptable precisely because a call without a valid
token grants nothing. /healthz only reports the instance URL and the version.
Development
pnpm dev # tsc --watch
pnpm typecheck # sources and tests
pnpm test # node:test, against a fake Forgejo client
pnpm start # node dist/index.jsQuick check without an MCP client:
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"smoke","version":"1"}}}' '{"jsonrpc":"2.0","method":"notifications/initialized"}' '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' | FORGEJO_URL="https://forgejo.example.org" FORGEJO_TOKEN="x" node dist/index.jsKnown limitations
No PR merging, no reviews, no milestone management: the scope stops at reading, opening, updating and commenting.
forgejo_update_issuereplaces the fields it is given — body, labels and assignees are overwritten, not appended to. Read the issue first if you mean to preserve what is there.forgejo_create_issueandforgejo_update_issueonly apply existing labels; unknown names are skipped and reported in the response.Binary files are not decoded (size and SHA only).
Pagination is capped at 50 items per page, the Forgejo API limit.
Available Tools
13 toolsforgejo_comment_issueComment on an issue or PRA
Adds a comment to an issue or a pull request (shared numbering).
Parameters: owner, repo, number (required), body (string, required), response_format.
Returns: { id, author, created_at, html_url }
Write operation: requires the 'write:issue' scope. The comment is attributed to the token's owner and cannot be deleted by this tool.
Inputs: body (required), number (required), repo, owner, +1 more.
forgejo_create_issueCreate an issueA
Opens a new issue. Write operation: requires the 'write:issue' scope.
Parameters:
owner, repo (optional when defaults are configured)
title (string, required)
body (string, optional): markdown description
labels (string[], optional): label names; unknown names are skipped and reported
assignees (string[], optional): login names
Returns: { number, title, state, html_url, unresolved_labels }
The issue is attributed to the token's owner — check with forgejo_whoami if unsure.
Inputs: title (required), body, repo, owner, +3 more.
forgejo_create_pull_requestOpen a pull requestA
Opens a pull request between two branches of the repository. Write operation: requires the 'write:repository' scope.
Parameters:
owner, repo (optional when defaults are configured)
head (string, required): source branch, already pushed to the server
base (string, required): target branch, typically 'main'
title (string, required)
body (string, optional)
Returns: { number, title, state, head, base, html_url }
Prerequisite: the 'head' branch must exist server-side — push before calling. Errors: 409 if a PR is already open for this branch pair; 404 if the head or base branch does not exist; 422 if the request is otherwise rejected.
Inputs: base (required), head (required), title (required), body, +3 more.
forgejo_get_fileRead a file or directoryARead-onlyIdempotent
Reads a text file's contents, or lists a directory, at a given revision.
Parameters:
owner, repo (optional when defaults are configured)
path (string, required): path from the repository root, e.g. 'lib/filters.ts'; '' or '.' for the root
ref (string, optional): branch, tag or SHA. Defaults to the main branch
response_format
Returns, for a file: { type: 'file', path, size, sha, content, truncated, html_url } Returns, for a directory: { type: 'directory', path, entries: [{ name, type, size }] }
Binary files are not decoded: their size and SHA are returned with an explicit note. Contents are truncated past the context limit and the cut is reported.
Inputs: ref, path, repo, owner, +1 more.
forgejo_get_issueIssue detailARead-onlyIdempotent
Returns a full issue: description, metadata and, on request, its comments.
Parameters: owner, repo, number (required), include_comments (bool, default true), response_format.
Returns: { number, title, state, author, labels, assignees, body, html_url, comments: [{ author, body, created_at }] }
Also works with a pull request number: issues and PRs share one numbering space in Forgejo. Errors: 404 if the number does not exist in this repository.
Inputs: number (required), repo, owner, response_format, +1 more.
forgejo_get_pull_requestPull request detailARead-onlyIdempotent
Returns a pull request: description, merge state, statistics and, on request, the unified diff.
Parameters: owner, repo, number (required), include_diff (bool, default false), response_format.
Returns: { number, title, state, merged, mergeable, head, base, additions, deletions, changed_files, body, html_url, diff? }
The diff is truncated past the context limit and the cut is explicitly reported in the returned text. Tip: leave include_diff=false for a status check — it saves a lot of context.
Inputs: number (required), repo, owner, include_diff, +1 more.
forgejo_list_branchesList branchesARead-onlyIdempotent
Lists the repository's branches with their latest commit and protection status.
Parameters: owner, repo, page, limit, response_format.
Returns: { total, count, page, limit, has_more, branches: [{ name, protected, commit_sha, commit_message }] }
Use it to confirm a branch exists before opening a pull request with forgejo_create_pull_request.
Inputs: page, repo, limit, owner, +1 more.
forgejo_list_commitsList commitsARead-onlyIdempotent
Lists a branch's commits, newest first.
Parameters: owner, repo, branch (string, optional — the repository's default branch when omitted), page, limit, response_format.
Returns: { total, count, page, limit, has_more, commits: [{ sha, message, author, date, html_url }] }
Examples:
"what changed recently" -> limit=10
"history of the migration branch" -> branch='birdiz/migration'
Inputs: page, repo, limit, owner, +2 more.
forgejo_list_issuesList issuesARead-onlyIdempotent
Lists a repository's issues. Pull requests are excluded (use forgejo_list_pull_requests).
Parameters:
owner, repo (string, optional when defaults are configured)
state ('open' | 'closed' | 'all', default 'open')
labels (string[], optional): label names, all of them required
query (string, optional): full-text search across title and body
page, limit, response_format
Returns: { total, count, page, limit, has_more, issues: [{ number, title, state, author, labels, comments, created_at, updated_at, html_url }] }
Examples:
"open issues on the CRM" -> state='open'
"closed bugs" -> state='closed', labels=['bug']
Inputs: page, repo, limit, owner, +4 more.
forgejo_list_pull_requestsList pull requestsARead-onlyIdempotent
Lists a repository's pull requests.
Parameters: owner, repo, state ('open' | 'closed' | 'all', default 'open'), page, limit, response_format.
Returns: { total, count, page, limit, has_more, pull_requests: [{ number, title, state, merged, draft, head, base, author, html_url }] }
Note: a PR closed without merging and a merged PR both report state='closed' — rely on the 'merged' field.
Inputs: page, repo, limit, owner, +2 more.
forgejo_list_reposList accessible repositoriesARead-onlyIdempotent
Lists the repositories the token can reach, most recently updated first.
Parameters: page, limit, response_format.
Returns: { total, count, page, limit, has_more, repos: [{ full_name, private, fork, default_branch, description, updated_at, html_url }] }
Use it to discover the owner/repo values to pass to the other tools when they are unknown. Errors: 403 if the token lacks the 'read:user' scope.
Inputs: page, limit, response_format.
forgejo_update_issueUpdate an issueADestructiveIdempotent
Changes an existing issue: state, title, body, labels or assignees. Write operation: requires the 'write:issue' scope.
Parameters:
owner, repo (optional when defaults are configured)
number (required)
state ('open' | 'closed', optional): closes or reopens the issue
title (string, optional): replaces the current title
body (string, optional): replaces the current body — this overwrites, it does not append
labels (string[], optional): replaces the full label set; unknown names are skipped and reported
assignees (string[], optional): replaces the full assignee list
At least one changing field is required; omitted fields are left untouched.
Returns: { number, title, state, labels, assignees, html_url, unresolved_labels }
Examples:
"close issue 42" -> number=42, state='closed'
"reopen it and retitle it" -> number=42, state='open', title='…'
To add to a discussion without altering the issue, use forgejo_comment_issue instead. Also accepts a pull request number, but only its issue-side fields change — it cannot merge or close a PR's branch.
Inputs: number (required), body, repo, owner, +5 more.
forgejo_whoamiForgejo token identityARead-onlyIdempotent
Returns the Forgejo account the token used for this call belongs to.
No parameters.
Returns: { id, login, full_name, email }
Use it to confirm a token is valid and which identity writes will be attributed to, before creating an issue or a pull request. Errors: 401 if the token is missing, expired or revoked; 403 if it lacks the 'read:user' scope.
Inputs: response_format.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Each tool targets a distinct resource and action: identity, repos, issues, PRs, branches, commits, and files. Even where issue and PR numbering overlaps, the descriptions clearly separate issue-side from PR-side operations.
The forgejo_ prefix plus verb_noun pattern is consistent across nearly all tools: list_repos, get_issue, create_pull_request, list_commits, get_file. The only minor deviation is forgejo_whoami, which uses a bare verb instead of verb_noun.
13 tools is a well-scoped size for a Forgejo server covering authentication, repositories, issues, pull requests, branches, commits, and file access. Each tool addresses a clear need without redundancy or bloat.
Issue management is well covered with list/get/create/update/comment, and PRs have list/get/create plus branch discovery and file reading. The main gap is the lack of PR update or merge operations, but the core read-and-create workflows agents commonly need are present.
Maintenance
Related MCP Connectors
Operate GitHub from your AI assistant: repos, PRs, issues, Actions. Previews and read-only mode.
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Read and write KukGit repositories, files, issues and pull requests from an AI assistant.
Access the GitHub API, enabling file operations, repository management, search functionality, and…
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables AI assistants to directly operate GitHub repositories, such as listing issues, through the Model Context Protocol.2345 npm2Apache 2.0
- AlicenseBqualityDmaintenanceEnables AI assistants to inspect local Git repositories and interact with the GitHub API for reading commits, diffs, files, issues, comments, pull requests, and project boards.10145 npmISC
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with a Forgejo instance as an authenticated user, supporting issues, pull requests, repositories, and notifications.70 npmMIT
- AlicenseAqualityCmaintenanceEnables AI assistants to search and inspect code repositories, manage issues and pull requests, and analyze user contributions.13MIT