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

296 lines (295 loc) 9.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BranchesResponseSchema = exports.ListBranchesParamsSchema = exports.BranchSchema = exports.BranchTargetSchema = exports.GetFileContentParamsSchema = exports.BranchRefSchema = exports.CreateBranchParamsSchema = exports.PaginatedCommitsSchema = exports.CommitSchema = exports.CommitAuthorSchema = exports.ListCommitsParamsSchema = exports.RepositoriesResponseSchema = exports.GetRepositoryParamsSchema = exports.ListRepositoriesParamsSchema = exports.RepositorySchema = exports.RepositoryProjectSchema = exports.RepositoryBranchSchema = exports.RepositoryOwnerSchema = exports.RepositoryLinksSchema = exports.RepositoryForkPolicySchema = exports.RepositorySCMSchema = void 0; const zod_1 = require("zod"); /** * Types for Atlassian Bitbucket Repositories API */ // Link href schema const LinkSchema = zod_1.z.object({ href: zod_1.z.string(), name: zod_1.z.string().optional(), }); /** * Repository SCM type */ exports.RepositorySCMSchema = zod_1.z.enum(['git', 'hg']); /** * Repository fork policy */ exports.RepositoryForkPolicySchema = zod_1.z.enum([ 'allow_forks', 'no_public_forks', 'no_forks', ]); /** * Repository links object */ exports.RepositoryLinksSchema = zod_1.z.object({ self: LinkSchema.optional(), html: LinkSchema.optional(), avatar: LinkSchema.optional(), pullrequests: LinkSchema.optional(), commits: LinkSchema.optional(), forks: LinkSchema.optional(), watchers: LinkSchema.optional(), downloads: LinkSchema.optional(), clone: zod_1.z.array(LinkSchema).optional(), hooks: LinkSchema.optional(), issues: LinkSchema.optional(), }); /** * Repository owner links schema */ const OwnerLinksSchema = zod_1.z.object({ self: LinkSchema.optional(), html: LinkSchema.optional(), avatar: LinkSchema.optional(), }); /** * Repository owner object */ exports.RepositoryOwnerSchema = zod_1.z.object({ type: zod_1.z.enum(['user', 'team']), username: zod_1.z.string().optional(), display_name: zod_1.z.string().optional(), uuid: zod_1.z.string().optional(), links: OwnerLinksSchema.optional(), }); /** * Repository branch object */ exports.RepositoryBranchSchema = zod_1.z.object({ type: zod_1.z.literal('branch'), name: zod_1.z.string(), }); /** * Repository project links schema */ const ProjectLinksSchema = zod_1.z.object({ self: LinkSchema.optional(), html: LinkSchema.optional(), }); /** * Repository project object */ exports.RepositoryProjectSchema = zod_1.z.object({ type: zod_1.z.literal('project'), key: zod_1.z.string(), uuid: zod_1.z.string(), name: zod_1.z.string(), links: ProjectLinksSchema.optional(), }); /** * Repository object returned from the API */ exports.RepositorySchema = zod_1.z.object({ type: zod_1.z.literal('repository'), uuid: zod_1.z.string(), full_name: zod_1.z.string(), name: zod_1.z.string(), description: zod_1.z.string().optional(), is_private: zod_1.z.boolean(), fork_policy: exports.RepositoryForkPolicySchema.optional(), created_on: zod_1.z.string().optional(), updated_on: zod_1.z.string().optional(), size: zod_1.z.number().optional(), language: zod_1.z.string().optional(), has_issues: zod_1.z.boolean().optional(), has_wiki: zod_1.z.boolean().optional(), scm: exports.RepositorySCMSchema, owner: exports.RepositoryOwnerSchema, mainbranch: exports.RepositoryBranchSchema.optional(), project: exports.RepositoryProjectSchema.optional(), links: exports.RepositoryLinksSchema, }); /** * Parameters for listing repositories */ exports.ListRepositoriesParamsSchema = zod_1.z.object({ workspace: zod_1.z.string(), q: zod_1.z.string().optional(), sort: zod_1.z.string().optional(), page: zod_1.z.number().optional(), pagelen: zod_1.z.number().optional(), role: zod_1.z.string().optional(), }); /** * Parameters for getting a repository by identifier */ exports.GetRepositoryParamsSchema = zod_1.z.object({ workspace: zod_1.z.string(), repo_slug: zod_1.z.string(), }); /** * API response for listing repositories */ exports.RepositoriesResponseSchema = zod_1.z.object({ pagelen: zod_1.z.number(), page: zod_1.z.number(), size: zod_1.z.number(), next: zod_1.z.string().optional(), previous: zod_1.z.string().optional(), values: zod_1.z.array(exports.RepositorySchema), }); // --- Commit History Types --- /** * Parameters for listing commits. */ exports.ListCommitsParamsSchema = zod_1.z.object({ workspace: zod_1.z.string(), repo_slug: zod_1.z.string(), include: zod_1.z.string().optional(), // Branch, tag, or hash to include history from exclude: zod_1.z.string().optional(), // Branch, tag, or hash to exclude history up to path: zod_1.z.string().optional(), // File path to filter commits by page: zod_1.z.number().optional(), pagelen: zod_1.z.number().optional(), }); /** * Commit author user links schema */ const CommitAuthorUserLinksSchema = zod_1.z.object({ self: LinkSchema.optional(), avatar: LinkSchema.optional(), }); /** * Commit author user schema */ const CommitAuthorUserSchema = zod_1.z.object({ display_name: zod_1.z.string().optional(), nickname: zod_1.z.string().optional(), account_id: zod_1.z.string().optional(), uuid: zod_1.z.string().optional(), type: zod_1.z.string(), // Usually 'user' links: CommitAuthorUserLinksSchema.optional(), }); /** * Commit author schema */ exports.CommitAuthorSchema = zod_1.z.object({ raw: zod_1.z.string(), type: zod_1.z.string(), // Usually 'author' user: CommitAuthorUserSchema.optional(), }); /** * Commit links schema */ const CommitLinksSchema = zod_1.z.object({ self: LinkSchema.optional(), html: LinkSchema.optional(), diff: LinkSchema.optional(), approve: LinkSchema.optional(), comments: LinkSchema.optional(), }); /** * Commit summary schema */ const CommitSummarySchema = zod_1.z.object({ raw: zod_1.z.string().optional(), markup: zod_1.z.string().optional(), html: zod_1.z.string().optional(), }); /** * Commit parent schema */ const CommitParentSchema = zod_1.z.object({ hash: zod_1.z.string(), type: zod_1.z.string(), links: zod_1.z.unknown(), }); /** * Represents a single commit in the history. */ exports.CommitSchema = zod_1.z.object({ hash: zod_1.z.string(), type: zod_1.z.string(), // Usually 'commit' author: exports.CommitAuthorSchema, date: zod_1.z.string(), // ISO 8601 format date string message: zod_1.z.string(), links: CommitLinksSchema, summary: CommitSummarySchema.optional(), parents: zod_1.z.array(CommitParentSchema), }); /** * API response for listing commits (paginated). */ exports.PaginatedCommitsSchema = zod_1.z.object({ pagelen: zod_1.z.number(), page: zod_1.z.number().optional(), size: zod_1.z.number().optional(), next: zod_1.z.string().optional(), previous: zod_1.z.string().optional(), values: zod_1.z.array(exports.CommitSchema), }); /** * Parameters for creating a branch. */ exports.CreateBranchParamsSchema = zod_1.z.object({ workspace: zod_1.z.string(), repo_slug: zod_1.z.string(), name: zod_1.z.string(), // New branch name target: zod_1.z.object({ hash: zod_1.z.string(), // Source branch name or commit hash }), }); /** * Response object when creating a branch. * Contains details about the newly created branch reference. */ exports.BranchRefSchema = zod_1.z.object({ type: zod_1.z.literal('branch'), name: zod_1.z.string(), target: zod_1.z.object({ hash: zod_1.z.string(), type: zod_1.z.string(), // e.g., 'commit' }), }); /** * Parameters for getting a file's content from a repository. */ exports.GetFileContentParamsSchema = zod_1.z.object({ workspace: zod_1.z.string(), repo_slug: zod_1.z.string(), commit: zod_1.z.string(), // Branch name, tag, or commit hash path: zod_1.z.string(), // File path within the repository }); /** * Represents a branch target (usually a commit). */ exports.BranchTargetSchema = zod_1.z.object({ hash: zod_1.z.string(), type: zod_1.z.string(), // Usually 'commit' }); /** * Represents a branch in a Bitbucket repository. */ exports.BranchSchema = zod_1.z.object({ name: zod_1.z.string(), type: zod_1.z.literal('branch'), target: exports.BranchTargetSchema, merge_strategies: zod_1.z.array(zod_1.z.string()).optional(), default_merge_strategy: zod_1.z.string().optional(), links: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(), }); /** * Parameters for listing branches in a repository. */ exports.ListBranchesParamsSchema = zod_1.z.object({ workspace: zod_1.z.string(), repo_slug: zod_1.z.string(), page: zod_1.z.number().optional(), pagelen: zod_1.z.number().optional(), q: zod_1.z.string().optional(), // Query for filtering branches sort: zod_1.z.string().optional(), // Sort field }); /** * API response for listing branches (paginated). */ exports.BranchesResponseSchema = zod_1.z.object({ pagelen: zod_1.z.number(), page: zod_1.z.number().optional(), size: zod_1.z.number().optional(), next: zod_1.z.string().optional(), previous: zod_1.z.string().optional(), values: zod_1.z.array(exports.BranchSchema), });