gitea-mcp
v0.5.1Model Context Protocol server for Gitea (and Forgejo, Codeberg).
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
read_file
Read a file's content from a Gitea repository. Returns Gitea's ``ContentsResponse`` shape extended with a ``text`` field containing the decoded file content as a UTF-8 string (or ``None`` if the content isn't valid UTF-8 — binary file). The raw base64 ``content`` and Gitea's ``encoding`` are preserved so callers can re-decode if needed. The ``sha`` field in the response is what :func:`commit_changes` would need to update this file — but ``commit_changes`` fetches it internally, so callers don't usually need to pass it forward.
| Parameter | Type | Description |
|---|---|---|
owner * | string | Repository owner |
path * | string | Path within the repository, e.g. 'src/gitea_mcp/server.py' |
repo * | string | Repository name |
ref | Branch name, tag name, or commit SHA to read from. Omit to read from the repository's default branch. |
create_branch
Create a new branch in a repository. Returns the created Gitea Branch object. Fails cleanly via :class:`GiteaAPIError` if the new branch name already exists.
| Parameter | Type | Description |
|---|---|---|
new_branch_name * | string | Name for the new branch (must not already exist) |
owner * | string | Repository owner |
repo * | string | Repository name |
old_branch_name | Existing branch to fork from. Omit to use the repository's default branch. |
commit_changes
Create or update a single file on a branch in one commit. Auto-detects whether the file exists: - **File does not exist on the branch:** Gitea returns 404 to the SHA lookup; we ``POST`` to create the file. - **File exists:** we use its current SHA and ``PUT`` to update it. Returns Gitea's ``FileResponse`` shape (the resulting commit + content metadata). Raises :class:`GiteaAPIError` on conflicts (e.g. concurrent update changed the SHA between our lookup and our write — caller should re-read and retry). Single-file only. Multi-file commits would require Gitea's Git Trees API and are del…
| Parameter | Type | Description |
|---|---|---|
branch * | string | Branch to commit to (must exist; use create_branch first) |
content * | string | New file content (UTF-8 text; binary files not supported) |
message * | string | Commit message |
owner * | string | Repository owner |
path * | string | File path within the repository, e.g. 'README.md' |
repo * | string | Repository name |
create_pr
Open a new pull request from ``head`` into ``base``. Returns the created Gitea PullRequest object (including the assigned number, URL, and merge status). Raises :class:`GiteaAPIError` if the head branch doesn't exist, there are no commits between head and base, or an open PR already exists for this branch pair.
| Parameter | Type | Description |
|---|---|---|
base * | string | Target branch (where the PR should merge into, e.g. 'main') |
head * | string | Source branch (the branch containing your changes). Same-repo only; cross-fork PRs not supported by this tool. |
owner * | string | Repository owner |
repo * | string | Repository name |
title * | string | Pull request title |
body | string | PR description in Markdown |
draft | boolean | Open as a draft PR (cannot be merged until marked ready) |
create_issue
Create a new issue in a Gitea repository. Returns the full Gitea Issue object including the assigned number, URL, and metadata. Label names are resolved to IDs against the repository's label set; an unknown label name fails the call cleanly with the list of valid names.
| Parameter | Type | Description |
|---|---|---|
owner * | string | Repository owner (user or organization name) |
repo * | string | Repository name |
title * | string | Issue title |
assignees | Usernames to assign to the new issue | |
body | string | Issue body in Markdown |
labels | Label names to apply to the new issue (resolved to IDs automatically) | |
milestone | Milestone ID to attach |
list_issues
List issues in a Gitea repository. Pull requests are excluded; only true issues are returned. Filters compose (state AND labels AND assignee).
| Parameter | Type | Description |
|---|---|---|
owner * | string | Repository owner (user or organization name) |
repo * | string | Repository name |
assignee | Filter to issues assigned to this username | |
labels | Comma-separated label names to filter by | |
limit | integer | Items per page (max 50) |
page | integer | Page number (1-indexed) |
state | string | Filter by state: 'open', 'closed', or 'all' |
get_issue
Get a single issue by number, including all of its comments. The returned object is the standard Gitea Issue payload, with an additional ``comments_list`` field containing the full list of Comment objects. The existing top-level ``comments`` integer field (comment count) is preserved.
| Parameter | Type | Description |
|---|---|---|
issue_number * | integer | Issue number (the #N in the URL) |
owner * | string | Repository owner |
repo * | string | Repository name |
update_issue
Update an existing issue's title, body, state, assignees, milestone, or labels. Each argument is independent — pass only the fields you want to change. Labels are replaced atomically against the new set (passing ``[]`` removes all labels). Other list fields (assignees) follow the same replace semantics.
| Parameter | Type | Description |
|---|---|---|
issue_number * | integer | Issue number |
owner * | string | Repository owner |
repo * | string | Repository name |
assignees | Replace assignees with this exact set of usernames | |
body | New body (Markdown) | |
labels | Replace labels with this exact set (names; pass [] to clear) | |
milestone | Milestone ID to attach; pass 0 to clear the milestone | |
state | New state: 'open' or 'closed' | |
title | New title |
add_comment
Add a comment to an existing issue. Returns the created Comment object.
| Parameter | Type | Description |
|---|---|---|
body * | string | Comment body (Markdown) |
issue_number * | integer | Issue number |
owner * | string | Repository owner |
repo * | string | Repository name |
list_branches
List branches in a repository. Returns the standard Gitea Branch object array: ``[{name, commit: {id, ...}, protected, ...}]``. Useful for inspecting available targets before creating a release, opening a PR, or filing a fix against a specific branch.
| Parameter | Type | Description |
|---|---|---|
owner * | string | Repository owner (user or organization name) |
repo * | string | Repository name |
limit | integer | Items per page (max 50) |
page | integer | Page number (1-indexed) |
list_pull_requests
List pull requests in a repository, optionally filtered by state. Returns Gitea PullRequest objects (not Issue-style — the PR endpoint returns richer head/base/mergeable info than the issues endpoint does even when issues are filtered to ``type=pulls``).
| Parameter | Type | Description |
|---|---|---|
owner * | string | Repository owner |
repo * | string | Repository name |
limit | integer | Items per page (max 50) |
page | integer | Page number (1-indexed) |
sort | Sort order: 'oldest', 'newest', 'leastupdate', 'mostupdate', 'leastcomment', 'mostcomment', 'priority'. Omit for Gitea's default. | |
state | string | Filter by state: 'open', 'closed', or 'all' |
get_pull_request
Get a single pull request by number, including its discussion comments. Mirrors :func:`gitea_mcp.tools.issues.get_issue`'s shape: returns the full Gitea PullRequest object with an additional ``comments_list`` field containing the issue-style comment thread. Inline review comments (those attached to specific diff lines) are NOT included — those live under ``/pulls/{n}/reviews`` and are out of scope for this tool.
| Parameter | Type | Description |
|---|---|---|
owner * | string | Repository owner |
pull_number * | integer | Pull request number (the #N in the URL) |
repo * | string | Repository name |
add_comment_on_pr
Add a comment to a pull request's discussion thread. Posts to ``/repos/{owner}/{repo}/issues/{pull_number}/comments`` — Gitea's issue-comments endpoint also serves PR conversation comments (PRs and issues share the number namespace and comment infrastructure). For inline diff-line review comments, a separate ``/pulls/{n}/reviews``-based tool would be needed; that's deliberately out of scope here.
| Parameter | Type | Description |
|---|---|---|
body * | string | Comment body (Markdown) |
owner * | string | Repository owner |
pull_number * | integer | Pull request number |
repo * | string | Repository name |
merge_pr
Merge a pull request. Calls ``POST /repos/{owner}/{repo}/pulls/{pull_number}/merge`` using the requested merge strategy and optional commit-message overrides. This is tagged ``destructiveHint=True`` because it changes repository history and closes the pull request.
| Parameter | Type | Description |
|---|---|---|
owner * | string | Repository owner |
pull_number * | integer | Pull request number |
repo * | string | Repository name |
do | string | Merge strategy: 'merge', 'rebase', 'rebase-merge', or 'squash'. |
merge_message_field | Optional merge commit message body. Ignored by strategies that do not create a merge commit. | |
merge_title_field | Optional merge commit title. Ignored by strategies that do not create a merge commit. |
list_releases
List releases for a repository. Returns the standard Gitea Release object array, including drafts and pre-releases. Sort order is newest first.
| Parameter | Type | Description |
|---|---|---|
owner * | string | Repository owner |
repo * | string | Repository name |
limit | integer | Items per page (max 50) |
page | integer | Page number (1-indexed) |
create_release
Create a new release in a repository. .. warning:: Side effects: if ``tag_name`` does not already exist in the repository, Gitea creates the tag at the current ``target_commitish`` (or default branch). Creating a draft does NOT skip tag creation — both drafts and published releases will leave a tag in the repo.
| Parameter | Type | Description |
|---|---|---|
name * | string | Release title |
owner * | string | Repository owner |
repo * | string | Repository name |
tag_name * | string | Tag this release is based on. If the tag does not already exist in the repository, Gitea creates it at the time of release. |
body | string | Release notes in Markdown |
draft | boolean | Save as draft without publishing |
prerelease | boolean | Mark as a pre-release |
target_commitish | Branch name or commit SHA the tag should point at. Defaults to the repository's default branch. Ignored if the tag already exists. |
list_repos
List repositories. Three modes: - ``owner`` empty: returns repositories accessible to the authenticated user (``GET /user/repos``). - ``owner`` is a user: returns that user's repositories (``GET /users/{owner}/repos``). - ``owner`` is an organization: returns that org's repositories (``GET /orgs/{owner}/repos`` — automatically tried as a fallback when the user endpoint 404s, so callers don't need to know which it is).
| Parameter | Type | Description |
|---|---|---|
limit | integer | Items per page (max 50) |
owner | Username or organization to list repos for. Leave empty to list repositories accessible to the authenticated user. | |
page | integer | Page number (1-indexed) |
list_labels
List labels defined in a repository. Returns the standard Gitea Label object: ``{id, name, color, description, ...}``. Use the ``id`` values when calling tools that take ``label_ids`` directly; most tools accept label *names* and resolve to IDs internally.
| Parameter | Type | Description |
|---|---|---|
owner * | string | Repository owner |
repo * | string | Repository name |
limit | integer | Items per page (max 50) |
page | integer | Page number (1-indexed) |
list_milestones
List milestones in a repository, optionally filtered by state.
| Parameter | Type | Description |
|---|---|---|
owner * | string | Repository owner |
repo * | string | Repository name |
limit | integer | Items per page (max 50) |
page | integer | Page number (1-indexed) |
state | string | Filter by state: 'open', 'closed', or 'all' |
get_server_version
Return the running gitea-mcp server's version. No network call — just reports the package version. ``openWorldHint`` is ``False`` for this tool only, since it doesn't touch the Gitea instance or any external system.
get_server_info
Return information about the running gitea-mcp server and its Gitea connection. Performs two Gitea API calls — ``GET /user`` (to identify the authenticated user the PAT belongs to) and ``GET /version`` (to report the Gitea instance version). If ``/version`` is unavailable (older Gitea, or the PAT lacks the scope), ``gitea_version`` falls back to ``None`` rather than raising. Returns a dict with: * ``gitea_mcp_version`` — the gitea-mcp package version (e.g. ``"0.4.1"``). * ``gitea_url`` — the Gitea base URL this server is configured against. * ``gitea_user`` — the ``login`` of the au…