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

105 lines (104 loc) 4.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatWorkspacesList = formatWorkspacesList; exports.formatWorkspaceDetails = formatWorkspaceDetails; const formatter_util_js_1 = require("../utils/formatter.util.js"); /** * Format a list of workspaces for display * @param workspacesData - Raw workspaces data from the API * @returns Formatted string with workspaces information in markdown format */ function formatWorkspacesList(workspacesData) { const workspaces = workspacesData.values || []; if (workspaces.length === 0) { return 'No workspaces found matching your criteria.'; } const lines = [(0, formatter_util_js_1.formatHeading)('Bitbucket Workspaces', 1), '']; // Format each workspace with its details const formattedList = (0, formatter_util_js_1.formatNumberedList)(workspaces, (membership, index) => { const workspace = membership.workspace; const itemLines = []; itemLines.push((0, formatter_util_js_1.formatHeading)(workspace.name, 2)); // Basic information const properties = { UUID: workspace.uuid, Slug: workspace.slug, 'Permission Level': membership.permission || 'Unknown', 'Last Accessed': membership.last_accessed ? (0, formatter_util_js_1.formatDate)(new Date(membership.last_accessed)) : 'N/A', 'Added On': membership.added_on ? (0, formatter_util_js_1.formatDate)(new Date(membership.added_on)) : 'N/A', 'Web URL': workspace.links?.html?.href ? (0, formatter_util_js_1.formatUrl)(workspace.links.html.href, workspace.slug) : (0, formatter_util_js_1.formatUrl)(`https://bitbucket.org/${workspace.slug}/`, workspace.slug), User: membership.user?.display_name || membership.user?.nickname || 'Unknown', }; // Format as a bullet list itemLines.push((0, formatter_util_js_1.formatBulletList)(properties, (key) => key)); // Add separator between workspaces except for the last one if (index < workspaces.length - 1) { itemLines.push(''); itemLines.push((0, formatter_util_js_1.formatSeparator)()); } return itemLines.join('\n'); }); lines.push(formattedList); // Add timestamp for when this information was retrieved lines.push(''); lines.push(`*Workspace information retrieved at ${(0, formatter_util_js_1.formatDate)(new Date())}*`); return lines.join('\n'); } /** * Format detailed workspace information for display * @param workspace - Raw workspace data from the API * @param membership - Optional membership information for the workspace * @returns Formatted string with workspace details in markdown format */ function formatWorkspaceDetails(workspace, membership) { const lines = [ (0, formatter_util_js_1.formatHeading)(`Workspace: ${workspace.name}`, 1), '', (0, formatter_util_js_1.formatHeading)('Basic Information', 2), ]; // Format basic information as a bullet list const basicProperties = { UUID: workspace.uuid, Slug: workspace.slug, Type: workspace.type || 'Not specified', 'Created On': workspace.created_on, }; lines.push((0, formatter_util_js_1.formatBulletList)(basicProperties, (key) => key)); // Add membership information if available if (membership) { lines.push(''); lines.push((0, formatter_util_js_1.formatHeading)('Your Membership', 2)); const membershipProperties = { Permission: membership.permission, 'Last Accessed': membership.last_accessed, 'Added On': membership.added_on, }; lines.push((0, formatter_util_js_1.formatBulletList)(membershipProperties, (key) => key)); } // Add links lines.push(''); lines.push((0, formatter_util_js_1.formatHeading)('Links', 2)); const links = []; if (workspace.links.html?.href) { links.push(`- ${(0, formatter_util_js_1.formatUrl)(workspace.links.html.href, 'View in Browser')}`); } if (workspace.links.repositories?.href) { links.push(`- ${(0, formatter_util_js_1.formatUrl)(workspace.links.repositories.href, 'Repositories')}`); } if (workspace.links.projects?.href) { links.push(`- ${(0, formatter_util_js_1.formatUrl)(workspace.links.projects.href, 'Projects')}`); } if (workspace.links.snippets?.href) { links.push(`- ${(0, formatter_util_js_1.formatUrl)(workspace.links.snippets.href, 'Snippets')}`); } lines.push(links.join('\n')); return lines.join('\n'); }