Codeberg MCP server
Commit Nov 13, 2026Enables AI clients to manage repositories, pull requests, issues, and CI actions on Codeberg, Gitea, or Forgejo instances with multi-account support.
Also known as effecet/codeberg-mcp
- Stars
- 0
- Tools
- —
- Downloads, 30 days
- —
- Latest version
- —
- Last commit
- Nov 13, 2026
- License
- MIT
What is Codeberg MCP?
Codeberg enables AI clients to manage repositories, pull requests, issues, and CI actions on Codeberg, Gitea, or Forgejo instances with multi-account support.
Summary generated from the project's README
About Codeberg MCP server
Managing repositories, pull requests, and CI actions on Codeberg, Gitea, or Forgejo is what this server enables for developers using AI clients. It provides 51 specialized tools to handle everything from file manipulation and issue tracking to managing releases and repository settings. By wrapping the REST API, it allows an agent to interact with your code hosting platform through a structured interface.
Users can configure the server using a JSON map of account names to tokens via the CODEBERG_ACCOUNTS environment variable. This multi-account support allows you to switch between personal and organizational identities by simply passing an account parameter to a tool. The server supports Claude Code through stdio transport and can be used with claude.ai custom connectors via HTTP or SSE transports.
A key feature is the consistent error contract that returns predictable JSON objects when an API call fails. This helps the AI agent understand specific issues like invalid merge methods or unknown accounts instead of crashing. It also includes specialized tools like wait_for_runs, which allows an agent to monitor CI progress for up to 30 minutes without manual sleep loops.
What you can do with it
- 1Automate CI workflow monitoringAsk the AI to wait for a specific commit's CI actions to finish and report the results.
- 2Manage multiple developer identitiesInstruct the agent to perform tasks using a specific organizational account instead of your default one.
- 3Debug failed build logsHave the AI retrieve and analyze the specific sections of a workflow log where a failure occurred.
- 4Handle pull request mergesDirect the AI to merge a pull request with a custom commit message.
Written from the project's README. Every use case is checked against a quote from it.
Configuration
MCP_TRANSPORT
| Name | Description | |
|---|---|---|
| MCP_TRANSPORT | — |
README
View on GitHubcodeberg-mcp
An MCP server for Codeberg (and any Gitea/Forgejo instance) exposing 51 tools for repos, files, pull requests, branches, commits, issues, releases, tags, Actions, and repo/account settings — with multi-account support and a consistent structured error contract.
Works with Claude Code (stdio transport) and claude.ai custom connectors (streamable-HTTP / SSE transport).
Why
The official tooling around Forgejo/Gitea is thin, and switching between several
accounts (e.g. a personal account and an org) usually means juggling tokens by
hand. This server wraps the REST API behind typed MCP tools, routes each call to
the right account via a single account parameter, and turns API failures into
a predictable {"error": ..., "status": ...} shape so the agent can reason about
them instead of crashing.
Architecture
flowchart LR
Agent[MCP client<br/>Claude Code / claude.ai]
Server[codeberg-mcp<br/>MCPServer server.py]
Accounts[(CODEBERG_ACCOUNTS<br/>name -> token)]
API[(Codeberg / Forgejo<br/>Gitea REST API v1)]
Agent -- "tool call (+optional account)" --> Server
Server -- "resolve account -> token" --> Accounts
Server -- "authenticated request" --> API
API -- "JSON or {error,status}" --> Server
Server -- "structured result" --> Agent
Install
git clone https://github.com/effecet/codeberg-mcp.git
cd codeberg-mcp
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # then edit .env (see Configuration)
Configuration
All config is via environment variables (loaded from .env):
| Variable | Required | Description |
|---|---|---|
CODEBERG_ACCOUNTS |
yes | JSON {name: token} map. Generate tokens at https://codeberg.org/user/settings/applications. |
CODEBERG_DEFAULT_ACCOUNT |
no | Account used when a tool omits account. Defaults to the first key. |
MCP_TRANSPORT |
no | stdio | http (default) | sse. |
HOST / PORT |
no | Bind address for http/sse (default 0.0.0.0:8000). |
Token scopes depend on which tools you use: read/write:repository,
read/write:issue, read:user. A token missing a scope returns a clean 403
through the error contract rather than crashing.
Usage
Claude Code (stdio)
Add to your MCP config (e.g. ~/.claude/.mcp.json):
{
"mcpServers": {
"codeberg": {
"command": "python",
"args": ["/path/to/codeberg-mcp/server.py"],
"env": { "MCP_TRANSPORT": "stdio" }
}
}
}
(CODEBERG_ACCOUNTS can live in the repo's .env or be passed in env.)
claude.ai custom connector (HTTP)
MCP_TRANSPORT=http PORT=8000 python server.py
# exposes streamable-HTTP on http://0.0.0.0:8000
Tools (51)
| Group | Tools |
|---|---|
| Repos | list_repos, get_repo, create_repo, edit_repo, set_repo_actions_enabled |
| Files | get_file, create_file, update_file, delete_file, list_dir |
| Pull requests | list_pulls, get_pull, create_pull, merge_pull, list_pull_files, list_pull_commits, list_pull_reviews |
| Branches / commits | list_branches, create_branch, get_latest_commit, compare_refs |
| Issues | list_issues, get_issue, create_issue, edit_issue, comment_on_issue, list_issue_labels, add_issue_labels, remove_issue_label |
| Releases / tags | list_releases, get_release, get_release_by_tag, create_release, edit_release, list_tags, get_tag |
| Actions | list_workflow_runs, get_workflow_run, wait_for_runs, get_workflow_logs, cancel_workflow_run, rerun_workflow_run, list_runners, list_queued_jobs, list_actions_variables, get_actions_variable, create_actions_variable, update_actions_variable |
| Account / secrets | list_user_keys, list_user_emails, list_repo_secrets |
Every tool accepts an optional account parameter to pick which configured
account (token) to use.
wait_for_runs blocks until every Actions run for a commit has finished (up
to 30 minutes per call) and reports MCP progress while it waits, when the
client asks for it, so an agent can wait for CI without hand-rolled sleep
loops. get_workflow_logs returns one section per job, keeping the end of
each log, where the failure usually is. cancel_workflow_run and
rerun_workflow_run call endpoints that codeberg.org does not register (they
return 404 there); they work only on Forgejo/Gitea instances that expose them.
Error contract
On any API failure a tool returns, instead of its normal result:
{"error": "Codeberg API <status>: <detail>", "status": <int|null>}
Treat any result with top-level error and status keys as a failure. Tools
that normally return a list or text (or nothing) cannot return that object, so
they report an error result (isError: true) whose text is
Error executing tool <name>: followed by the same JSON.
Caller mistakes the caller can fix (unknown account, a directory passed to
get_file, an invalid merge method) come back as an error result with the
guidance as text. Any other failure inside a tool is a bug, and the client sees
only Error executing tool <name>.
status is null when there is no definite answer: a timeout, a refused or
dropped connection, a body that cannot be read, or a 502/503/504 from
Codeberg's gateway (which has applied writes before failing the response). A
write may still have landed, so check state before retrying.
create_pull and merge_pull do that check themselves. When the response is
lost they re-read the real state (open PRs for head→base; the PR's merged
flag, re-read over a few seconds because it lags), and if the PR or merge is
there they return success with recovered_after_read_error: true and the
original error in read_error. Do not retry those. If the re-check cannot
settle it, the result is still status: null. merge_pull also accepts
merge_title and merge_message for the merge or squash commit.
Development
pip install -r requirements.txt
pytest -q # 165 tests (respx-mocked, no network)
ruff check .
ruff format --check .
CI runs ruff + pytest on GitHub Actions (.github/workflows/ci.yml).
License
MIT — see LICENSE. crafted by effece 🧉
Codeberg MCP questions
Can I use multiple accounts at once?
Yes, the server supports multi-account functionality by routing calls to specific accounts via an account parameter.
How does the server handle API errors?
It uses a consistent structured error contract that returns a JSON object containing the error detail and status code, allowing the agent to reason about failures.
What kind of tools are provided?
It provides 51 tools covering repositories, files, pull requests, branches, commits, issues, releases, tags, and Actions.