get_pull_requests_count
Count pull requests in a Backlog repository using filters like status, assignee, or issue to track development progress and manage code review workflows.
Instructions
Returns count of pull requests for a repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | No | The numeric ID of the project (e.g., 12345) | |
| projectKey | No | The key of the project (e.g., 'PROJECT') | |
| repoId | No | Repository ID | |
| repoName | No | Repository name | |
| statusId | No | Status IDs | |
| assigneeId | No | Assignee user IDs | |
| issueId | No | Issue IDs | |
| createdUserId | No | Created user IDs |
Implementation Reference
- src/tools/getPullRequestsCount.ts:72-94 (handler)The tool handler logic: resolves project (ID or key) and repository (ID or name) using utility functions, then calls the Backlog library's getPullRequestsCount method.handler: async ({ projectId, projectKey, repoId, repoName, ...params }) => { const result = resolveIdOrKey( 'project', { id: projectId, key: projectKey }, t ); if (!result.ok) { throw result.error; } const repoResult = resolveIdOrName( 'repository', { id: repoId, name: repoName }, t ); if (!repoResult.ok) { throw repoResult.error; } return backlog.getPullRequestsCount( result.value, String(repoResult.value), params ); },
- Zod schema for tool input parameters including optional project, repository, status, assignee, issue, and creator filters.const getPullRequestsCountSchema = buildToolSchema((t) => ({ projectId: z .number() .optional() .describe( t( 'TOOL_GET_PULL_REQUESTS_COUNT_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)' ) ), projectKey: z .string() .optional() .describe( t( 'TOOL_GET_PULL_REQUESTS_COUNT_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')" ) ), repoId: z .number() .optional() .describe(t('TOOL_GET_PULL_REQUESTS_COUNT_REPO_ID', 'Repository ID')), repoName: z .string() .optional() .describe(t('TOOL_GET_PULL_REQUESTS_COUNT_REPO_NAME', 'Repository name')), statusId: z .array(z.number()) .optional() .describe(t('TOOL_GET_PULL_REQUESTS_COUNT_STATUS_ID', 'Status IDs')), assigneeId: z .array(z.number()) .optional() .describe( t('TOOL_GET_PULL_REQUESTS_COUNT_ASSIGNEE_ID', 'Assignee user IDs') ), issueId: z .array(z.number()) .optional() .describe(t('TOOL_GET_PULL_REQUESTS_COUNT_ISSUE_ID', 'Issue IDs')), createdUserId: z .array(z.number()) .optional() .describe( t('TOOL_GET_PULL_REQUESTS_COUNT_CREATED_USER_ID', 'Created user IDs') ), }));
- src/tools/tools.ts:134-145 (registration)Registration of the getPullRequestsCountTool factory within the 'git' toolset group in the main allTools export.tools: [ getGitRepositoriesTool(backlog, helper), getGitRepositoryTool(backlog, helper), getPullRequestsTool(backlog, helper), getPullRequestsCountTool(backlog, helper), getPullRequestTool(backlog, helper), addPullRequestTool(backlog, helper), updatePullRequestTool(backlog, helper), getPullRequestCommentsTool(backlog, helper), addPullRequestCommentTool(backlog, helper), updatePullRequestCommentTool(backlog, helper), ],
- src/tools/getPullRequestsCount.ts:57-96 (registration)Factory function exporting the tool definition, including name, description, schemas, and handler for get_pull_requests_count.export const getPullRequestsCountTool = ( backlog: Backlog, { t }: TranslationHelper ): ToolDefinition< ReturnType<typeof getPullRequestsCountSchema>, (typeof PullRequestCountSchema)['shape'] > => { return { name: 'get_pull_requests_count', description: t( 'TOOL_GET_PULL_REQUESTS_COUNT_DESCRIPTION', 'Returns count of pull requests for a repository' ), schema: z.object(getPullRequestsCountSchema(t)), outputSchema: PullRequestCountSchema, handler: async ({ projectId, projectKey, repoId, repoName, ...params }) => { const result = resolveIdOrKey( 'project', { id: projectId, key: projectKey }, t ); if (!result.ok) { throw result.error; } const repoResult = resolveIdOrName( 'repository', { id: repoId, name: repoName }, t ); if (!repoResult.ok) { throw repoResult.error; } return backlog.getPullRequestsCount( result.value, String(repoResult.value), params ); }, }; };
- src/utils/resolveIdOrKey.ts:51-55 (helper)Helper utility used in the handler to resolve project ID or key to a usable value.export const resolveIdOrKey = <E extends EntityName>( entity: E, values: { id?: number; key?: string }, t: TranslationHelper['t'] ): ResolveResult => resolveIdOrField(entity, 'key', values, t);