@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
71 lines (70 loc) • 3.73 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleRepositoryDetails = handleRepositoryDetails;
const vendor_atlassian_repositories_service_js_1 = __importDefault(require("../services/vendor.atlassian.repositories.service.js"));
const vendor_atlassian_pullrequests_service_js_1 = __importDefault(require("../services/vendor.atlassian.pullrequests.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 atlassian_repositories_formatter_js_1 = require("./atlassian.repositories.formatter.js");
const workspace_util_js_1 = require("../utils/workspace.util.js");
// Logger instance for this module
const logger = logger_util_js_1.Logger.forContext('controllers/atlassian.repositories.details.controller.ts');
/**
* Get details of a specific repository
*
* @param params - Parameters containing workspaceSlug and repoSlug
* @returns Promise with formatted repository details content
*/
async function handleRepositoryDetails(params) {
const methodLogger = logger.forMethod('handleRepositoryDetails');
try {
methodLogger.debug('Getting repository details', params);
// Handle optional workspaceSlug
if (!params.workspaceSlug) {
methodLogger.debug('No workspace provided, fetching default workspace');
const defaultWorkspace = await (0, workspace_util_js_1.getDefaultWorkspace)();
if (!defaultWorkspace) {
throw new Error('No default workspace found. Please provide a workspace slug.');
}
params.workspaceSlug = defaultWorkspace;
methodLogger.debug(`Using default workspace: ${defaultWorkspace}`);
}
// Call the service to get repository details
const repoData = await vendor_atlassian_repositories_service_js_1.default.get({
workspace: params.workspaceSlug,
repo_slug: params.repoSlug,
});
// Fetch recent pull requests for this repository (most recently updated, limit to 5)
let pullRequestsData = null;
try {
methodLogger.debug('Fetching recent pull requests for the repository');
pullRequestsData = await vendor_atlassian_pullrequests_service_js_1.default.list({
workspace: params.workspaceSlug,
repo_slug: params.repoSlug,
state: 'OPEN', // Focus on open PRs
sort: '-updated_on', // Sort by most recently updated
pagelen: 5, // Limit to 5 to keep the response concise
});
methodLogger.debug(`Retrieved ${pullRequestsData.values?.length || 0} recent pull requests`);
}
catch (error) {
// Log the error but continue - this is an enhancement, not critical
methodLogger.warn('Failed to fetch recent pull requests, continuing without them', error);
// Do not fail the entire operation if pull requests cannot be fetched
}
// Format the repository data with optional pull requests
const content = (0, atlassian_repositories_formatter_js_1.formatRepositoryDetails)(repoData, pullRequestsData);
return { content };
}
catch (error) {
throw (0, error_handler_util_js_1.handleControllerError)(error, {
entityType: 'Repository',
operation: 'get',
source: 'controllers/atlassian.repositories.details.controller.ts@handleRepositoryDetails',
additionalInfo: params,
});
}
}