UNPKG

@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

73 lines (72 loc) 3.5 kB
"use strict"; 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 atlassian_search_types_js_1 = require("./atlassian.search.types.js"); const atlassian_search_controller_js_1 = __importDefault(require("../controllers/atlassian.search.controller.js")); const error_util_js_1 = require("../utils/error.util.js"); const workspace_util_js_1 = require("../utils/workspace.util.js"); // Set up logger const logger = logger_util_js_1.Logger.forContext('tools/atlassian.search.tool.ts'); /** * Handle search command in MCP */ async function handleSearch(args) { // Create a method-scoped logger const methodLogger = logger.forMethod('handleSearch'); try { methodLogger.debug('Search tool called with args:', args); // Handle workspace similar to CLI implementation let workspace = args.workspaceSlug; if (!workspace) { const defaultWorkspace = await (0, workspace_util_js_1.getDefaultWorkspace)(); if (!defaultWorkspace) { return { content: [ { type: 'text', text: 'Error: No workspace provided and no default workspace configured', }, ], }; } workspace = defaultWorkspace; methodLogger.debug(`Using default workspace: ${workspace}`); } // Map tool args to controller options, aligning with controller parameter names const controllerOptions = { workspace: workspace, repo: args.repoSlug, query: args.query, type: args.scope, contentType: args.contentType, language: args.language, extension: args.extension, limit: args.limit, cursor: args.cursor, }; // Call the controller const result = await atlassian_search_controller_js_1.default.search(controllerOptions); // Return the result content in MCP format return { content: [{ type: 'text', text: result.content }], }; } catch (error) { // Log the error methodLogger.error('Search tool failed:', error); // Format the error for MCP response return (0, error_util_js_1.formatErrorForMcpTool)(error); } } /** * Register the search tools with the MCP server */ function registerTools(server) { // Register the search tool using the schema shape server.tool('bb_search', 'Searches Bitbucket for content matching the provided query. Use this tool to find repositories, code, pull requests, or other content in Bitbucket. Specify `scope` to narrow your search ("code", "repositories", "pullrequests", or "content"). Filter code searches by `language` or `extension`. Filter content searches by `contentType`. Only searches within the specified `workspaceSlug` and optionally within a specific `repoSlug`. Supports pagination via `limit` and `cursor`. Requires Atlassian Bitbucket credentials configured. Returns search results as Markdown.', atlassian_search_types_js_1.SearchToolArgsSchema.shape, handleSearch); logger.debug('Successfully registered Bitbucket search tools'); } exports.default = { registerTools };