Skip to main content
Glama
pdogra1299
by pdogra1299

approve_pull_request

Automate approval of Bitbucket pull requests by specifying workspace, repository, and pull request ID for streamlined code review and PR lifecycle management.

Instructions

Approve a pull request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pull_request_idYesPull request ID
repositoryYesRepository slug (e.g., "my-repo")
workspaceYesBitbucket workspace/project key (e.g., "PROJ")

Implementation Reference

  • The main handler function that validates arguments using isApprovePullRequestArgs, constructs the appropriate Bitbucket API endpoint for Cloud or Server, sends the approval request, and returns a success message or handles errors.
    async handleApprovePullRequest(args: any) {
      if (!isApprovePullRequestArgs(args)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid arguments for approve_pull_request'
        );
      }
    
      const { workspace, repository, pull_request_id } = args;
    
      try {
        let apiPath: string;
    
        if (this.apiClient.getIsServer()) {
          // Bitbucket Server API - use participants endpoint
          // Convert email format: @ to _ for the API
          const username = this.username.replace('@', '_');
          apiPath = `/rest/api/latest/projects/${workspace}/repos/${repository}/pull-requests/${pull_request_id}/participants/${username}`;
          await this.apiClient.makeRequest<any>('put', apiPath, { status: 'APPROVED' });
        } else {
          // Bitbucket Cloud API
          apiPath = `/repositories/${workspace}/${repository}/pullrequests/${pull_request_id}/approve`;
          await this.apiClient.makeRequest<any>('post', apiPath);
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                message: 'Pull request approved successfully',
                pull_request_id,
                approved_by: this.username
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        return this.apiClient.handleApiError(error, `approving pull request ${pull_request_id} in ${workspace}/${repository}`);
      }
    }
  • JSON Schema definition for the approve_pull_request tool, specifying input parameters: workspace, repository, pull_request_id.
      name: 'approve_pull_request',
      description: 'Approve a pull request',
      inputSchema: {
        type: 'object',
        properties: {
          workspace: {
            type: 'string',
            description: 'Bitbucket workspace/project key (e.g., "PROJ")',
          },
          repository: {
            type: 'string',
            description: 'Repository slug (e.g., "my-repo")',
          },
          pull_request_id: {
            type: 'number',
            description: 'Pull request ID',
          },
        },
        required: ['workspace', 'repository', 'pull_request_id'],
      },
    },
  • src/index.ts:124-125 (registration)
    Registration of the approve_pull_request tool in the main server request handler switch statement, delegating to ReviewHandlers.handleApprovePullRequest.
    case 'approve_pull_request':
      return this.reviewHandlers.handleApprovePullRequest(request.params.arguments);
  • Type guard function for validating approve_pull_request arguments at runtime, used in the handler.
    export const isApprovePullRequestArgs = (
      args: any
    ): args is {
      workspace: string;
      repository: string;
      pull_request_id: number;
    } =>
      typeof args === 'object' &&
      args !== null &&
      typeof args.workspace === 'string' &&
      typeof args.repository === 'string' &&
      typeof args.pull_request_id === 'number';
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Approve a pull request' implies a write/mutation operation that likely requires specific permissions and changes the PR state, but it doesn't disclose any behavioral traits such as required authentication, side effects (e.g., triggering merges), rate limits, or what happens on success/failure. The description is minimal and lacks critical context for safe use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence 'Approve a pull request', which is front-loaded and wastes no words. It directly states the tool's purpose without unnecessary elaboration, making it efficient for quick understanding, though this brevity contributes to gaps in other dimensions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a mutation tool (approving PRs) with no annotations and no output schema, the description is incomplete. It fails to cover behavioral aspects like permissions, side effects, or return values, and doesn't address usage context relative to siblings. For a tool that modifies data, this minimal description leaves significant gaps for an AI agent to operate safely and effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with clear parameter descriptions (e.g., 'Pull request ID', 'Repository slug'). The description adds no additional meaning beyond what the schema provides, such as explaining how parameters interact or format specifics. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Approve a pull request' clearly states the action (approve) and resource (pull request), but it's vague about what 'approve' entails in this context (e.g., formal approval vs. informal). It distinguishes from siblings like 'unapprove_pull_request' by being the opposite action, but doesn't differentiate from other PR-related tools like 'merge_pull_request' or 'update_pull_request' in terms of purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing review permissions), when not to use it (e.g., if changes are requested), or direct alternatives like 'request_changes' or 'merge_pull_request'. Usage is implied only by the tool name and context, with no explicit instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/pdogra1299/bitbucket-mcp-server'

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