Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Users connect with their own scoped Forgejo personal access tokens (PATs). Admin

## What it provides

- 39 tools for repositories, organization repository creation, git trees, branches, commits, labels, milestones, Issues, pull requests, reviews, workflows, tags and releases.
- 47 tools for repositories, organization repository creation, git trees, branches, commits, labels, milestones, Issues, pull requests, reviews, Actions runs, jobs, logs and artifacts, tags and releases.
- Global, user and token-level tool authorization in addition to Forgejo's own permissions.
- Per-user Forgejo identity through a verified, scoped PAT.
- AES-256-GCM encryption for stored PATs and show-once MCP tokens.
Expand Down
2 changes: 1 addition & 1 deletion README.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Forgejo MCP 是一套自架的 [Model Context Protocol](https://modelcontextprot

## 能做什麼

- 提供 39 個工具,涵蓋 repository、組織 repository 建立、git tree、branch、commit、label、milestone、Issue、pull request、review、workflow、tag 與 release。
- 提供 47 個工具,涵蓋 repository、組織 repository 建立、git tree、branch、commit、label、milestone、Issue、pull request、review、Actions run、job、log、artifact、tag 與 release。
- 在 Forgejo 原有權限之外,增加全域、使用者與 token 三層工具授權。
- 使用者透過已驗證且限制權限範圍的 Forgejo PAT,以自己的 Forgejo 身分操作。
- 使用 AES-256-GCM 加密儲存 PAT,MCP token 只顯示一次。
Expand Down
2 changes: 1 addition & 1 deletion docs/admin-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ v0.1.0 is contract-tested against Forgejo `16.0.2+gitea-1.22.0`. See [Known limi

## 3. Configure global tools

Review the 39-tool catalog and enable only the tools the organization intends to expose. Global disable is the top-level kill switch: a disabled tool is unavailable to every user and token.
Review the 47-tool catalog and enable only the tools the organization intends to expose. Global disable is the top-level kill switch: a disabled tool is unavailable to every user and token.

Suggested rollout policy:

Expand Down
2 changes: 1 addition & 1 deletion docs/admin-guide.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ v0.1.0 已依 Forgejo `16.0.2+gitea-1.22.0` contract 測試。連接其他版本

## 3. 設定全域工具

檢查 39 個工具,並只啟用組織預計提供的工具。Global disable 是最高層的 kill switch:停用後,所有使用者與 token 都無法使用該工具。
檢查 47 個工具,並只啟用組織預計提供的工具。Global disable 是最高層的 kill switch:停用後,所有使用者與 token 都無法使用該工具。

建議逐步開放:

Expand Down
2 changes: 1 addition & 1 deletion docs/known-limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ v0.1.0 is the initial open-source release. It provides the complete Forgejo deve

## Tool scope

- The catalog contains 39 workflow-oriented tools; it is not a one-to-one wrapper for every Forgejo API endpoint.
- The catalog contains 47 workflow-oriented tools; it is not a one-to-one wrapper for every Forgejo API endpoint.
- Repository creation is limited to existing organizations and remains subject to the stored PAT's Forgejo permissions.
- Organization administration, repository deletion, user administration inside Forgejo, SSH key management, package administration and arbitrary API passthrough are intentionally excluded.
- Workflow dispatch requires Forgejo Actions and an existing workflow file in the target repository.
Expand Down
2 changes: 1 addition & 1 deletion docs/known-limitations.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ v0.1.0 是第一個開源版本,已提供完整 Forgejo 開發流程與核心

## 工具範圍

- 目前包含 39 個以 workflow 為導向的工具,不是一對一包裝所有 Forgejo API endpoints。
- 目前包含 47 個以 workflow 為導向的工具,不是一對一包裝所有 Forgejo API endpoints。
- Repository 建立僅支援既有組織,並受儲存的 PAT 在 Forgejo 中實際權限限制。
- Organization administration、repository deletion、Forgejo user administration、SSH key management、package administration 與 arbitrary API passthrough 明確排除。
- Workflow dispatch 需要 Forgejo Actions,以及 target repository 中既有的 workflow file。
Expand Down
21 changes: 15 additions & 6 deletions docs/tools/v1-tool-catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

本文件是 Forgejo MCP **v1.0 工具功能、公開名稱及 schema 邊界的規範文件**。實作、測試、Dashboard 權限顯示與相容性判斷均以本文件為準。

> 狀態:39 個 v1 工具已實作。公開 tool name 與已發布 schema 視為 SemVer public API。
> 狀態:47 個 v1 工具已實作。公開 tool name 與已發布 schema 視為 SemVer public API。

## 1. v1 範圍

v1 提供 24 個唯讀工具及 15 個寫入工具,共 39 個。平台不提供任意 HTTP request、任意 URL 或通用 Forgejo API proxy;每個工具都必須對應 Forgejo v16-compatible OpenAPI endpoint。
v1 提供 30 個唯讀工具及 17 個寫入工具,共 47 個。平台不提供任意 HTTP request、任意 URL 或通用 Forgejo API proxy;每個工具都必須對應 Forgejo v16-compatible OpenAPI endpoint。

| 批次 | 功能 | Tools | 狀態 |
|---|---|---:|---|
Expand All @@ -18,6 +18,7 @@ v1 提供 24 個唯讀工具及 15 個寫入工具,共 39 個。平台不提
| 5 | File content 與 multi-file commit | 2 | 已完成 |
| 6 | Workflow dispatch、tag 與 release | 3 | 已完成 |
| 7 | Git tree、label、milestone 與 PR 查詢補強 | 6 read | 已完成 |
| 8 | Actions run、job、log、artifact、cancel 與 delete | 6 read + 2 write | 已完成 |

## 2. 共通契約

Expand Down Expand Up @@ -475,16 +476,24 @@ Forgejo v16 compare response 不提供可靠的 ahead/behind 或 resolved base/h

Review event 限定 `APPROVED`、`REQUEST_CHANGES` 或 `COMMENT`,可包含最多 100 個 inline comments。Merge 支援 Forgejo OpenAPI 宣告的 merge、squash、rebase、rebase-merge 與 manually-merged strategy。

### 5.8 Commit status、workflow、tag 與 release
### 5.8 Commit status、Actions、tag 與 release

| Tool | Forgejo endpoint |
|---|---|
| `forgejo_get_commit_status` | `GET /repos/{owner}/{repo}/commits/{ref}/status` |
| `forgejo_list_action_runs` | `GET /repos/{owner}/{repo}/actions/runs` |
| `forgejo_get_action_run` | `GET /repos/{owner}/{repo}/actions/runs/{run_id}` |
| `forgejo_list_action_run_jobs` | `GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs` |
| `forgejo_get_action_job_log` | `GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs` |
| `forgejo_get_action_run_logs` | `GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs` |
| `forgejo_list_action_run_artifacts` | `GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts` |
| `forgejo_cancel_action_run` | `POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel` |
| `forgejo_delete_action_run` | `DELETE /repos/{owner}/{repo}/actions/runs/{run_id}` |
| `forgejo_dispatch_workflow` | `POST /repos/{owner}/{repo}/actions/workflows/{workflow}/dispatches` |
| `forgejo_create_tag` | `POST /repos/{owner}/{repo}/tags` |
| `forgejo_create_release` | `POST /repos/{owner}/{repo}/releases` |

Workflow 工具只提供 Forgejo v16-compatible OpenAPI 已確認的 `workflow_dispatch`;run、job、log 與 rerun 工具須在最低支援版本 Swagger 確認後才能新增
Run 與 artifact 清單皆有界;job 清單最多回傳 100 筆。Job log 最多回傳 1 MiB UTF-8 文字並提供原始大小、SHA-256 與 `truncated`。Run log ZIP 最大接受 10 MiB,最多解開 100 個檔案且合計最多回傳 1 MiB 文字;不下載 artifact 內容。`forgejo_delete_action_run` 只適用於 Forgejo 允許刪除的已完成 run。Forgejo v16 沒有公開 PAT REST rerun endpoint,因此不提供 rerun 工具

## 6. Audit 規格

Expand Down Expand Up @@ -515,7 +524,7 @@ v1 不實作也不在 registry 中預留以下工具:
- Update/delete repository;建立 repository 僅限既有組織,且只能透過 `forgejo_create_organization_repository`。
- Protected branch、collaborator、team、organization 權限管理。
- Webhook、deploy key、GPG key、OAuth application 管理。
- 未由最低支援 Forgejo OpenAPI 確認的 Actions run/job/log/rerun,以及 runner、package、secret 或 variable 管理。
- Actions rerun,以及 runner、package、secret 或 variable 管理。
- Generic Forgejo API request/proxy。
- 任意 URL fetch 或讓 argument 覆寫 Forgejo base URL。

Expand Down Expand Up @@ -547,7 +556,7 @@ v1 不實作也不在 registry 中預留以下工具:

最低支援版本鎖定為 Forgejo `16.0.2+gitea-1.22.0`,測試 image 固定使用 `codeberg.org/forgejo/forgejo:16.0.2-rootless`。

- `tests/contracts/forgejo-v16-openapi.json` 保存 39 個 MCP tools 對應的 method、path、operation ID,以及完整 `/swagger.v1.json` SHA-256。
- `tests/contracts/forgejo-v16-openapi.json` 保存 47 個 MCP tools 對應的 method、path、operation ID,以及完整 `/swagger.v1.json` SHA-256。
- `scripts/verify_forgejo_openapi.py` 驗證實際 instance 的版本、checksum、registry 完整性與每個 operation。
- `scripts/test-full-docker-e2e.sh` 在每次 CI 以 pinned image 執行 contract verification 及完整 MCP development flow。
- 正式發布前仍須加入最低與最新支援版本的 integration matrix。
Expand Down
9 changes: 5 additions & 4 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,16 @@ Depending on your grants, an MCP client can:
4. commit multiple file changes atomically;
5. create a pull request and inspect its commits, diff and changed files;
6. request reviewers and submit, list or load a specific review;
7. inspect commit status and dispatch a workflow;
8. check whether a pull request has already been merged, or merge it;
9. create a tag and release.
7. inspect commit status, dispatch a workflow, and inspect Actions runs, jobs, logs and artifacts;
8. cancel a running Action or delete a completed Action run;
9. check whether a pull request has already been merged, or merge it;
10. create a tag and release.

Write tools change the real Forgejo repository. Review the tool name, repository, branch and proposed arguments before approving a client action. `forgejo_get_pull_request_merge_status` reports only whether a pull request has already been merged; use the `mergeable` field from `forgejo_get_pull_request` to check whether it can be merged.

If a write tool times out or the connection is interrupted, do not retry immediately. First use a read tool to check whether the Issue, commit, pull request, merge, tag or release was created, avoiding duplicate side effects.

The complete schema and behavior of all 39 tools are documented in the [v1 tool catalog](tools/v1-tool-catalog.md).
The complete schema and behavior of all 47 tools are documented in the [v1 tool catalog](tools/v1-tool-catalog.md).

## Token and credential maintenance

Expand Down
9 changes: 5 additions & 4 deletions docs/user-guide.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,16 @@ Authorization: Bearer fmcp_...
4. 以單一 commit 變更多個檔案;
5. 建立 pull request,並檢視其中的 commits、diff 與 changed files;
6. 要求 reviewer,並提交、列出或讀取特定 review;
7. 檢視 commit status 並 dispatch workflow;
8. 確認 pull request 是否已合併,或執行 merge;
9. 建立 tag 與 release。
7. 檢視 commit status、dispatch workflow,並查看 Actions run、job、log 與 artifact;
8. 取消執行中的 Action,或刪除已完成的 Action run;
9. 確認 pull request 是否已合併,或執行 merge;
10. 建立 tag 與 release。

Write tools 會直接修改真實 Forgejo repository。允許 client 執行前,請檢查工具名稱、repository、branch 與 proposed arguments。`forgejo_get_pull_request_merge_status` 只表示 PR 是否已經合併;是否可合併請查看 `forgejo_get_pull_request` 的 `mergeable`。

若 write tool 發生 timeout 或連線中斷,不要立刻重試;請先使用 read tool 確認 Issue、commit、PR、merge、tag 或 release 是否已建立,避免重複操作。

全部 39 個工具的 schema 與行為請參閱 [v1 工具目錄](tools/v1-tool-catalog.md)。
全部 47 個工具的 schema 與行為請參閱 [v1 工具目錄](tools/v1-tool-catalog.md)。

## Token 與 credential 維護

Expand Down
34 changes: 34 additions & 0 deletions src/forgejo_mcp/application/forgejo_tool_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,40 @@ async def get_pull_request_merge_status(self, user_id: uuid.UUID, **kwargs: Any)
async def get_commit_status(self, user_id: uuid.UUID, **kwargs: Any) -> dict[str, Any]:
return cast(dict[str, Any], await self._call(user_id, "get_commit_status", **kwargs))

async def list_action_runs(self, user_id: uuid.UUID, **kwargs: Any) -> dict[str, Any]:
return cast(dict[str, Any], await self._call(user_id, "list_action_runs", **kwargs))

async def get_action_run(self, user_id: uuid.UUID, **kwargs: Any) -> dict[str, Any]:
return cast(dict[str, Any], await self._call(user_id, "get_action_run", **kwargs))

async def list_action_run_jobs(
self, user_id: uuid.UUID, **kwargs: Any
) -> BoundedList[dict[str, Any]]:
return cast(
BoundedList[dict[str, Any]],
await self._call(user_id, "list_action_run_jobs", **kwargs),
)

async def get_action_job_log(self, user_id: uuid.UUID, **kwargs: Any) -> dict[str, Any]:
return cast(dict[str, Any], await self._call(user_id, "get_action_job_log", **kwargs))

async def get_action_run_logs(self, user_id: uuid.UUID, **kwargs: Any) -> dict[str, Any]:
return cast(dict[str, Any], await self._call(user_id, "get_action_run_logs", **kwargs))

async def list_action_run_artifacts(
self, user_id: uuid.UUID, **kwargs: Any
) -> Page[dict[str, Any]]:
return cast(
Page[dict[str, Any]],
await self._call(user_id, "list_action_run_artifacts", **kwargs),
)

async def cancel_action_run(self, user_id: uuid.UUID, **kwargs: Any) -> None:
await self._call(user_id, "cancel_action_run", **kwargs)

async def delete_action_run(self, user_id: uuid.UUID, **kwargs: Any) -> None:
await self._call(user_id, "delete_action_run", **kwargs)

async def dispatch_workflow(self, user_id: uuid.UUID, **kwargs: Any) -> None:
await self._call(user_id, "dispatch_workflow", **kwargs)

Expand Down
4 changes: 4 additions & 0 deletions src/forgejo_mcp/audit/redaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"owner",
"repo",
"number",
"run_id",
"job_id",
"attempt",
"workflow_id",
"path",
"ref",
"sha",
Expand Down
Loading
Loading