@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
76 lines (75 loc) • 3.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const logger_util_js_1 = require("../utils/logger.util.js");
const atlassian_search_code_controller_js_1 = require("./atlassian.search.code.controller.js");
const atlassian_search_content_controller_js_1 = require("./atlassian.search.content.controller.js");
const atlassian_search_repositories_controller_js_1 = require("./atlassian.search.repositories.controller.js");
const atlassian_search_pullrequests_controller_js_1 = require("./atlassian.search.pullrequests.controller.js");
const defaults_util_js_1 = require("../utils/defaults.util.js");
const error_handler_util_js_1 = require("../utils/error-handler.util.js");
// Logger instance for this module
const logger = logger_util_js_1.Logger.forContext('controllers/atlassian.search.controller.ts');
/**
* Perform a search across various Bitbucket data types
*
* @param options Search options
* @returns Formatted search results
*/
async function search(options = {}) {
const methodLogger = logger.forMethod('search');
try {
// Apply default values
const defaults = {
type: 'code',
workspace: '',
limit: defaults_util_js_1.DEFAULT_PAGE_SIZE,
};
const params = (0, defaults_util_js_1.applyDefaults)(options, defaults);
methodLogger.debug('Search options (with defaults):', params);
// Validate parameters
if (!params.workspace) {
methodLogger.warn('No workspace provided for search');
return {
content: 'Error: Please provide a workspace to search in.',
};
}
// Convert content type string to enum if provided (outside the switch statement)
let contentTypeEnum = undefined;
if (params.contentType) {
contentTypeEnum = params.contentType.toLowerCase();
}
// Dispatch to the appropriate search function based on type
switch (params.type?.toLowerCase()) {
case 'code':
return await (0, atlassian_search_code_controller_js_1.handleCodeSearch)(params.workspace, params.repo, params.query, params.limit, params.cursor, params.language, params.extension);
case 'content':
return await (0, atlassian_search_content_controller_js_1.handleContentSearch)(params.workspace, params.repo, params.query, params.limit, params.cursor, contentTypeEnum);
case 'repos':
case 'repositories':
return await (0, atlassian_search_repositories_controller_js_1.handleRepositorySearch)(params.workspace, params.repo, params.query, params.limit, params.cursor);
case 'prs':
case 'pullrequests':
if (!params.repo) {
return {
content: 'Error: Repository is required for pull request search.',
};
}
return await (0, atlassian_search_pullrequests_controller_js_1.handlePullRequestSearch)(params.workspace, params.repo, params.query, params.limit, params.cursor);
default:
methodLogger.warn(`Unknown search type: ${params.type}`);
return {
content: `Error: Unknown search type "${params.type}". Supported types are: code, content, repositories, pullrequests.`,
};
}
}
catch (error) {
// Pass the error to the handler with context
throw (0, error_handler_util_js_1.handleControllerError)(error, {
entityType: 'Search',
operation: 'search',
source: 'controllers/atlassian.search.controller.ts@search',
additionalInfo: options,
});
}
}
exports.default = { search };