Skip to main content
Glama
Korfu
by Korfu

list_default_reviewers

Retrieve default reviewers for a Bitbucket project to ensure code changes are reviewed by the appropriate team members before merging.

Instructions

List default reviewers for a project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_keyYesThe key of the project.

Implementation Reference

  • The main handler function `listDefaultReviewers` that fetches default reviewers for a project using the Bitbucket API, 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'
              }`,
            },
          ],
        };
      }
    } 
  • Tool schema definition `listDefaultReviewersTool` including name 'list_default_reviewers', description, and input schema requiring 'project_key'.
    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:48-50 (registration)
    Import statement for the `listDefaultReviewers` handler and `listDefaultReviewersTool` from the tool file.
      listDefaultReviewers,
      listDefaultReviewersTool,
    } from './tools/projects/listDefaultReviewers.js';
  • src/index.ts:111-136 (registration)
    Registration of `listDefaultReviewersTool` in the ListToolsRequest handler's tools array (line 126).
    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:138-180 (registration)
    Dispatch mapping in CallToolRequest handler: 'list_default_reviewers' to `listDefaultReviewers` (line 165).
    CallToolRequestSchema,
    async (request: CallToolRequest) => {
      const args = request.params.arguments || {};
      const { name } = request.params;
      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,
      };
    
      if (name in handlers) {
        return await handlers[name](this.axiosInstance, this.config, args);
      } else {
        throw new Error(`Unknown tool: ${name}`);
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Korfu/mcp-bitbucket'

If you have feedback or need assistance with the MCP directory API, please join our Discord server