mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2026-03-16 18:05:13 +00:00
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:
@@ -16,8 +16,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// GetMyUserInfoToolName is the unique tool name used for MCP registration and lookup of the get_my_user_info command.
|
||||
GetMyUserInfoToolName = "get_my_user_info"
|
||||
// GetMyUserInfoToolName is the unique tool name used for MCP registration and lookup of the get_me command.
|
||||
GetMyUserInfoToolName = "get_me"
|
||||
// GetUserOrgsToolName is the unique tool name used for MCP registration and lookup of the get_user_orgs command.
|
||||
GetUserOrgsToolName = "get_user_orgs"
|
||||
|
||||
@@ -39,12 +39,12 @@ var (
|
||||
)
|
||||
|
||||
// GetUserOrgsTool is the MCP tool for listing organizations for the authenticated user.
|
||||
// It supports pagination via "page" and "pageSize" arguments with default values specified above.
|
||||
// It supports pagination via "page" and "perPage" arguments with default values specified above.
|
||||
GetUserOrgsTool = mcp.NewTool(
|
||||
GetUserOrgsToolName,
|
||||
mcp.WithDescription("Get organizations associated with the authenticated user"),
|
||||
mcp.WithNumber("page", mcp.Description("page number"), mcp.DefaultNumber(defaultPage)),
|
||||
mcp.WithNumber("pageSize", mcp.Description("page size"), mcp.DefaultNumber(defaultPageSize)),
|
||||
mcp.WithNumber("perPage", mcp.Description("results per page"), mcp.DefaultNumber(defaultPageSize)),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -66,7 +66,7 @@ func registerTools() {
|
||||
}
|
||||
}
|
||||
|
||||
// GetUserInfoFn is the handler for "get_my_user_info" MCP tool requests.
|
||||
// GetUserInfoFn is the handler for "get_me" MCP tool requests.
|
||||
// Logs invocation, fetches current user info from gitea, wraps result for MCP.
|
||||
func GetUserInfoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("[User] Called GetUserInfoFn")
|
||||
|
||||
Reference in New Issue
Block a user