Adds the spec-driven change artifacts for exposing Forgejo organization labels through the MCP server: - proposal: motivation, capabilities, impact - design: decisions, trade-offs, impl approach via DoJSONList - specs: new list_org_labels capability + modified list_repo_labels with include_org_labels merge and scope tagging - tasks: 5-group breakdown covering helper, new tool, augmentation, docs, and verification Tracked as forgejo-mcp-7ch (blocked by forgejo-mcp-xv0 OpenSpec). Closes forgejo-mcp-xv0.
2.6 KiB
2.6 KiB
Why
list_repo_labels only returns repo-scoped labels (/repos/{owner}/{repo}/labels). Forgejo also supports organization-level labels (/orgs/{org}/labels) which can be applied to issues in any repo owned by that org. The MCP exposes none of them, so an AI agent has no way to discover org-label IDs needed by add_issue_labels and cannot distinguish org-labels already attached to issues. Reported as Codeberg issue #125 by enbyted.
The Forgejo SDK (forgejo-sdk/forgejo/v3@v3.0.0) does not bind the org-label endpoint, but the project already has a raw-HTTP helper (pkg/forgejo.DoJSONList) used for similar SDK gaps (attachments). No SDK upgrade is required.
What Changes
- Add
list_org_labelsMCP tool — returns all org-level labels for a given organization with their names and numeric IDs. - Augment
list_repo_labelswith aninclude_org_labelsboolean parameter (defaulttrue). When the repo owner is an organization and the flag is on, the tool merges org labels into the repo label result. - Each label entry returned by
list_repo_labels(with merge enabled) is annotated with ascopefield of"repo"or"org"so callers can disambiguate IDs that may overlap by name. - Use
pkg/forgejo.DoJSONListfor both endpoints — no new SDK dependency. 404 from the org endpoint maps to an empty list (helper already handles this).
Capabilities
New Capabilities
list_org_labels: discover org-level label names → IDs for use withadd_issue_labelson any repo owned by the organization.
Modified Capabilities
list_repo_labels: gains optionalinclude_org_labelsparameter andscopefield on each returned label. The capability spec is introduced by the in-flightlist-milestones-labelschange; this change layers on top once that lands.
Impact
- Code:
operation/issue/issue.go— newListOrgLabelsTooldefinition + handler + registration; modifiedListRepoLabelsFnto optionally merge org labels and stampscope. Possibly a small response-shape helper if scope tagging needs a wrapper type. - APIs: One additional GET per
list_repo_labelscall when merge is enabled and the owner is an org. Standalonelist_org_labelsis a single GET. - Dependencies: None added. Reuses
pkg/forgejo.DoJSONList. - Order: Depends on
list-milestones-labelschange archiving first so thelist_repo_labelscapability spec exists. If that has not landed, thelist_repo_labelsmodified-capability delta in this change is held back, butlist_org_labels(new capability) ships independently. - Risk: Low. Read-only, additive. One extra HTTP call per merged listing.