@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
100 lines (99 loc) • 3.79 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.pathToString = pathToString;
exports.isPathInHome = isPathInHome;
exports.formatDisplayPath = formatDisplayPath;
const path = __importStar(require("path"));
const logger_util_js_1 = require("./logger.util.js");
const logger = logger_util_js_1.Logger.forContext('utils/path.util.ts');
/**
* Safely converts a path or path segments to a string, handling various input types.
* Useful for ensuring consistent path string representations across different platforms.
*
* @param pathInput - The path or path segments to convert to a string
* @returns The path as a normalized string
*/
function pathToString(pathInput) {
if (Array.isArray(pathInput)) {
return path.join(...pathInput);
}
else if (typeof pathInput === 'string') {
return pathInput;
}
else if (pathInput instanceof URL) {
return pathInput.pathname;
}
else if (pathInput &&
typeof pathInput === 'object' &&
'toString' in pathInput) {
return String(pathInput);
}
logger.warn(`Unable to convert path input to string: ${typeof pathInput}`);
return ''; // Return empty string for null/undefined
}
/**
* Determines if a given path is within the user's home directory
* which is generally considered a safe location for MCP operations.
*
* @param inputPath - Path to check
* @returns True if the path is within the user's home directory
*/
function isPathInHome(inputPath) {
const homePath = process.env.HOME || process.env.USERPROFILE || '';
if (!homePath) {
logger.warn('Could not determine user home directory');
return false;
}
const resolvedPath = path.resolve(inputPath);
return resolvedPath.startsWith(homePath);
}
/**
* Gets a user-friendly display version of a path for use in messages.
* For paths within the home directory, can replace with ~ for brevity.
*
* @param inputPath - Path to format
* @param useHomeTilde - Whether to replace home directory with ~ symbol
* @returns Formatted path string
*/
function formatDisplayPath(inputPath, useHomeTilde = true) {
const homePath = process.env.HOME || process.env.USERPROFILE || '';
if (useHomeTilde &&
homePath &&
path.resolve(inputPath).startsWith(homePath)) {
return path.resolve(inputPath).replace(homePath, '~');
}
return path.resolve(inputPath);
}