Skip to main content
Glama
forgejo-readonly-mcp
by aiekick

forgejo-readonly-mcp

A read-only MCP server for Forgejo. It lets an MCP client read the state of repositories and of Forgejo Actions: runs, jobs, statuses and logs. It cannot write anything, by design.

The read-only contract

Three independent locks, each enough on its own:

  1. The client only speaks GET. ReadOnlyClient has a single network method, and it builds GET requests only. No tool can send another verb.

  2. The tool list is closed. There is no "call any endpoint" tool. Each tool assembles its own path from validated segments under /api/v1. An owner, repo or path component with /, .. or any character outside [A-Za-z0-9_.-] is refused by name.

  3. The token only carries read scopes. Even a bug in this code would be refused by Forgejo.

Two further guards:

  • A redirect to another origin is refused, because urllib would forward the token with it.

  • A plain http:// URL is refused unless FORGEJO_ALLOW_HTTP=1 is set.

Left out on purpose: runners and their registration tokens, secrets, variables, artifacts, and the run-wide log zip.

Related MCP server: GitHub MCP

Tools

Tool

Reads

repo_info

default branch, visibility, counters

list_branches, list_tags

refs with their head commit

list_commits

commits on a ref, optionally touching a path

get_commit

full message, parents, stats, changed files

commit_status

combined CI status of a commit and each check

list_dir, read_file

the tree and files at a ref

list_runs

Actions runs, filtered by status, event, ref, sha, workflow

get_run, list_jobs

one run and its jobs

job_logs

a job log: tail (200 by default), head, or grep with context

Token

In Forgejo, go to Settings, then Applications, then Generate new token. Give it read:repository only (add read:organization if you read organization repositories you are not a member of).

Install

python3 -m venv .venv
.venv/bin/pip install -e .

Register in Claude Code

Keep the token in a file only its owner reads, and point the server at it. Passing it with -e FORGEJO_TOKEN=... would copy it in clear into ~/.claude.json.

install -m 600 /dev/null ~/.config/forgejo-readonly-mcp/token   # then paste the token in it
claude mcp add forgejo \
  -e FORGEJO_URL=https://forge.example.com \
  -e FORGEJO_TOKEN_FILE=$HOME/.config/forgejo-readonly-mcp/token \
  -- /path/to/forgejo-readonly-mcp/.venv/bin/forgejo-readonly-mcp

FORGEJO_TOKEN still works for hosts without a file; setting both is refused.

Optional: FORGEJO_ALLOWED_REPOS=owner/repo,owner/other restricts the server to those repositories. Any other repository is refused by name.

Tests

The tests run against a local fake server and never reach a real forge:

.venv/bin/python -m unittest discover -s tests

License

MIT, see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables self-hosted, read-only remote interaction with GitHub repositories, allowing listing repositories, searching code, and inspecting commits, pull requests, issues, and diffs via authenticated MCP clients.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables MCP clients to read a Forgejo, Codeberg, or Gitea instance—including users, repositories, issues, pull requests, search, notifications, comments, reviews, and Actions runs—with opt-in, time-boxed guarded writes for repository, branch, issue, pull request, comment, migration, push-mirror, and workflow operations.
      59
      2
      MIT