GranularCreateIssue creates a tool to create a new issue.
(t translations.TranslationHelperFunc)
| 114 | |
| 115 | // GranularCreateIssue creates a tool to create a new issue. |
| 116 | func GranularCreateIssue(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 117 | st := NewTool( |
| 118 | ToolsetMetadataIssues, |
| 119 | mcp.Tool{ |
| 120 | Name: "create_issue", |
| 121 | Description: t("TOOL_CREATE_ISSUE_DESCRIPTION", "Create a new issue in a GitHub repository with a title and optional body."), |
| 122 | Annotations: &mcp.ToolAnnotations{ |
| 123 | Title: t("TOOL_CREATE_ISSUE_USER_TITLE", "Create Issue"), |
| 124 | ReadOnlyHint: false, |
| 125 | DestructiveHint: jsonschema.Ptr(false), |
| 126 | OpenWorldHint: jsonschema.Ptr(true), |
| 127 | }, |
| 128 | InputSchema: &jsonschema.Schema{ |
| 129 | Type: "object", |
| 130 | Properties: map[string]*jsonschema.Schema{ |
| 131 | "owner": { |
| 132 | Type: "string", |
| 133 | Description: "Repository owner (username or organization)", |
| 134 | }, |
| 135 | "repo": { |
| 136 | Type: "string", |
| 137 | Description: "Repository name", |
| 138 | }, |
| 139 | "title": { |
| 140 | Type: "string", |
| 141 | Description: "Issue title", |
| 142 | }, |
| 143 | "body": { |
| 144 | Type: "string", |
| 145 | Description: "Issue body content (optional)", |
| 146 | }, |
| 147 | }, |
| 148 | Required: []string{"owner", "repo", "title"}, |
| 149 | }, |
| 150 | }, |
| 151 | []scopes.Scope{scopes.Repo}, |
| 152 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 153 | owner, err := RequiredParam[string](args, "owner") |
| 154 | if err != nil { |
| 155 | return utils.NewToolResultError(err.Error()), nil, nil |
| 156 | } |
| 157 | repo, err := RequiredParam[string](args, "repo") |
| 158 | if err != nil { |
| 159 | return utils.NewToolResultError(err.Error()), nil, nil |
| 160 | } |
| 161 | title, err := RequiredParam[string](args, "title") |
| 162 | if err != nil { |
| 163 | return utils.NewToolResultError(err.Error()), nil, nil |
| 164 | } |
| 165 | body, _ := OptionalParam[string](args, "body") |
| 166 | |
| 167 | issueReq := &github.IssueRequest{ |
| 168 | Title: &title, |
| 169 | } |
| 170 | if body != "" { |
| 171 | issueReq.Body = &body |
| 172 | } |
| 173 |