@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
101 lines (100 loc) • 4.62 kB
TypeScript
/**
* Standardized formatting utilities for consistent output across all CLI and Tool interfaces.
* These functions should be used by all formatters to ensure consistent formatting.
*/
import { ResponsePagination } from '../types/common.types.js';
/**
* Format a date in a standardized way: YYYY-MM-DD HH:MM:SS UTC
* @param dateString - ISO date string or Date object
* @returns Formatted date string
*/
export declare function formatDate(dateString?: string | Date): string;
/**
* Format a URL as a markdown link
* @param url - URL to format
* @param title - Link title
* @returns Formatted markdown link
*/
export declare function formatUrl(url?: string, title?: string): string;
/**
* Format pagination information in a standardized way for CLI output.
* Includes separator, item counts, availability message, next page instructions, and timestamp.
* @param pagination - The ResponsePagination object containing pagination details.
* @returns Formatted pagination footer string for CLI.
*/
export declare function formatPagination(pagination: ResponsePagination): string;
/**
* Format a heading with consistent style
* @param text - Heading text
* @param level - Heading level (1-6)
* @returns Formatted heading
*/
export declare function formatHeading(text: string, level?: number): string;
/**
* Format a list of key-value pairs as a bullet list
* @param items - Object with key-value pairs
* @param keyFormatter - Optional function to format keys
* @returns Formatted bullet list
*/
export declare function formatBulletList(items: Record<string, unknown>, keyFormatter?: (key: string) => string): string;
/**
* Format a separator line
* @returns Separator line
*/
export declare function formatSeparator(): string;
/**
* Format a numbered list of items
* @param items - Array of items to format
* @param formatter - Function to format each item
* @returns Formatted numbered list
*/
export declare function formatNumberedList<T>(items: T[], formatter: (item: T, index: number) => string): string;
/**
* Format a raw diff output for display
*
* Parses and formats a raw unified diff string into a Markdown
* formatted display with proper code block syntax highlighting.
*
* @param {string} rawDiff - The raw diff content from the API
* @param {number} maxFiles - Maximum number of files to display in detail (optional, default: 5)
* @param {number} maxLinesPerFile - Maximum number of lines to display per file (optional, default: 100)
* @returns {string} Markdown formatted diff content
*/
export declare function formatDiff(rawDiff: string, maxFiles?: number, maxLinesPerFile?: number): string;
/**
* Optimizes markdown content to address Bitbucket Cloud's rendering quirks
*
* IMPORTANT: This function does NOT convert between formats (unlike Jira's ADF conversion).
* Bitbucket Cloud API natively accepts and returns markdown format. This function specifically
* addresses documented rendering issues in Bitbucket's markdown renderer by applying targeted
* formatting adjustments for better display in the Bitbucket UI.
*
* Known Bitbucket rendering issues this function fixes:
* - List spacing and indentation (prevents items from concatenating on a single line)
* - Code block formatting (addresses BCLOUD-20503 and similar bugs)
* - Nested list indentation (ensures proper hierarchy display)
* - Inline code formatting (adds proper spacing around backticks)
* - Diff syntax preservation (maintains +/- at line starts)
* - Excessive line break normalization
* - Heading spacing consistency
*
* Use this function for both:
* - Content received FROM the Bitbucket API (to properly display in CLI/tools)
* - Content being sent TO the Bitbucket API (to ensure proper rendering in Bitbucket UI)
*
* @param {string} markdown - The original markdown content
* @returns {string} Optimized markdown with workarounds for Bitbucket rendering issues
*/
export declare function optimizeBitbucketMarkdown(markdown: string): string;
/**
* Truncate content for AI consumption and add guidance if truncated
*
* When responses exceed the token limit, this function truncates the content
* and appends guidance for the AI to either access the full response from
* the raw log file or refine the request with better filtering.
*
* @param content - The formatted response content
* @param rawResponsePath - Optional path to the raw response file in /tmp/mcp/
* @returns Truncated content with guidance if needed, or original content if within limits
*/
export declare function truncateForAI(content: string, rawResponsePath?: string | null): string;