Skip to main content
Glama

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

stdio (local)

the user's own FORGEJO_TOKEN environment variable

http (Railway)

the Authorization header of every request

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 into owner, repo or 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

read:user

forgejo_whoami and the repository list (/user endpoints)

write:issue

creating and commenting on issues

write:repository

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

forgejo_whoami

read

token identity (check before writing)

forgejo_list_repos

read

accessible repositories

forgejo_list_issues

read

issues, filterable by state/labels/text

forgejo_get_issue

read

full issue + comments

forgejo_create_issue

write

open an issue (labels by name)

forgejo_comment_issue

write

comment on an issue or a PR

forgejo_update_issue

write

close, reopen, retitle, rewrite, relabel, reassign

forgejo_list_pull_requests

read

pull requests by state

forgejo_get_pull_request

read

full PR, optional diff

forgejo_create_pull_request

write

open a PR between two branches

forgejo_list_branches

read

branches and protection

forgejo_list_commits

read

a branch's history

forgejo_get_commit_status

read

CI status of a commit, job by job

forgejo_get_file

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 build

The 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.js

Railway deployment (http)

Connect the repository as a Railway service, then set:

Variable

Value

FORGEJO_URL

your instance, e.g. https://forgejo.example.org

TRANSPORT

http

PORT

3000 — and use the same value as the domain's target port

FORGEJO_DEFAULT_OWNER

optional, saves repeating owner on every call

FORGEJO_DEFAULT_REPO

optional, saves repeating repo on every call

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.js

Quick 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.js

Known limitations

  • No PR merging, no reviews, no milestone management: the scope stops at reading, opening, updating and commenting.

  • forgejo_update_issue replaces 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_issue and forgejo_update_issue only 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 tools
forgejo_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 directoryA
Read-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 detailA
Read-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 detailA
Read-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 branchesA
Read-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 commitsA
Read-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 issuesA
Read-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 requestsA
Read-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 repositoriesA
Read-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 issueA
DestructiveIdempotent

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 identityA
Read-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

    A4.4/5.0

    Scored across 13 tools

    Disambiguation5/5

    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.

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      D
      maintenance
      Enables AI assistants to directly operate GitHub repositories, such as listing issues, through the Model Context Protocol.
      2
      345 npm
      2
      Apache 2.0
    • A
      license
      B
      quality
      D
      maintenance
      Enables 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.
      10
      145 npm
      ISC
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to interact with a Forgejo instance as an authenticated user, supporting issues, pull requests, repositories, and notifications.
      70 npm
      MIT