@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
90 lines (89 loc) • 3.96 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const logger_util_js_1 = require("../utils/logger.util.js");
const error_util_js_1 = require("../utils/error.util.js");
const atlassian_workspaces_controller_js_1 = __importDefault(require("../controllers/atlassian.workspaces.controller.js"));
/**
* CLI module for managing Bitbucket workspaces.
* Provides commands for listing workspaces and retrieving workspace details.
* All commands require valid Atlassian credentials.
*/
// Create a contextualized logger for this file
const cliLogger = logger_util_js_1.Logger.forContext('cli/atlassian.workspaces.cli.ts');
// Log CLI initialization
cliLogger.debug('Bitbucket workspaces CLI module initialized');
/**
* Register Bitbucket workspaces CLI commands with the Commander program
*
* @param program - The Commander program instance to register commands with
* @throws Error if command registration fails
*/
function register(program) {
const methodLogger = logger_util_js_1.Logger.forContext('cli/atlassian.workspaces.cli.ts', 'register');
methodLogger.debug('Registering Bitbucket Workspaces CLI commands...');
registerListWorkspacesCommand(program);
registerGetWorkspaceCommand(program);
methodLogger.debug('CLI commands registered successfully');
}
/**
* Register the command for listing Bitbucket workspaces
*
* @param program - The Commander program instance
*/
function registerListWorkspacesCommand(program) {
program
.command('ls-workspaces')
.description('List workspaces in your Bitbucket account.')
.option('-l, --limit <number>', 'Maximum number of workspaces to retrieve (1-100). Default: 25.')
.option('-c, --cursor <string>', 'Pagination cursor for retrieving the next set of results.')
.action(async (options) => {
const actionLogger = cliLogger.forMethod('ls-workspaces');
try {
actionLogger.debug('Processing command options:', options);
// Map CLI options to controller params - keep only type conversions
const controllerOptions = {
limit: options.limit
? parseInt(options.limit, 10)
: undefined,
cursor: options.cursor,
};
// Call controller directly
const result = await atlassian_workspaces_controller_js_1.default.list(controllerOptions);
console.log(result.content);
}
catch (error) {
actionLogger.error('Operation failed:', error);
(0, error_util_js_1.handleCliError)(error);
}
});
}
/**
* Register the command for retrieving a specific Bitbucket workspace
*
* @param program - The Commander program instance
*/
function registerGetWorkspaceCommand(program) {
program
.command('get-workspace')
.description('Get detailed information about a specific Bitbucket workspace.')
.requiredOption('-w, --workspace-slug <slug>', 'Workspace slug to retrieve. Must be a valid workspace slug from your Bitbucket account. Example: "myteam"')
.action(async (options) => {
const actionLogger = logger_util_js_1.Logger.forContext('cli/atlassian.workspaces.cli.ts', 'get-workspace');
try {
actionLogger.debug(`Fetching workspace: ${options.workspaceSlug}`);
// Call controller directly with passed options
const result = await atlassian_workspaces_controller_js_1.default.get({
workspaceSlug: options.workspaceSlug,
});
console.log(result.content);
}
catch (error) {
actionLogger.error('Operation failed:', error);
(0, error_util_js_1.handleCliError)(error);
}
});
}
exports.default = { register };