gitea-mcp

v0.5.1
io.github.werebear73/gitea-mcp Checked 1 day ago Published 6 months ago

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

ParameterTypeDescription
owner *stringRepository owner
path *stringPath within the repository, e.g. 'src/gitea_mcp/server.py'
repo *stringRepository name
refBranch 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.

ParameterTypeDescription
new_branch_name *stringName for the new branch (must not already exist)
owner *stringRepository owner
repo *stringRepository name
old_branch_nameExisting 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…

ParameterTypeDescription
branch *stringBranch to commit to (must exist; use create_branch first)
content *stringNew file content (UTF-8 text; binary files not supported)
message *stringCommit message
owner *stringRepository owner
path *stringFile path within the repository, e.g. 'README.md'
repo *stringRepository 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.

ParameterTypeDescription
base *stringTarget branch (where the PR should merge into, e.g. 'main')
head *stringSource branch (the branch containing your changes). Same-repo only; cross-fork PRs not supported by this tool.
owner *stringRepository owner
repo *stringRepository name
title *stringPull request title
bodystringPR description in Markdown
draftbooleanOpen 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.

ParameterTypeDescription
owner *stringRepository owner (user or organization name)
repo *stringRepository name
title *stringIssue title
assigneesUsernames to assign to the new issue
bodystringIssue body in Markdown
labelsLabel names to apply to the new issue (resolved to IDs automatically)
milestoneMilestone 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).

ParameterTypeDescription
owner *stringRepository owner (user or organization name)
repo *stringRepository name
assigneeFilter to issues assigned to this username
labelsComma-separated label names to filter by
limitintegerItems per page (max 50)
pageintegerPage number (1-indexed)
statestringFilter 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.

ParameterTypeDescription
issue_number *integerIssue number (the #N in the URL)
owner *stringRepository owner
repo *stringRepository 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.

ParameterTypeDescription
issue_number *integerIssue number
owner *stringRepository owner
repo *stringRepository name
assigneesReplace assignees with this exact set of usernames
bodyNew body (Markdown)
labelsReplace labels with this exact set (names; pass [] to clear)
milestoneMilestone ID to attach; pass 0 to clear the milestone
stateNew state: 'open' or 'closed'
titleNew title

add_comment

Add a comment to an existing issue. Returns the created Comment object.

ParameterTypeDescription
body *stringComment body (Markdown)
issue_number *integerIssue number
owner *stringRepository owner
repo *stringRepository 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.

ParameterTypeDescription
owner *stringRepository owner (user or organization name)
repo *stringRepository name
limitintegerItems per page (max 50)
pageintegerPage 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``).

ParameterTypeDescription
owner *stringRepository owner
repo *stringRepository name
limitintegerItems per page (max 50)
pageintegerPage number (1-indexed)
sortSort order: 'oldest', 'newest', 'leastupdate', 'mostupdate', 'leastcomment', 'mostcomment', 'priority'. Omit for Gitea's default.
statestringFilter 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.

ParameterTypeDescription
owner *stringRepository owner
pull_number *integerPull request number (the #N in the URL)
repo *stringRepository 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.

ParameterTypeDescription
body *stringComment body (Markdown)
owner *stringRepository owner
pull_number *integerPull request number
repo *stringRepository 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.

ParameterTypeDescription
owner *stringRepository owner
pull_number *integerPull request number
repo *stringRepository name
dostringMerge strategy: 'merge', 'rebase', 'rebase-merge', or 'squash'.
merge_message_fieldOptional merge commit message body. Ignored by strategies that do not create a merge commit.
merge_title_fieldOptional 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.

ParameterTypeDescription
owner *stringRepository owner
repo *stringRepository name
limitintegerItems per page (max 50)
pageintegerPage 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.

ParameterTypeDescription
name *stringRelease title
owner *stringRepository owner
repo *stringRepository name
tag_name *stringTag this release is based on. If the tag does not already exist in the repository, Gitea creates it at the time of release.
bodystringRelease notes in Markdown
draftbooleanSave as draft without publishing
prereleasebooleanMark as a pre-release
target_commitishBranch 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).

ParameterTypeDescription
limitintegerItems per page (max 50)
ownerUsername or organization to list repos for. Leave empty to list repositories accessible to the authenticated user.
pageintegerPage 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.

ParameterTypeDescription
owner *stringRepository owner
repo *stringRepository name
limitintegerItems per page (max 50)
pageintegerPage number (1-indexed)

list_milestones

List milestones in a repository, optionally filtered by state.

ParameterTypeDescription
owner *stringRepository owner
repo *stringRepository name
limitintegerItems per page (max 50)
pageintegerPage number (1-indexed)
statestringFilter 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…