| 283 | } |
| 284 | |
| 285 | func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 286 | return NewTool( |
| 287 | ToolsetMetadataDiscussions, |
| 288 | mcp.Tool{ |
| 289 | Name: "get_discussion", |
| 290 | Description: t("TOOL_GET_DISCUSSION_DESCRIPTION", "Get a specific discussion by ID"), |
| 291 | Annotations: &mcp.ToolAnnotations{ |
| 292 | Title: t("TOOL_GET_DISCUSSION_USER_TITLE", "Get discussion"), |
| 293 | ReadOnlyHint: true, |
| 294 | }, |
| 295 | InputSchema: &jsonschema.Schema{ |
| 296 | Type: "object", |
| 297 | Properties: map[string]*jsonschema.Schema{ |
| 298 | "owner": { |
| 299 | Type: "string", |
| 300 | Description: "Repository owner", |
| 301 | }, |
| 302 | "repo": { |
| 303 | Type: "string", |
| 304 | Description: "Repository name", |
| 305 | }, |
| 306 | "discussionNumber": { |
| 307 | Type: "number", |
| 308 | Description: "Discussion Number", |
| 309 | }, |
| 310 | }, |
| 311 | Required: []string{"owner", "repo", "discussionNumber"}, |
| 312 | }, |
| 313 | }, |
| 314 | []scopes.Scope{scopes.Repo}, |
| 315 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 316 | // Decode params |
| 317 | var params struct { |
| 318 | Owner string |
| 319 | Repo string |
| 320 | DiscussionNumber int32 |
| 321 | } |
| 322 | if err := mapstructure.WeakDecode(args, ¶ms); err != nil { |
| 323 | return utils.NewToolResultError(err.Error()), nil, nil |
| 324 | } |
| 325 | client, err := deps.GetGQLClient(ctx) |
| 326 | if err != nil { |
| 327 | return utils.NewToolResultError(fmt.Sprintf("failed to get GitHub GQL client: %v", err)), nil, nil |
| 328 | } |
| 329 | |
| 330 | var q struct { |
| 331 | Repository struct { |
| 332 | Discussion struct { |
| 333 | Number githubv4.Int |
| 334 | Title githubv4.String |
| 335 | Body githubv4.String |
| 336 | CreatedAt githubv4.DateTime |
| 337 | Closed githubv4.Boolean |
| 338 | IsAnswered githubv4.Boolean |
| 339 | AnswerChosenAt *githubv4.DateTime |
| 340 | URL githubv4.String `graphql:"url"` |
| 341 | Category struct { |
| 342 | Name githubv4.String |