5.1 KiB
topic, source_keys
| topic | source_keys | ||
|---|---|---|---|
| data-model |
|
Gitea Data Model
How issues, PRs, labels, milestones, and branches relate to each other — and the representation quirks that affect how you call tools.
Issues and PRs share a number space
Issues and pull requests are the same entity type in Gitea's data model. They share a single sequential counter per repository: if issue #3 exists, there cannot be a PR #3 in the same repo. The list_issues tool returns both unless you pass type: "issues" or type: "pulls" to filter. A single-item issue_read response includes is_pull: true when the issue is backed by a pull request.
This matters for cross-linking: when you refer to #5, it might be either an issue or a PR. Use issue_read method: "get" and check is_pull to determine the type before deciding how to handle it.
Label identity: names vs IDs
Labels have two identifiers that appear in different contexts:
- Name (string) — what appears in
issue_readandlist_issuesresponses;labels: ["bug", "wontfix"] - ID (number) — what
issue_writerequires when applying labels;labels: [3, 7]
This mismatch is the single most common source of errors when managing labels. The MCP server slims label data in issue/PR responses to name-only strings. To apply labels to an issue or PR, you must first call label_read method: "list_repo_labels" to get the full label list (including IDs), then extract the IDs for the labels you want to apply.
The only tool that returns full label objects (including ID, color, description) is label_read.
Milestone references
Milestones are repo-scoped and have both an ID and a sequential number within the repo. The tools use the numeric ID for all references:
issue_writetakesmilestone: <id>(not a title, not a number)milestone_read method: "get"takesid: <id>
Milestone representations differ between issue and PR responses:
- In
issue_readresponses:milestone: {id, title}— an object with both fields - In
pull_request_readresponses:milestone: "title string"— the title only, no ID
This inconsistency means you cannot extract a milestone's ID from a PR response. To get the milestone ID from a PR, you must look up milestones via milestone_read method: "list" and match by title.
Label scope: repo vs org
Labels exist at two scopes:
- Repo labels — the default; scoped to a single repository; managed via
label_read/writewithowner+repo - Org labels — scoped to an organization; shared across repos in the org; managed via
label_read/writewithorg
Org labels have an additional exclusive boolean. When exclusive: true, applying one label in an exclusive group removes all other exclusive labels from the same group on the issue. This is Gitea's equivalent of a single-select category field.
When listing labels for labeling purposes, repo labels and org labels are listed separately. Issues in a repo can carry both.
PR branches and cross-repo forks
For a PR within the same repository, head is just a branch name. For cross-repo PRs (from a fork), head uses the format owner:branch.
In pull_request_write method: "create":
head— the source (feature branch or fork branch)base— the merge target (usuallymainormaster)
In pull_request_read method: "get" responses, head and base are full objects: {ref, sha, repo: {full_name, description}}. In list_pull_requests responses, they are bare ref strings.
File SHA requirement
File operations in Gitea use SHA-based optimistic concurrency. To update or delete an existing file, you must provide the file's current sha — a content-addressed identifier returned by get_file_contents. Without it:
create_or_update_filewithoutshais treated as a create; Gitea returns 409 if the file existsdelete_filewithoutshareturns a validation error
The workflow is always: get_file_contents → extract sha → pass to create_or_update_file or delete_file.
Commit association on issues
Issues optionally carry a ref field — a branch name that associates the issue with ongoing work. This is set via issue_write method: "create" or "update" with the ref parameter. It is informational only; it does not create a branch or affect PR linking.
PR review states
PR reviews move through a state machine:
- Create a review in
"PENDING"state (drafting inline comments) - Submit the review with a state:
"APPROVED","REQUEST_CHANGES", or"COMMENT" - A submitted review can be dismissed (not deleted)
The stale boolean on a review indicates the PR was pushed to after the review was submitted, making the review potentially outdated.
Pagination and truncation
Repository tree (get_repository_tree) returns a truncated: bool field alongside total_count. When truncated is true, not all tree entries fit in one response — use page + per_page to paginate.
All list endpoints use cursor-less offset pagination (page integer). There is no next_cursor or Link header exposed through the MCP tools — iterate by incrementing page until you get fewer results than per_page.