@azure-devops/mcp 2.2.0-nightly.20250925 → 2.2.0-nightly.20250927

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/README.md CHANGED
@@ -94,6 +94,7 @@ Interact with these Azure DevOps services:
94
94
  - **repo_get_branch_by_name**: Get a branch by its name.
95
95
  - **repo_get_pull_request_by_id**: Get a pull request by its ID.
96
96
  - **repo_create_pull_request**: Create a new pull request.
97
+ - **repo_create_branch**: Create a new branch in the repository.
97
98
  - **repo_update_pull_request_status**: Update the status of an existing pull request to active or abandoned.
98
99
  - **repo_update_pull_request**: Update various fields of an existing pull request (title, description, draft status, target branch).
99
100
  - **repo_update_pull_request_reviewers**: Add or remove reviewers for an existing pull request.
@@ -16,6 +16,7 @@ const REPO_TOOLS = {
16
16
  get_branch_by_name: "repo_get_branch_by_name",
17
17
  get_pull_request_by_id: "repo_get_pull_request_by_id",
18
18
  create_pull_request: "repo_create_pull_request",
19
+ create_branch: "repo_create_branch",
19
20
  update_pull_request: "repo_update_pull_request",
20
21
  update_pull_request_reviewers: "repo_update_pull_request_reviewers",
21
22
  reply_to_comment: "repo_reply_to_comment",
@@ -107,6 +108,91 @@ function configureRepoTools(server, tokenProvider, connectionProvider, userAgent
107
108
  content: [{ type: "text", text: JSON.stringify(pullRequest, null, 2) }],
108
109
  };
109
110
  });
111
+ server.tool(REPO_TOOLS.create_branch, "Create a new branch in the repository.", {
112
+ repositoryId: z.string().describe("The ID of the repository where the branch will be created."),
113
+ branchName: z.string().describe("The name of the new branch to create, e.g., 'feature-branch'."),
114
+ sourceBranchName: z.string().optional().default("main").describe("The name of the source branch to create the new branch from. Defaults to 'main'."),
115
+ sourceCommitId: z.string().optional().describe("The commit ID to create the branch from. If not provided, uses the latest commit of the source branch."),
116
+ }, async ({ repositoryId, branchName, sourceBranchName, sourceCommitId }) => {
117
+ const connection = await connectionProvider();
118
+ const gitApi = await connection.getGitApi();
119
+ let commitId = sourceCommitId;
120
+ // If no commit ID is provided, get the latest commit from the source branch
121
+ if (!commitId) {
122
+ const sourceRefName = `refs/heads/${sourceBranchName}`;
123
+ try {
124
+ const sourceBranch = await gitApi.getRefs(repositoryId, undefined, "heads/", false, false, undefined, false, undefined, sourceBranchName);
125
+ const branch = sourceBranch.find((b) => b.name === sourceRefName);
126
+ if (!branch || !branch.objectId) {
127
+ return {
128
+ content: [
129
+ {
130
+ type: "text",
131
+ text: `Error: Source branch '${sourceBranchName}' not found in repository ${repositoryId}`,
132
+ },
133
+ ],
134
+ isError: true,
135
+ };
136
+ }
137
+ commitId = branch.objectId;
138
+ }
139
+ catch (error) {
140
+ return {
141
+ content: [
142
+ {
143
+ type: "text",
144
+ text: `Error retrieving source branch '${sourceBranchName}': ${error instanceof Error ? error.message : String(error)}`,
145
+ },
146
+ ],
147
+ isError: true,
148
+ };
149
+ }
150
+ }
151
+ // Create the new branch using updateRefs
152
+ const newRefName = `refs/heads/${branchName}`;
153
+ const refUpdate = {
154
+ name: newRefName,
155
+ newObjectId: commitId,
156
+ oldObjectId: "0000000000000000000000000000000000000000", // All zeros indicates creating a new ref
157
+ };
158
+ try {
159
+ const result = await gitApi.updateRefs([refUpdate], repositoryId);
160
+ // Check if the branch creation was successful
161
+ if (result && result.length > 0 && result[0].success) {
162
+ return {
163
+ content: [
164
+ {
165
+ type: "text",
166
+ text: `Branch '${branchName}' created successfully from '${sourceBranchName}' (${commitId})`,
167
+ },
168
+ ],
169
+ };
170
+ }
171
+ else {
172
+ const errorMessage = result && result.length > 0 && result[0].customMessage ? result[0].customMessage : "Unknown error occurred during branch creation";
173
+ return {
174
+ content: [
175
+ {
176
+ type: "text",
177
+ text: `Error creating branch '${branchName}': ${errorMessage}`,
178
+ },
179
+ ],
180
+ isError: true,
181
+ };
182
+ }
183
+ }
184
+ catch (error) {
185
+ return {
186
+ content: [
187
+ {
188
+ type: "text",
189
+ text: `Error creating branch '${branchName}': ${error instanceof Error ? error.message : String(error)}`,
190
+ },
191
+ ],
192
+ isError: true,
193
+ };
194
+ }
195
+ });
110
196
  server.tool(REPO_TOOLS.update_pull_request, "Update a Pull Request by ID with specified fields.", {
111
197
  repositoryId: z.string().describe("The ID of the repository where the pull request exists."),
112
198
  pullRequestId: z.number().describe("The ID of the pull request to update."),
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const packageVersion = "2.2.0-nightly.20250925";
1
+ export const packageVersion = "2.2.0-nightly.20250927";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-devops/mcp",
3
- "version": "2.2.0-nightly.20250925",
3
+ "version": "2.2.0-nightly.20250927",
4
4
  "description": "MCP server for interacting with Azure DevOps",
5
5
  "license": "MIT",
6
6
  "author": "Microsoft Corporation",