UNPKG

@mseep/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

102 lines (101 loc) 5.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const vendor_atlassian_workspaces_service_js_1 = __importDefault(require("../services/vendor.atlassian.workspaces.service.js")); const logger_util_js_1 = require("../utils/logger.util.js"); const error_handler_util_js_1 = require("../utils/error-handler.util.js"); const pagination_util_js_1 = require("../utils/pagination.util.js"); const atlassian_workspaces_formatter_js_1 = require("./atlassian.workspaces.formatter.js"); const defaults_util_js_1 = require("../utils/defaults.util.js"); // Create a contextualized logger for this file const controllerLogger = logger_util_js_1.Logger.forContext('controllers/atlassian.workspaces.controller.ts'); // Log controller initialization controllerLogger.debug('Bitbucket workspaces controller initialized'); /** * Controller for managing Bitbucket workspaces. * Provides functionality for listing workspaces and retrieving workspace details. */ /** * List Bitbucket workspaces with optional filtering * @param options - Options for listing workspaces * @param options.limit - Maximum number of workspaces to return * @param options.cursor - Pagination cursor for retrieving the next set of results * @returns Promise with formatted workspace list content and pagination information */ async function list(options) { const methodLogger = logger_util_js_1.Logger.forContext('controllers/atlassian.workspaces.controller.ts', 'list'); methodLogger.debug('Listing Bitbucket workspaces...', options); try { // Create defaults object with proper typing const defaults = { limit: defaults_util_js_1.DEFAULT_PAGE_SIZE, }; // Apply defaults const mergedOptions = (0, defaults_util_js_1.applyDefaults)(options, defaults); // Map controller filters to service params const serviceParams = { pagelen: mergedOptions.limit, // Default page length page: mergedOptions.cursor ? parseInt(mergedOptions.cursor, 10) : undefined, // Use cursor value for page // NOTE: Sort parameter is not included as the Bitbucket API's /2.0/user/permissions/workspaces // endpoint does not support sorting on any field }; methodLogger.debug('Using filters:', serviceParams); const workspacesData = await vendor_atlassian_workspaces_service_js_1.default.list(serviceParams); methodLogger.debug(`Retrieved ${workspacesData.values?.length || 0} workspaces`); // Extract pagination information using the utility const pagination = (0, pagination_util_js_1.extractPaginationInfo)(workspacesData, pagination_util_js_1.PaginationType.PAGE); // Format the workspaces data for display using the formatter const formattedWorkspaces = (0, atlassian_workspaces_formatter_js_1.formatWorkspacesList)(workspacesData); return { content: formattedWorkspaces, pagination, }; } catch (error) { // Use the standardized error handler (0, error_handler_util_js_1.handleControllerError)(error, { entityType: 'Workspaces', operation: 'listing', source: 'controllers/atlassian.workspaces.controller.ts@list', additionalInfo: { options }, }); } } /** * Get details of a specific Bitbucket workspace * @param identifier - Object containing the workspace slug * @param identifier.workspaceSlug - The slug of the workspace to retrieve * @param options - Options for retrieving the workspace (not currently used) * @returns Promise with formatted workspace details content * @throws Error if workspace retrieval fails */ async function get(identifier, options = {}) { const { workspaceSlug } = identifier; const methodLogger = logger_util_js_1.Logger.forContext('controllers/atlassian.workspaces.controller.ts', 'get'); methodLogger.debug(`Getting Bitbucket workspace with slug: ${workspaceSlug}...`); try { const workspaceData = await vendor_atlassian_workspaces_service_js_1.default.get(workspaceSlug); methodLogger.debug(`Retrieved workspace: ${workspaceData.slug}`); // Since membership info isn't directly available, we'll use the workspace data only methodLogger.debug('Membership info not available, using workspace data only'); // Format the workspace data for display using the formatter const formattedWorkspace = (0, atlassian_workspaces_formatter_js_1.formatWorkspaceDetails)(workspaceData, undefined); return { content: formattedWorkspace, }; } catch (error) { // Use the standardized error handler (0, error_handler_util_js_1.handleControllerError)(error, { entityType: 'Workspace', operation: 'retrieving', source: 'controllers/atlassian.workspaces.controller.ts@get', additionalInfo: { options }, }); } } exports.default = { list, get };