UNPKG

@aashari/mcp-server-atlassian-bitbucket

Version:

Node.js/TypeScript MCP server for Atlassian Bitbucket. Enables AI systems (LLMs) to interact with workspaces, repositories, and pull requests via tools (list, get, comment, search). Connects AI directly to version control workflows through the standard MC

58 lines (55 loc) 3.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const atlassian_pullrequests_base_controller_js_1 = require("./atlassian.pullrequests.base.controller.js"); /** * Approve a pull request in Bitbucket * @param options - Options including workspace slug, repo slug, and pull request ID * @returns Promise with formatted approval confirmation as Markdown content */ async function approve(options) { const methodLogger = atlassian_pullrequests_base_controller_js_1.Logger.forContext('controllers/atlassian.pullrequests.approve.controller.ts', 'approve'); try { // Apply defaults if needed (none for this operation) const mergedOptions = (0, atlassian_pullrequests_base_controller_js_1.applyDefaults)(options, {}); // Handle optional workspaceSlug - get default if not provided if (!mergedOptions.workspaceSlug) { methodLogger.debug('No workspace provided, fetching default workspace'); const defaultWorkspace = await (0, atlassian_pullrequests_base_controller_js_1.getDefaultWorkspace)(); if (!defaultWorkspace) { throw new Error('Could not determine a default workspace. Please provide a workspaceSlug.'); } mergedOptions.workspaceSlug = defaultWorkspace; methodLogger.debug(`Using default workspace: ${mergedOptions.workspaceSlug}`); } methodLogger.debug(`Approving pull request ${mergedOptions.pullRequestId} in ${mergedOptions.workspaceSlug}/${mergedOptions.repoSlug}`); // Prepare service parameters const serviceParams = { workspace: mergedOptions.workspaceSlug, repo_slug: mergedOptions.repoSlug, pull_request_id: mergedOptions.pullRequestId, }; // Call service to approve the pull request const participant = await atlassian_pullrequests_base_controller_js_1.atlassianPullRequestsService.approve(serviceParams); methodLogger.debug(`Successfully approved pull request ${mergedOptions.pullRequestId}`); // Format the response const content = `# Pull Request Approved ✅ **Pull Request ID:** ${mergedOptions.pullRequestId} **Repository:** \`${mergedOptions.workspaceSlug}/${mergedOptions.repoSlug}\` **Approved by:** ${participant.user.display_name || participant.user.nickname || 'Unknown User'} **Status:** ${participant.state} **Participated on:** ${new Date(participant.participated_on).toLocaleString()} The pull request has been successfully approved and is now ready for merge (pending any other required approvals or checks).`; return { content: content, }; } catch (error) { throw (0, atlassian_pullrequests_base_controller_js_1.handleControllerError)(error, { entityType: 'Pull Request', operation: 'approving', source: 'controllers/atlassian.pullrequests.approve.controller.ts@approve', additionalInfo: { options }, }); } } exports.default = { approve };