SearchPullRequests creates a tool to search for pull requests.
(t translations.TranslationHelperFunc)
| 1559 | |
| 1560 | // SearchPullRequests creates a tool to search for pull requests. |
| 1561 | func SearchPullRequests(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 1562 | schema := &jsonschema.Schema{ |
| 1563 | Type: "object", |
| 1564 | Properties: map[string]*jsonschema.Schema{ |
| 1565 | "query": { |
| 1566 | Type: "string", |
| 1567 | Description: "Search query using GitHub pull request search syntax", |
| 1568 | }, |
| 1569 | "owner": { |
| 1570 | Type: "string", |
| 1571 | Description: "Optional repository owner. If provided with repo, only pull requests for this repository are listed.", |
| 1572 | }, |
| 1573 | "repo": { |
| 1574 | Type: "string", |
| 1575 | Description: "Optional repository name. If provided with owner, only pull requests for this repository are listed.", |
| 1576 | }, |
| 1577 | "sort": { |
| 1578 | Type: "string", |
| 1579 | Description: "Sort field by number of matches of categories, defaults to best match", |
| 1580 | Enum: []any{ |
| 1581 | "comments", |
| 1582 | "reactions", |
| 1583 | "reactions-+1", |
| 1584 | "reactions--1", |
| 1585 | "reactions-smile", |
| 1586 | "reactions-thinking_face", |
| 1587 | "reactions-heart", |
| 1588 | "reactions-tada", |
| 1589 | "interactions", |
| 1590 | "created", |
| 1591 | "updated", |
| 1592 | }, |
| 1593 | }, |
| 1594 | "order": { |
| 1595 | Type: "string", |
| 1596 | Description: "Sort order", |
| 1597 | Enum: []any{"asc", "desc"}, |
| 1598 | }, |
| 1599 | }, |
| 1600 | Required: []string{"query"}, |
| 1601 | } |
| 1602 | WithPagination(schema) |
| 1603 | |
| 1604 | return NewTool( |
| 1605 | ToolsetMetadataPullRequests, |
| 1606 | mcp.Tool{ |
| 1607 | Name: "search_pull_requests", |
| 1608 | Description: t("TOOL_SEARCH_PULL_REQUESTS_DESCRIPTION", "Search for pull requests in GitHub repositories using issues search syntax already scoped to is:pr"), |
| 1609 | Annotations: &mcp.ToolAnnotations{ |
| 1610 | Title: t("TOOL_SEARCH_PULL_REQUESTS_USER_TITLE", "Search pull requests"), |
| 1611 | ReadOnlyHint: true, |
| 1612 | }, |
| 1613 | InputSchema: schema, |
| 1614 | }, |
| 1615 | []scopes.Scope{scopes.Repo}, |
| 1616 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 1617 | result, err := searchHandler(ctx, deps.GetClient, args, "pr", "failed to search pull requests", ifcSearchPostProcessOption(ctx, deps)) |
| 1618 | return result, nil, err |