list_default_reviewers
Retrieve the default reviewers configured for a Bitbucket project to understand required code review workflows and approval processes.
Instructions
List default reviewers for a project.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_key | Yes | The key of the project. |
Implementation Reference
- The async handler function that implements the core logic of the 'list_default_reviewers' tool: validates input, fetches default reviewers from Bitbucket API for the given project_key, formats the response, and handles errors.export async function listDefaultReviewers( axiosInstance: AxiosInstance, config: Config, args: any ): Promise<{ content: Array<{ type: string; text: string }> }> { try { const { project_key } = args; if (!project_key) { throw new Error('Project key is required'); } console.error(`Fetching default reviewers for project: ${project_key}`); const response = await axiosInstance.get< BitbucketPaginatedResponse<BitbucketUser> >( `/workspaces/${config.BITBUCKET_WORKSPACE}/projects/${project_key}/default-reviewers` ); const reviewers = response.data.values; const summary = `Found ${reviewers.length} default reviewers in project "${project_key}"`; const reviewerList = reviewers .map(reviewer => `- ${reviewer.display_name} (${reviewer.nickname})`) .join('\n'); return { content: [ { type: 'text', text: `${summary}\n\n${reviewerList}`, }, ], }; } catch (error) { console.error('Error fetching default reviewers:', error); return { content: [ { type: 'text', text: `Error fetching default reviewers: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; } }
- The tool schema definition, including name, description, and inputSchema specifying the required 'project_key' parameter.export const listDefaultReviewersTool = { name: 'list_default_reviewers', description: 'List default reviewers for a project.', inputSchema: { type: 'object', properties: { project_key: { type: 'string', description: 'The key of the project.', }, }, required: ['project_key'], }, };
- src/index.ts:111-135 (registration)Registration of the listDefaultReviewersTool in the ListToolsRequest handler, making it discoverable by MCP clients.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ // Repositories listRepositoriesTool, getRepositoryDetailsTool, // Commits listCommitsTool, getCommitTool, // Branching Model updateRepositoryBranchingModelSettingsTool, updateProjectBranchingModelSettingsTool, listBranchRestrictionsTool, getBranchRestrictionTool, // Projects getProjectTool, listDefaultReviewersTool, // Pull Requests listPullRequestsTool, getPullRequestTool, createPullRequestTool, updatePullRequestTool, // Workspaces listWorkspacesTool, ], }));
- src/index.ts:142-173 (registration)Registration of the handler function for 'list_default_reviewers' in the CallToolRequest handler's dispatch map.const handlers: Record< string, ( axiosInstance: AxiosInstance, config: Config, args: any ) => Promise<{ content: Array<{ type: string; text: string }> }> > = { // Repositories list_repositories: listRepositories, get_repository_details: getRepositoryDetails, // Commits list_commits: listCommits, get_commit: getCommit, // Branching Model update_repository_branching_model_settings: updateRepositoryBranchingModelSettings, update_project_branching_model_settings: updateProjectBranchingModelSettings, list_branch_restrictions: listBranchRestrictions, get_branch_restriction: getBranchRestriction, // Projects get_project: getProject, list_default_reviewers: listDefaultReviewers, // Pull Requests list_pull_requests: listPullRequests, get_pull_request: getPullRequest, create_pull_request: createPullRequest, update_pull_request: updatePullRequest, // Workspaces list_workspaces: listWorkspaces, };