@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
89 lines (88 loc) • 4.29 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_types_js_1 = require("./atlassian.workspaces.types.js");
const atlassian_workspaces_controller_js_1 = __importDefault(require("../controllers/atlassian.workspaces.controller.js"));
// Create a contextualized logger for this file
const toolLogger = logger_util_js_1.Logger.forContext('tools/atlassian.workspaces.tool.ts');
// Log tool initialization
toolLogger.debug('Bitbucket workspaces tool initialized');
/**
* MCP Tool: List Bitbucket Workspaces
*
* Lists Bitbucket workspaces available to the authenticated user with optional filtering.
* Returns a formatted markdown response with workspace details.
*
* @param args - Tool arguments for filtering workspaces
* @returns MCP response with formatted workspaces list
* @throws Will return error message if workspace listing fails
*/
async function listWorkspaces(args) {
const methodLogger = logger_util_js_1.Logger.forContext('tools/atlassian.workspaces.tool.ts', 'listWorkspaces');
methodLogger.debug('Listing Bitbucket workspaces with filters:', args);
try {
// Pass args directly to controller without any logic
const result = await atlassian_workspaces_controller_js_1.default.list(args);
methodLogger.debug('Successfully retrieved workspaces from controller');
return {
content: [
{
type: 'text',
text: result.content,
},
],
};
}
catch (error) {
methodLogger.error('Failed to list workspaces', error);
return (0, error_util_js_1.formatErrorForMcpTool)(error);
}
}
/**
* MCP Tool: Get Bitbucket Workspace Details
*
* Retrieves detailed information about a specific Bitbucket workspace.
* Returns a formatted markdown response with workspace metadata.
*
* @param args - Tool arguments containing the workspace slug
* @returns MCP response with formatted workspace details
* @throws Will return error message if workspace retrieval fails
*/
async function getWorkspace(args) {
const methodLogger = logger_util_js_1.Logger.forContext('tools/atlassian.workspaces.tool.ts', 'getWorkspace');
methodLogger.debug('Getting workspace details:', args);
try {
// Pass args directly to controller without any logic
const result = await atlassian_workspaces_controller_js_1.default.get(args);
methodLogger.debug('Successfully retrieved workspace details from controller');
return {
content: [
{
type: 'text',
text: result.content,
},
],
};
}
catch (error) {
methodLogger.error('Failed to get workspace details', error);
return (0, error_util_js_1.formatErrorForMcpTool)(error);
}
}
/**
* Register all Bitbucket workspace tools with the MCP server.
*/
function registerTools(server) {
const registerLogger = logger_util_js_1.Logger.forContext('tools/atlassian.workspaces.tool.ts', 'registerTools');
registerLogger.debug('Registering Workspace tools...');
// Register the list workspaces tool
server.tool('bb_ls_workspaces', `Lists workspaces within your Bitbucket account. Returns a formatted Markdown list showing workspace slugs, names, and membership role. Requires Bitbucket credentials to be configured.`, atlassian_workspaces_types_js_1.ListWorkspacesToolArgs.shape, listWorkspaces);
// Register the get workspace details tool
server.tool('bb_get_workspace', `Retrieves detailed information for a workspace identified by \`workspaceSlug\`. Returns comprehensive workspace details as formatted Markdown, including membership, projects, and key metadata. Requires Bitbucket credentials to be configured.`, atlassian_workspaces_types_js_1.GetWorkspaceToolArgs.shape, getWorkspace);
registerLogger.debug('Successfully registered Workspace tools');
}
exports.default = { registerTools };