Skip to content

Commit a1922b2

Browse files
committed
consolidate fetching tools under ui_get tool to remove toolset deps
1 parent 934e83d commit a1922b2

File tree

10 files changed

+523
-438
lines changed

10 files changed

+523
-438
lines changed

pkg/github/__toolsnaps__/list_assignees.snap

Lines changed: 0 additions & 25 deletions
This file was deleted.

pkg/github/__toolsnaps__/list_milestones.snap

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"annotations": {
3+
"readOnlyHint": true,
4+
"title": "Get UI data"
5+
},
6+
"description": "Fetch UI data for MCP Apps (labels, assignees, milestones, issue types, branches).",
7+
"inputSchema": {
8+
"properties": {
9+
"method": {
10+
"description": "The type of data to fetch",
11+
"enum": [
12+
"labels",
13+
"assignees",
14+
"milestones",
15+
"issue_types",
16+
"branches"
17+
],
18+
"type": "string"
19+
},
20+
"owner": {
21+
"description": "Repository owner (required for all methods)",
22+
"type": "string"
23+
},
24+
"repo": {
25+
"description": "Repository name (required for labels, assignees, milestones, branches)",
26+
"type": "string"
27+
}
28+
},
29+
"required": [
30+
"method",
31+
"owner"
32+
],
33+
"type": "object"
34+
},
35+
"name": "ui_get"
36+
}

pkg/github/issues.go

Lines changed: 0 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -601,190 +601,6 @@ func ListIssueTypes(t translations.TranslationHelperFunc) inventory.ServerTool {
601601
})
602602
}
603603

