Consolidate tools from 110 to 45 using method dispatch (#143)

Consolidate 110 individual MCP tools down to 45 using a method dispatch pattern, aligning tool names with the GitHub MCP server conventions.

**Motivation:** LLMs work better with fewer, well-organized tools. The method dispatch pattern (used by GitHub's MCP server) groups related operations under read/write tools with a `method` parameter.

**Changes:**
- Group related tools into `_read`/`_write` pairs with method dispatch (e.g. `issue_read`, `issue_write`, `pull_request_read`, `pull_request_write`)
- Rename tools to match GitHub MCP naming (`get_file_contents`, `create_or_update_file`, `list_issues`, `list_pull_requests`, etc.)
- Rename `pageSize` to `perPage` for GitHub MCP compat
- Move issue label ops (`add_labels`, `remove_label`, etc.) into `issue_write`
- Merge `create_file`/`update_file` into `create_or_update_file` with optional `sha`
- Make `delete_file` require `sha`
- Add `get_labels` method to `issue_read`
- Add shared helpers: `GetInt64Slice`, `GetStringSlice`, `GetPagination` in params package
- Unexport all dispatch handler functions
- Fix: pass assignees/milestone in `CreateIssue`, bounds check in `GetFileContent`

Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/143
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-committed-by: silverwind <me@silverwind.io>
This commit is contained in:
silverwind
2026-03-06 19:12:15 +00:00
committed by silverwind
parent c3db4fb65f
commit bba612d238
22 changed files with 1574 additions and 2039 deletions

View File

@@ -13,7 +13,7 @@ import (
"github.com/mark3labs/mcp-go/mcp"
)
func TestEditPullRequestFn(t *testing.T) {
func Test_editPullRequestFn(t *testing.T) {
const (
owner = "octo"
repo = "demo"
@@ -87,9 +87,9 @@ func TestEditPullRequestFn(t *testing.T) {
},
}
result, err := EditPullRequestFn(context.Background(), req)
result, err := editPullRequestFn(context.Background(), req)
if err != nil {
t.Fatalf("EditPullRequestFn() error = %v", err)
t.Fatalf("editPullRequestFn() error = %v", err)
}
mu.Lock()
@@ -127,7 +127,7 @@ func TestEditPullRequestFn(t *testing.T) {
}
}
func TestMergePullRequestFn(t *testing.T) {
func Test_mergePullRequestFn(t *testing.T) {
const (
owner = "octo"
repo = "demo"
@@ -202,9 +202,9 @@ func TestMergePullRequestFn(t *testing.T) {
},
}
result, err := MergePullRequestFn(context.Background(), req)
result, err := mergePullRequestFn(context.Background(), req)
if err != nil {
t.Fatalf("MergePullRequestFn() error = %v", err)
t.Fatalf("mergePullRequestFn() error = %v", err)
}
mu.Lock()
@@ -254,7 +254,7 @@ func TestMergePullRequestFn(t *testing.T) {
}
}
func TestGetPullRequestDiffFn(t *testing.T) {
func Test_getPullRequestDiffFn(t *testing.T) {
const (
owner = "octo"
repo = "demo"
@@ -334,9 +334,9 @@ func TestGetPullRequestDiffFn(t *testing.T) {
},
}
result, err := GetPullRequestDiffFn(context.Background(), req)
result, err := getPullRequestDiffFn(context.Background(), req)
if err != nil {
t.Fatalf("GetPullRequestDiffFn() error = %v", err)
t.Fatalf("getPullRequestDiffFn() error = %v", err)
}
select {