UIGet creates a tool to fetch UI data for MCP Apps.
(t translations.TranslationHelperFunc)
| 31 | |
| 32 | // UIGet creates a tool to fetch UI data for MCP Apps. |
| 33 | func UIGet(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 34 | st := NewTool( |
| 35 | ToolsetMetadataContext, // Use context toolset so it's always available |
| 36 | mcp.Tool{ |
| 37 | Name: "ui_get", |
| 38 | Description: t("TOOL_UI_GET_DESCRIPTION", "Fetch UI data for MCP Apps (labels, assignees, milestones, issue types, branches, issue fields, reviewers)."), |
| 39 | Annotations: &mcp.ToolAnnotations{ |
| 40 | Title: t("TOOL_UI_GET_USER_TITLE", "Get UI data"), |
| 41 | ReadOnlyHint: true, |
| 42 | }, |
| 43 | // ui_get only backs MCP App views; declaring app-only visibility keeps |
| 44 | // it out of the agent's tool list while remaining callable by the views |
| 45 | // via tools/call (per the MCP Apps 2026-01-26 spec). |
| 46 | Meta: mcp.Meta{ |
| 47 | "ui": map[string]any{ |
| 48 | "visibility": []string{"app"}, |
| 49 | }, |
| 50 | }, |
| 51 | InputSchema: &jsonschema.Schema{ |
| 52 | Type: "object", |
| 53 | Properties: map[string]*jsonschema.Schema{ |
| 54 | "method": { |
| 55 | Type: "string", |
| 56 | Enum: []any{"labels", "assignees", "milestones", "issue_types", "branches", "issue_fields", "reviewers"}, |
| 57 | Description: "The type of data to fetch", |
| 58 | }, |
| 59 | "owner": { |
| 60 | Type: "string", |
| 61 | Description: "Repository owner (required for all methods)", |
| 62 | }, |
| 63 | "repo": { |
| 64 | Type: "string", |
| 65 | Description: "Repository name (required for labels, assignees, milestones, branches, issue fields, reviewers)", |
| 66 | }, |
| 67 | }, |
| 68 | Required: []string{"method", "owner"}, |
| 69 | }, |
| 70 | }, |
| 71 | []scopes.Scope{scopes.Repo, scopes.ReadOrg}, |
| 72 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 73 | method, err := RequiredParam[string](args, "method") |
| 74 | if err != nil { |
| 75 | return utils.NewToolResultError(err.Error()), nil, nil |
| 76 | } |
| 77 | |
| 78 | owner, err := RequiredParam[string](args, "owner") |
| 79 | if err != nil { |
| 80 | return utils.NewToolResultError(err.Error()), nil, nil |
| 81 | } |
| 82 | |
| 83 | switch method { |
| 84 | case "labels": |
| 85 | return uiGetLabels(ctx, deps, args, owner) |
| 86 | case "assignees": |
| 87 | return uiGetAssignees(ctx, deps, args, owner) |
| 88 | case "milestones": |
| 89 | return uiGetMilestones(ctx, deps, args, owner) |
| 90 | case "issue_types": |