604-
// ListAssignees creates a tool to list available assignees for a repository.
605-
// This tool is only available when insiders mode is enabled as it's a helper
606-
// for the MCP Apps UI.
607-
func ListAssignees(t translations.TranslationHelperFunc) inventory.ServerTool {
608-
st := NewTool(
609-
ToolsetMetadataIssues,
610-
mcp.Tool{
611-
Name: "list_assignees",
612-
Description: t("TOOL_LIST_ASSIGNEES_DESCRIPTION", "List available assignees for a repository. Returns users who can be assigned to issues."),
613-
Annotations: &mcp.ToolAnnotations{
614-
Title: t("TOOL_LIST_ASSIGNEES_USER_TITLE", "List assignable users"),
615-
ReadOnlyHint: true,
616-
},
617-
InputSchema: &jsonschema.Schema{
618-
Type: "object",
619-
Properties: map[string]*jsonschema.Schema{
620-
"owner": {
621-
Type: "string",
622-
Description: "Repository owner",
623-
},
624-
"repo": {
625-
Type: "string",
626-
Description: "Repository name",
627-
},
628-
},
629-
Required: []string{"owner", "repo"},
630-
},
631-
},
632-
[]scopes.Scope{scopes.Repo},
633-
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
634-
owner, err := RequiredParam[string](args, "owner")
635-
if err != nil {
636-
return utils.NewToolResultError(err.Error()), nil, nil
637-
}
638-
639-
repo, err := RequiredParam[string](args, "repo")
640-
if err != nil {
641-
return utils.NewToolResultError(err.Error()), nil, nil
642-
}
643-
644-
client, err := deps.GetClient(ctx)
645-
if err != nil {
646-
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
647-
}
648-
649-
// Fetch all assignees with pagination
650-
opts := &github.ListOptions{PerPage: 100}
651-
var allAssignees []*github.User
652-
653-
for {
654-
assignees, resp, err := client.Issues.ListAssignees(ctx, owner, repo, opts)
655-
if err != nil {
656-
return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to list assignees", resp, err), nil, nil
657-
}
658-
allAssignees = append(allAssignees, assignees...)
659-
if resp.NextPage == 0 {
660-
break
661-
}
662-
opts.Page = resp.NextPage
663-
}
664-
665-
// Build minimal response
666-
result := make([]map[string]string, len(allAssignees))
667-
for i, u := range allAssignees {
668-
result[i] = map[string]string{
669-
"login": u.GetLogin(),
670-
"avatar_url": u.GetAvatarURL(),
671-
}
672-
}
673-
674-
out, err := json.Marshal(map[string]any{
675-
"assignees": result,
676-
"totalCount": len(result),
677-
})
678-
if err != nil {
679-
return utils.NewToolResultErrorFromErr("failed to marshal assignees", err), nil, nil
680-
}
681-
682-
return utils.NewToolResultText(string(out)), nil, nil
683-
})
684-
st.InsidersOnly = true
685-
return st
686-
}
687-
688-
// ListMilestones creates a tool to list milestones for a repository.
689-
// This tool is only available when insiders mode is enabled as it's a helper
690-
// for the MCP Apps UI.
691-
func ListMilestones(t translations.TranslationHelperFunc) inventory.ServerTool {
692-
st := NewTool(
693-
ToolsetMetadataIssues,
694-
mcp.Tool{
695-
Name: "list_milestones",
696-
Description: t("TOOL_LIST_MILESTONES_DESCRIPTION", "List milestones for a repository."),
697-
Annotations: &mcp.ToolAnnotations{
698-
Title: t("TOOL_LIST_MILESTONES_USER_TITLE", "List milestones"),
699-
ReadOnlyHint: true,
700-
},
701-
InputSchema: &jsonschema.Schema{
702-
Type: "object",
703-
Properties: map[string]*jsonschema.Schema{
704-
"owner": {
705-
Type: "string",
706-
Description: "Repository owner",
707-
},
708-
"repo": {
709-
Type: "string",
710-
Description: "Repository name",
711-
},
712-
"state": {
713-
Type: "string",
714-
Enum: []any{"open", "closed", "all"},
715-
Description: "Filter by state (open, closed, all). Default: open",
716-
},
717-
},
718-
Required: []string{"owner", "repo"},
719-
},
720-
},
721-
[]scopes.Scope{scopes.Repo},
722-
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
723-
owner, err := RequiredParam[string](args, "owner")
724-
if err != nil {
725-
return utils.NewToolResultError(err.Error()), nil, nil
726-
}
727-
728-
repo, err := RequiredParam[string](args, "repo")
729-
if err != nil {
730-
return utils.NewToolResultError(err.Error()), nil, nil
731-
}
732-
733-
state, _ := OptionalParam[string](args, "state")
734-
if state == "" {
735-
state = "open"
736-
}
737-
738-
client, err := deps.GetClient(ctx)
739-
if err != nil {
740-
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
741-
}
742-
743-
opts := &github.MilestoneListOptions{
744-
State: state,
745-
ListOptions: github.ListOptions{PerPage: 100},
746-
}
747-
748-
var allMilestones []*github.Milestone
749-
for {
750-
milestones, resp, err := client.Issues.ListMilestones(ctx, owner, repo, opts)
751-
if err != nil {
752-
return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to list milestones", resp, err), nil, nil
753-
}
754-
allMilestones = append(allMilestones, milestones...)
755-
if resp.NextPage == 0 {
756-
break
757-
}
758-
opts.Page = resp.NextPage
759-
}
760-
761-
// Build minimal response
762-
result := make([]map[string]any, len(allMilestones))
763-
for i, m := range allMilestones {
764-
result[i] = map[string]any{
765-
"number": m.GetNumber(),
766-
"title": m.GetTitle(),
767-
"description": m.GetDescription(),
768-
"state": m.GetState(),
769-
"open_issues": m.GetOpenIssues(),
770-
"due_on": m.GetDueOn().Format("2006-01-02"),
771-
}
772-
}
773-
774-
out, err := json.Marshal(map[string]any{
775-
"milestones": result,
776-
"totalCount": len(result),
777-
})
778-
if err != nil {
779-
return utils.NewToolResultErrorFromErr("failed to marshal milestones", err), nil, nil
780-
}
781-
782-
return utils.NewToolResultText(string(out)), nil, nil
783-
})
784-
st.InsidersOnly = true
785-
return st
786-
}
787-
788604
// AddIssueComment creates a tool to add a comment to an issue.
789605
func AddIssueComment(t translations.TranslationHelperFunc) inventory.ServerTool {
790606
return NewTool(

0 commit comments

Comments
 (0)