@or2ooo/bitbucket-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +154 -0
- package/dist/bitbucket/client.d.ts +20 -0
- package/dist/bitbucket/client.d.ts.map +1 -0
- package/dist/bitbucket/client.js +123 -0
- package/dist/bitbucket/client.js.map +1 -0
- package/dist/bitbucket/types.d.ts +221 -0
- package/dist/bitbucket/types.d.ts.map +1 -0
- package/dist/bitbucket/types.js +2 -0
- package/dist/bitbucket/types.js.map +1 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +23 -0
- package/dist/config.js.map +1 -0
- package/dist/formatting.d.ts +21 -0
- package/dist/formatting.d.ts.map +1 -0
- package/dist/formatting.js +156 -0
- package/dist/formatting.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/safety.d.ts +10 -0
- package/dist/safety.d.ts.map +1 -0
- package/dist/safety.js +43 -0
- package/dist/safety.js.map +1 -0
- package/dist/toolsets/context.d.ts +5 -0
- package/dist/toolsets/context.d.ts.map +1 -0
- package/dist/toolsets/context.js +45 -0
- package/dist/toolsets/context.js.map +1 -0
- package/dist/toolsets/issues.d.ts +5 -0
- package/dist/toolsets/issues.d.ts.map +1 -0
- package/dist/toolsets/issues.js +140 -0
- package/dist/toolsets/issues.js.map +1 -0
- package/dist/toolsets/pipelines.d.ts +5 -0
- package/dist/toolsets/pipelines.d.ts.map +1 -0
- package/dist/toolsets/pipelines.js +125 -0
- package/dist/toolsets/pipelines.js.map +1 -0
- package/dist/toolsets/pullRequests.d.ts +5 -0
- package/dist/toolsets/pullRequests.d.ts.map +1 -0
- package/dist/toolsets/pullRequests.js +398 -0
- package/dist/toolsets/pullRequests.js.map +1 -0
- package/dist/toolsets/repos.d.ts +5 -0
- package/dist/toolsets/repos.d.ts.map +1 -0
- package/dist/toolsets/repos.js +221 -0
- package/dist/toolsets/repos.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
export function formatUser(user) {
|
|
2
|
+
return `${user.display_name} (@${user.nickname})`;
|
|
3
|
+
}
|
|
4
|
+
export function formatWorkspace(ws) {
|
|
5
|
+
return `${ws.name} [${ws.slug}]`;
|
|
6
|
+
}
|
|
7
|
+
export function formatWorkspaceList(workspaces) {
|
|
8
|
+
if (workspaces.length === 0)
|
|
9
|
+
return "No workspaces found.";
|
|
10
|
+
return workspaces.map((ws) => `- ${formatWorkspace(ws)}`).join("\n");
|
|
11
|
+
}
|
|
12
|
+
export function formatRepository(repo) {
|
|
13
|
+
const parts = [
|
|
14
|
+
`${repo.full_name}${repo.is_private ? " (private)" : " (public)"}`,
|
|
15
|
+
repo.description ? ` Description: ${repo.description}` : null,
|
|
16
|
+
` Language: ${repo.language || "not set"}`,
|
|
17
|
+
repo.mainbranch ? ` Main branch: ${repo.mainbranch.name}` : null,
|
|
18
|
+
repo.project ? ` Project: ${repo.project.name} [${repo.project.key}]` : null,
|
|
19
|
+
` Updated: ${repo.updated_on}`,
|
|
20
|
+
];
|
|
21
|
+
return parts.filter(Boolean).join("\n");
|
|
22
|
+
}
|
|
23
|
+
export function formatRepositoryList(repos) {
|
|
24
|
+
if (repos.length === 0)
|
|
25
|
+
return "No repositories found.";
|
|
26
|
+
return repos
|
|
27
|
+
.map((r) => `- ${r.full_name}${r.is_private ? " (private)" : ""} | ${r.language || "n/a"} | updated ${r.updated_on}`)
|
|
28
|
+
.join("\n");
|
|
29
|
+
}
|
|
30
|
+
export function formatBranch(branch) {
|
|
31
|
+
return `${branch.name} → ${branch.target.hash.substring(0, 12)} (${branch.target.message.split("\n")[0]})`;
|
|
32
|
+
}
|
|
33
|
+
export function formatBranchList(branches) {
|
|
34
|
+
if (branches.length === 0)
|
|
35
|
+
return "No branches found.";
|
|
36
|
+
return branches.map((b) => `- ${formatBranch(b)}`).join("\n");
|
|
37
|
+
}
|
|
38
|
+
export function formatCommit(commit) {
|
|
39
|
+
const shortHash = commit.hash.substring(0, 12);
|
|
40
|
+
const firstLine = commit.message.split("\n")[0];
|
|
41
|
+
const author = commit.author.user
|
|
42
|
+
? commit.author.user.display_name
|
|
43
|
+
: commit.author.raw;
|
|
44
|
+
return `${shortHash} ${firstLine}\n Author: ${author} | Date: ${commit.date}`;
|
|
45
|
+
}
|
|
46
|
+
export function formatCommitList(commits) {
|
|
47
|
+
if (commits.length === 0)
|
|
48
|
+
return "No commits found.";
|
|
49
|
+
return commits.map((c) => formatCommit(c)).join("\n");
|
|
50
|
+
}
|
|
51
|
+
function formatParticipant(p) {
|
|
52
|
+
const status = p.approved ? "approved" : p.state || "none";
|
|
53
|
+
return `${p.user.display_name} (${p.role}: ${status})`;
|
|
54
|
+
}
|
|
55
|
+
export function formatPullRequest(pr) {
|
|
56
|
+
const parts = [
|
|
57
|
+
`PR #${pr.id}: ${pr.title}`,
|
|
58
|
+
` State: ${pr.state} | Author: ${formatUser(pr.author)}`,
|
|
59
|
+
` Branch: ${pr.source.branch.name} → ${pr.destination.branch.name}`,
|
|
60
|
+
pr.description ? ` Description: ${pr.description.substring(0, 500)}` : null,
|
|
61
|
+
` Created: ${pr.created_on} | Updated: ${pr.updated_on}`,
|
|
62
|
+
` Comments: ${pr.comment_count} | Tasks: ${pr.task_count}`,
|
|
63
|
+
pr.participants.length > 0
|
|
64
|
+
? ` Participants: ${pr.participants.map(formatParticipant).join(", ")}`
|
|
65
|
+
: null,
|
|
66
|
+
pr.reviewers.length > 0
|
|
67
|
+
? ` Reviewers: ${pr.reviewers.map((r) => r.display_name).join(", ")}`
|
|
68
|
+
: null,
|
|
69
|
+
];
|
|
70
|
+
return parts.filter(Boolean).join("\n");
|
|
71
|
+
}
|
|
72
|
+
export function formatPullRequestList(prs) {
|
|
73
|
+
if (prs.length === 0)
|
|
74
|
+
return "No pull requests found.";
|
|
75
|
+
return prs
|
|
76
|
+
.map((pr) => `- #${pr.id} [${pr.state}] ${pr.title} (${pr.source.branch.name} → ${pr.destination.branch.name}) by ${pr.author.display_name}`)
|
|
77
|
+
.join("\n");
|
|
78
|
+
}
|
|
79
|
+
export function formatPRComment(comment) {
|
|
80
|
+
const location = comment.inline
|
|
81
|
+
? ` [${comment.inline.path}${comment.inline.to ? `:${comment.inline.to}` : ""}]`
|
|
82
|
+
: "";
|
|
83
|
+
const parent = comment.parent ? ` (reply to #${comment.parent.id})` : "";
|
|
84
|
+
return `#${comment.id}${location}${parent} by ${comment.user.display_name} at ${comment.created_on}:\n ${comment.content.raw}`;
|
|
85
|
+
}
|
|
86
|
+
export function formatPRActivity(activities) {
|
|
87
|
+
if (activities.length === 0)
|
|
88
|
+
return "No activity found.";
|
|
89
|
+
return activities
|
|
90
|
+
.map((a) => {
|
|
91
|
+
if (a.comment) {
|
|
92
|
+
return `[comment] ${formatPRComment(a.comment)}`;
|
|
93
|
+
}
|
|
94
|
+
if (a.approval) {
|
|
95
|
+
const user = a.approval.user;
|
|
96
|
+
return `[approved] by ${user.display_name} at ${a.approval.date}`;
|
|
97
|
+
}
|
|
98
|
+
if (a.update) {
|
|
99
|
+
return `[update] ${a.update.state} by ${a.update.author.display_name} at ${a.update.date}`;
|
|
100
|
+
}
|
|
101
|
+
return "[unknown activity]";
|
|
102
|
+
})
|
|
103
|
+
.join("\n");
|
|
104
|
+
}
|
|
105
|
+
export function formatDiffStat(entries) {
|
|
106
|
+
if (entries.length === 0)
|
|
107
|
+
return "No changes.";
|
|
108
|
+
const lines = entries.map((e) => {
|
|
109
|
+
const path = e.new?.path || e.old?.path || "unknown";
|
|
110
|
+
return `${e.status.padEnd(10)} ${path} (+${e.lines_added} -${e.lines_removed})`;
|
|
111
|
+
});
|
|
112
|
+
const totalAdded = entries.reduce((s, e) => s + e.lines_added, 0);
|
|
113
|
+
const totalRemoved = entries.reduce((s, e) => s + e.lines_removed, 0);
|
|
114
|
+
lines.push(`\nTotal: ${entries.length} files changed, +${totalAdded} -${totalRemoved}`);
|
|
115
|
+
return lines.join("\n");
|
|
116
|
+
}
|
|
117
|
+
export function formatIssue(issue) {
|
|
118
|
+
const parts = [
|
|
119
|
+
`#${issue.id}: ${issue.title}`,
|
|
120
|
+
` State: ${issue.state} | Priority: ${issue.priority} | Kind: ${issue.kind}`,
|
|
121
|
+
` Reporter: ${formatUser(issue.reporter)}`,
|
|
122
|
+
issue.assignee ? ` Assignee: ${formatUser(issue.assignee)}` : null,
|
|
123
|
+
issue.content.raw
|
|
124
|
+
? ` Description: ${issue.content.raw.substring(0, 500)}`
|
|
125
|
+
: null,
|
|
126
|
+
` Created: ${issue.created_on} | Updated: ${issue.updated_on}`,
|
|
127
|
+
` Votes: ${issue.votes} | Watches: ${issue.watches}`,
|
|
128
|
+
];
|
|
129
|
+
return parts.filter(Boolean).join("\n");
|
|
130
|
+
}
|
|
131
|
+
export function formatIssueList(issues) {
|
|
132
|
+
if (issues.length === 0)
|
|
133
|
+
return "No issues found.";
|
|
134
|
+
return issues
|
|
135
|
+
.map((i) => `- #${i.id} [${i.state}] ${i.title} (${i.priority}/${i.kind}) by ${i.reporter.display_name}`)
|
|
136
|
+
.join("\n");
|
|
137
|
+
}
|
|
138
|
+
export function formatIssueComment(comment) {
|
|
139
|
+
return `#${comment.id} by ${comment.user.display_name} at ${comment.created_on}:\n ${comment.content.raw}`;
|
|
140
|
+
}
|
|
141
|
+
export function formatPipeline(pipeline) {
|
|
142
|
+
const state = pipeline.state.result
|
|
143
|
+
? `${pipeline.state.name}:${pipeline.state.result.name}`
|
|
144
|
+
: pipeline.state.name;
|
|
145
|
+
const ref = pipeline.target.ref_name || "manual";
|
|
146
|
+
const duration = pipeline.duration_in_seconds
|
|
147
|
+
? `${pipeline.duration_in_seconds}s`
|
|
148
|
+
: "running";
|
|
149
|
+
return `#${pipeline.build_number} [${state}] ref:${ref} by ${pipeline.creator.display_name} (${duration}) started ${pipeline.created_on}`;
|
|
150
|
+
}
|
|
151
|
+
export function formatPipelineList(pipelines) {
|
|
152
|
+
if (pipelines.length === 0)
|
|
153
|
+
return "No pipelines found.";
|
|
154
|
+
return pipelines.map((p) => `- ${formatPipeline(p)}`).join("\n");
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=formatting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting.js","sourceRoot":"","sources":["../src/formatting.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,GAAG,IAAI,CAAC,YAAY,MAAM,IAAI,CAAC,QAAQ,GAAG,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAa;IAC3C,OAAO,GAAG,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,GAAG,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,UAAuB;IACzD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,sBAAsB,CAAC;IAC3D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAgB;IAC/C,MAAM,KAAK,GAAG;QACZ,GAAG,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,EAAE;QAClE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI;QAC9D,eAAe,IAAI,CAAC,QAAQ,IAAI,SAAS,EAAE;QAC3C,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI;QAC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CAAC,QAAkB;IAC/C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM;QACjC,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE;QACxD,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;IACxB,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,IAAI,QAAQ,CAAC;IACjD,MAAM,QAAQ,GAAG,QAAQ,CAAC,mBAAmB;QAC3C,CAAC,CAAC,GAAG,QAAQ,CAAC,mBAAmB,GAAG;QACpC,CAAC,CAAC,SAAS,CAAC;IACd,OAAO,IAAI,QAAQ,CAAC,YAAY,KAAK,KAAK,SAAS,GAAG,OAAO,QAAQ,CAAC,OAAO,CAAC,YAAY,KAAK,QAAQ,aAAa,QAAQ,CAAC,UAAU,EAAE,CAAC;AAC5I,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,SAAqB;IACtD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,qBAAqB,CAAC;IACzD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { loadConfig } from "./config.js";
|
|
5
|
+
import { BitbucketClient } from "./bitbucket/client.js";
|
|
6
|
+
import { registerContextTools } from "./toolsets/context.js";
|
|
7
|
+
import { registerRepoTools } from "./toolsets/repos.js";
|
|
8
|
+
import { registerPullRequestTools } from "./toolsets/pullRequests.js";
|
|
9
|
+
import { registerIssueTools } from "./toolsets/issues.js";
|
|
10
|
+
import { registerPipelineTools } from "./toolsets/pipelines.js";
|
|
11
|
+
async function main() {
|
|
12
|
+
const config = loadConfig();
|
|
13
|
+
const client = new BitbucketClient(config);
|
|
14
|
+
const server = new McpServer({
|
|
15
|
+
name: "bitbucket-mcp",
|
|
16
|
+
version: "1.0.0",
|
|
17
|
+
});
|
|
18
|
+
registerContextTools(server, client, config);
|
|
19
|
+
registerRepoTools(server, client, config);
|
|
20
|
+
registerPullRequestTools(server, client, config);
|
|
21
|
+
registerIssueTools(server, client, config);
|
|
22
|
+
registerPipelineTools(server, client, config);
|
|
23
|
+
const transport = new StdioServerTransport();
|
|
24
|
+
await server.connect(transport);
|
|
25
|
+
}
|
|
26
|
+
main().catch((error) => {
|
|
27
|
+
console.error("Fatal error:", error);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IAEH,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE9C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/safety.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Config } from "./config.js";
|
|
2
|
+
export declare class SafetyError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare function assertNotReadonly(config: Config): void;
|
|
6
|
+
export declare function assertWorkspaceAllowed(config: Config, workspace: string): void;
|
|
7
|
+
export declare function assertRepoAllowed(config: Config, workspace: string, repoSlug: string): void;
|
|
8
|
+
export declare function assertConfirmed(confirm: boolean | undefined, action: string): void;
|
|
9
|
+
export declare function resolveWorkspace(config: Config, workspace?: string): string;
|
|
10
|
+
//# sourceMappingURL=safety.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safety.d.ts","sourceRoot":"","sources":["../src/safety.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAMtD;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,IAAI,CASN;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,IAAI,CAcN;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GACb,IAAI,CAMN;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAMR"}
|
package/dist/safety.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export class SafetyError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "SafetyError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export function assertNotReadonly(config) {
|
|
8
|
+
if (config.readonly) {
|
|
9
|
+
throw new SafetyError("This operation is not allowed in readonly mode. Set BITBUCKET_READONLY=false to enable write operations.");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function assertWorkspaceAllowed(config, workspace) {
|
|
13
|
+
if (config.allowedWorkspaces) {
|
|
14
|
+
const normalized = workspace.toLowerCase();
|
|
15
|
+
if (!config.allowedWorkspaces.includes(normalized)) {
|
|
16
|
+
throw new SafetyError(`Workspace "${workspace}" is not in the allowed list. Allowed: ${config.allowedWorkspaces.join(", ")}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function assertRepoAllowed(config, workspace, repoSlug) {
|
|
21
|
+
assertWorkspaceAllowed(config, workspace);
|
|
22
|
+
if (config.allowedRepos) {
|
|
23
|
+
const fullName = `${workspace}/${repoSlug}`.toLowerCase();
|
|
24
|
+
const slugOnly = repoSlug.toLowerCase();
|
|
25
|
+
if (!config.allowedRepos.includes(fullName) &&
|
|
26
|
+
!config.allowedRepos.includes(slugOnly)) {
|
|
27
|
+
throw new SafetyError(`Repository "${workspace}/${repoSlug}" is not in the allowed list. Allowed: ${config.allowedRepos.join(", ")}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function assertConfirmed(confirm, action) {
|
|
32
|
+
if (!confirm) {
|
|
33
|
+
throw new SafetyError(`Destructive action "${action}" requires explicit confirmation. Set confirm=true to proceed.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function resolveWorkspace(config, workspace) {
|
|
37
|
+
if (workspace)
|
|
38
|
+
return workspace;
|
|
39
|
+
if (config.defaultWorkspace)
|
|
40
|
+
return config.defaultWorkspace;
|
|
41
|
+
throw new SafetyError("No workspace specified and BITBUCKET_DEFAULT_WORKSPACE is not set. Provide a workspace parameter.");
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=safety.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safety.js","sourceRoot":"","sources":["../src/safety.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9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,gEAAgE,CAC9F,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,MAAc,EACd,SAAkB;IAElB,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAChC,IAAI,MAAM,CAAC,gBAAgB;QAAE,OAAO,MAAM,CAAC,gBAAgB,CAAC;IAC5D,MAAM,IAAI,WAAW,CACnB,mGAAmG,CACpG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { BitbucketClient } from "../bitbucket/client.js";
|
|
3
|
+
import { Config } from "../config.js";
|
|
4
|
+
export declare function registerContextTools(server: McpServer, client: BitbucketClient, _config: Config): void;
|
|
5
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/toolsets/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,MAAM,GACd,IAAI,CAyDN"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatUser, formatWorkspaceList } from "../formatting.js";
|
|
3
|
+
export function registerContextTools(server, client, _config) {
|
|
4
|
+
server.tool("bb_whoami", "Get the currently authenticated Bitbucket user", {}, async () => {
|
|
5
|
+
try {
|
|
6
|
+
const user = await client.get("/user");
|
|
7
|
+
return {
|
|
8
|
+
content: [{ type: "text", text: formatUser(user) }],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
13
|
+
return {
|
|
14
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
15
|
+
isError: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
server.tool("bb_list_workspaces", "List Bitbucket workspaces accessible to the authenticated user", {
|
|
20
|
+
role: z
|
|
21
|
+
.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("Filter by role (e.g. 'owner', 'collaborator', 'member')"),
|
|
24
|
+
}, async (args) => {
|
|
25
|
+
try {
|
|
26
|
+
const workspaces = await client.paginateAll("/workspaces", args.role ? { role: args.role } : undefined);
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: "text",
|
|
31
|
+
text: formatWorkspaceList(workspaces),
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
38
|
+
return {
|
|
39
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
40
|
+
isError: true,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/toolsets/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEnE,MAAM,UAAU,oBAAoB,CAClC,MAAiB,EACjB,MAAuB,EACvB,OAAe;IAEf,MAAM,CAAC,IAAI,CACT,WAAW,EACX,gDAAgD,EAChD,EAAE,EACF,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAAO,OAAO,CAAC,CAAC;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,UAAU,OAAO,EAAE,EAAE,CAAC;gBAC/D,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { BitbucketClient } from "../bitbucket/client.js";
|
|
3
|
+
import { Config } from "../config.js";
|
|
4
|
+
export declare function registerIssueTools(server: McpServer, client: BitbucketClient, config: Config): void;
|
|
5
|
+
//# sourceMappingURL=issues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../../src/toolsets/issues.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAiBtC,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,GACb,IAAI,CAyKN"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatIssueList, formatIssue, formatIssueComment, } from "../formatting.js";
|
|
3
|
+
import { resolveWorkspace, assertRepoAllowed, assertNotReadonly, } from "../safety.js";
|
|
4
|
+
export function registerIssueTools(server, client, config) {
|
|
5
|
+
server.tool("bb_list_issues", "List issues in a Bitbucket repository", {
|
|
6
|
+
workspace: z
|
|
7
|
+
.string()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Bitbucket workspace slug (uses default if not set)"),
|
|
10
|
+
repo_slug: z.string().describe("Repository slug"),
|
|
11
|
+
query: z
|
|
12
|
+
.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Bitbucket query language string to filter issues"),
|
|
15
|
+
page: z.number().optional().describe("Page number for pagination"),
|
|
16
|
+
pagelen: z
|
|
17
|
+
.number()
|
|
18
|
+
.max(100)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Number of results per page (max 100)"),
|
|
21
|
+
}, async (args) => {
|
|
22
|
+
try {
|
|
23
|
+
const ws = resolveWorkspace(config, args.workspace);
|
|
24
|
+
assertRepoAllowed(config, ws, args.repo_slug);
|
|
25
|
+
const result = await client.get(`/repositories/${ws}/${args.repo_slug}/issues`, { q: args.query, page: args.page, pagelen: args.pagelen });
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{ type: "text", text: formatIssueList(result.values) },
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
34
|
+
return {
|
|
35
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
36
|
+
isError: true,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
server.tool("bb_get_issue", "Get details of a specific issue in a Bitbucket repository", {
|
|
41
|
+
workspace: z
|
|
42
|
+
.string()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("Bitbucket workspace slug (uses default if not set)"),
|
|
45
|
+
repo_slug: z.string().describe("Repository slug"),
|
|
46
|
+
issue_id: z.number().describe("Issue ID"),
|
|
47
|
+
}, async (args) => {
|
|
48
|
+
try {
|
|
49
|
+
const ws = resolveWorkspace(config, args.workspace);
|
|
50
|
+
assertRepoAllowed(config, ws, args.repo_slug);
|
|
51
|
+
const issue = await client.get(`/repositories/${ws}/${args.repo_slug}/issues/${args.issue_id}`);
|
|
52
|
+
return {
|
|
53
|
+
content: [{ type: "text", text: formatIssue(issue) }],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
+
return {
|
|
59
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
60
|
+
isError: true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
server.tool("bb_create_issue", "Create a new issue in a Bitbucket repository", {
|
|
65
|
+
workspace: z
|
|
66
|
+
.string()
|
|
67
|
+
.optional()
|
|
68
|
+
.describe("Bitbucket workspace slug (uses default if not set)"),
|
|
69
|
+
repo_slug: z.string().describe("Repository slug"),
|
|
70
|
+
title: z.string().describe("Issue title"),
|
|
71
|
+
content: z
|
|
72
|
+
.string()
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("Issue body in raw markdown format"),
|
|
75
|
+
kind: z
|
|
76
|
+
.enum(["bug", "enhancement", "proposal", "task"])
|
|
77
|
+
.optional()
|
|
78
|
+
.describe("Issue kind"),
|
|
79
|
+
priority: z
|
|
80
|
+
.enum(["trivial", "minor", "major", "critical", "blocker"])
|
|
81
|
+
.optional()
|
|
82
|
+
.describe("Issue priority"),
|
|
83
|
+
}, async (args) => {
|
|
84
|
+
try {
|
|
85
|
+
assertNotReadonly(config);
|
|
86
|
+
const ws = resolveWorkspace(config, args.workspace);
|
|
87
|
+
assertRepoAllowed(config, ws, args.repo_slug);
|
|
88
|
+
const body = { title: args.title };
|
|
89
|
+
if (args.content) {
|
|
90
|
+
body.content = { raw: args.content };
|
|
91
|
+
}
|
|
92
|
+
if (args.kind) {
|
|
93
|
+
body.kind = args.kind;
|
|
94
|
+
}
|
|
95
|
+
if (args.priority) {
|
|
96
|
+
body.priority = args.priority;
|
|
97
|
+
}
|
|
98
|
+
const issue = await client.post(`/repositories/${ws}/${args.repo_slug}/issues`, body);
|
|
99
|
+
return {
|
|
100
|
+
content: [{ type: "text", text: formatIssue(issue) }],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
105
|
+
return {
|
|
106
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
107
|
+
isError: true,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
server.tool("bb_comment_issue", "Add a comment to an issue in a Bitbucket repository", {
|
|
112
|
+
workspace: z
|
|
113
|
+
.string()
|
|
114
|
+
.optional()
|
|
115
|
+
.describe("Bitbucket workspace slug (uses default if not set)"),
|
|
116
|
+
repo_slug: z.string().describe("Repository slug"),
|
|
117
|
+
issue_id: z.number().describe("Issue ID"),
|
|
118
|
+
content: z.string().describe("Comment body in raw markdown format"),
|
|
119
|
+
}, async (args) => {
|
|
120
|
+
try {
|
|
121
|
+
assertNotReadonly(config);
|
|
122
|
+
const ws = resolveWorkspace(config, args.workspace);
|
|
123
|
+
assertRepoAllowed(config, ws, args.repo_slug);
|
|
124
|
+
const comment = await client.post(`/repositories/${ws}/${args.repo_slug}/issues/${args.issue_id}/comments`, { content: { raw: args.content } });
|
|
125
|
+
return {
|
|
126
|
+
content: [
|
|
127
|
+
{ type: "text", text: formatIssueComment(comment) },
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
133
|
+
return {
|
|
134
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
135
|
+
isError: true,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=issues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issues.js","sourceRoot":"","sources":["../../src/toolsets/issues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,OAAO,EACL,eAAe,EACf,WAAW,EACX,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,MAAM,UAAU,kBAAkB,CAChC,MAAiB,EACjB,MAAuB,EACvB,MAAc;IAEd,MAAM,CAAC,IAAI,C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K,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,EAAE,GAAG,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YACpD,iBAAiB,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAC9C,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,CAC/B,iBAAiB,EAAE,IAAI,IAAI,CAAC,SAAS,WAAW,IAAI,CAAC,QAAQ,WAAW,EACxE,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,CACnC,CAAC;YACF,OAAO;gBACL,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,kBAAkB,CAAC,OAAO,CAAC,EAAE;iBAC7D;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACzD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE,EAAE,CAAC;gBAC/D,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { BitbucketClient } from "../bitbucket/client.js";
|
|
3
|
+
import { Config } from "../config.js";
|
|
4
|
+
export declare function registerPipelineTools(server: McpServer, client: BitbucketClient, config: Config): void;
|
|
5
|
+
//# sourceMappingURL=pipelines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipelines.d.ts","sourceRoot":"","sources":["../../src/toolsets/pipelines.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAStC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,GACb,IAAI,CAsJN"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { formatPipelineList, formatPipeline } from "../formatting.js";
|
|
3
|
+
import { resolveWorkspace, assertRepoAllowed, assertNotReadonly, } from "../safety.js";
|
|
4
|
+
export function registerPipelineTools(server, client, config) {
|
|
5
|
+
server.tool("bb_list_pipelines", "List pipelines in a Bitbucket repository, sorted by newest first", {
|
|
6
|
+
workspace: z
|
|
7
|
+
.string()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Bitbucket workspace slug (uses default if not set)"),
|
|
10
|
+
repo_slug: z.string().describe("Repository slug"),
|
|
11
|
+
page: z.number().optional().describe("Page number for pagination"),
|
|
12
|
+
pagelen: z
|
|
13
|
+
.number()
|
|
14
|
+
.max(100)
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("Number of results per page (max 100)"),
|
|
17
|
+
}, async (args) => {
|
|
18
|
+
try {
|
|
19
|
+
const ws = resolveWorkspace(config, args.workspace);
|
|
20
|
+
assertRepoAllowed(config, ws, args.repo_slug);
|
|
21
|
+
const result = await client.get(`/repositories/${ws}/${args.repo_slug}/pipelines/`, {
|
|
22
|
+
page: args.page,
|
|
23
|
+
pagelen: args.pagelen,
|
|
24
|
+
sort: "-created_on",
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: "text",
|
|
30
|
+
text: formatPipelineList(result.values),
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
39
|
+
isError: true,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
server.tool("bb_get_pipeline", "Get details of a specific pipeline in a Bitbucket repository", {
|
|
44
|
+
workspace: z
|
|
45
|
+
.string()
|
|
46
|
+
.optional()
|
|
47
|
+
.describe("Bitbucket workspace slug (uses default if not set)"),
|
|
48
|
+
repo_slug: z.string().describe("Repository slug"),
|
|
49
|
+
pipeline_uuid: z.string().describe("Pipeline UUID"),
|
|
50
|
+
}, async (args) => {
|
|
51
|
+
try {
|
|
52
|
+
const ws = resolveWorkspace(config, args.workspace);
|
|
53
|
+
assertRepoAllowed(config, ws, args.repo_slug);
|
|
54
|
+
const pipeline = await client.get(`/repositories/${ws}/${args.repo_slug}/pipelines/${args.pipeline_uuid}`);
|
|
55
|
+
return {
|
|
56
|
+
content: [
|
|
57
|
+
{ type: "text", text: formatPipeline(pipeline) },
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
63
|
+
return {
|
|
64
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
65
|
+
isError: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
server.tool("bb_trigger_pipeline", "Trigger a new pipeline run in a Bitbucket repository", {
|
|
70
|
+
workspace: z
|
|
71
|
+
.string()
|
|
72
|
+
.optional()
|
|
73
|
+
.describe("Bitbucket workspace slug (uses default if not set)"),
|
|
74
|
+
repo_slug: z.string().describe("Repository slug"),
|
|
75
|
+
branch: z.string().describe("Branch name to run the pipeline on"),
|
|
76
|
+
pattern: z
|
|
77
|
+
.string()
|
|
78
|
+
.optional()
|
|
79
|
+
.describe("Custom pipeline pattern to run"),
|
|
80
|
+
variables: z
|
|
81
|
+
.array(z.object({
|
|
82
|
+
key: z.string(),
|
|
83
|
+
value: z.string(),
|
|
84
|
+
secured: z.boolean().optional(),
|
|
85
|
+
}))
|
|
86
|
+
.optional()
|
|
87
|
+
.describe("Pipeline variables"),
|
|
88
|
+
}, async (args) => {
|
|
89
|
+
try {
|
|
90
|
+
assertNotReadonly(config);
|
|
91
|
+
const ws = resolveWorkspace(config, args.workspace);
|
|
92
|
+
assertRepoAllowed(config, ws, args.repo_slug);
|
|
93
|
+
const target = {
|
|
94
|
+
ref_type: "branch",
|
|
95
|
+
type: "pipeline_ref_target",
|
|
96
|
+
ref_name: args.branch,
|
|
97
|
+
};
|
|
98
|
+
if (args.pattern) {
|
|
99
|
+
target.selector = { type: "custom", pattern: args.pattern };
|
|
100
|
+
}
|
|
101
|
+
const body = { target };
|
|
102
|
+
if (args.variables) {
|
|
103
|
+
body.variables = args.variables.map((v) => ({
|
|
104
|
+
key: v.key,
|
|
105
|
+
value: v.value,
|
|
106
|
+
secured: v.secured ?? false,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
const pipeline = await client.post(`/repositories/${ws}/${args.repo_slug}/pipelines/`, body);
|
|
110
|
+
return {
|
|
111
|
+
content: [
|
|
112
|
+
{ type: "text", text: formatPipeline(pipeline) },
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
118
|
+
return {
|
|
119
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
120
|
+
isError: true,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=pipelines.js.map
|