@mcp-apps/azure-devops-mcp-server
Version:
A Model Context Protocol (MCP) server for Azure DevOps integration
107 lines (105 loc) • 4.7 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.pushChangesTool = void 0;
const zod_1 = require("zod");
const child_process = __importStar(require("child_process"));
const util = __importStar(require("util"));
const execPromise = util.promisify(child_process.exec);
// Tool to push changes to remote
exports.pushChangesTool = {
name: "git-push-changes",
description: `
Pushes local Git changes to an Azure DevOps repository.
This tool pushes commits from your local branch to a remote branch in Azure DevOps.
Parameters:
- repositoryPath: The local path to the Git repository
Example: "C:\\projects\\my-repo" or "/home/user/projects/my-repo"
- remoteName: The name of the remote to push to (default: "origin")
Example: "origin", "upstream"
- branchName: The name of the branch to push
Example: "main", "feature/login"
- setUpstream: Whether to set up tracking for the branch (default: false)
Example: true, false
- force: Whether to force push the changes (default: false)
Example: true, false
`,
parameters: {
repositoryPath: zod_1.z.string().describe("Local path to the Git repository"),
remoteName: zod_1.z.string().default("origin").describe("Name of the remote to push to"),
branchName: zod_1.z.string().describe("Name of the branch to push"),
setUpstream: zod_1.z.boolean().default(false).describe("Whether to set up tracking for the branch"),
force: zod_1.z.boolean().default(false).describe("Whether to force push the changes"),
},
handler: async ({ repositoryPath, remoteName, branchName, setUpstream, force }) => {
try {
// Build the push command
let command = "push";
if (setUpstream) {
command += " --set-upstream";
}
if (force) {
command += " --force";
}
command += ` "${remoteName}" "${branchName}"`;
// Execute the command
const { stdout, stderr } = await execPromise(`git ${command}`, { cwd: repositoryPath });
// Git push typically outputs to stderr for progress information
if (stderr && !stderr.includes("remote:") && !stderr.includes("To ")) {
return {
content: [{
type: "text",
text: `Warning during push:\n${stderr}\n\n${stdout ? `Output: ${stdout}` : ''}`
}],
};
}
const fullOutput = [stdout, stderr].filter(Boolean).join("\n");
return {
content: [{
type: "text",
text: `Changes pushed successfully to ${remoteName}/${branchName}.\n\n${fullOutput}`
}],
};
}
catch (error) {
console.error("Error pushing changes:", error);
const errorMessage = error instanceof Error ? error.message : String(error);
return {
content: [{ type: "text", text: `Error pushing changes: ${errorMessage}` }],
};
}
}
};
//# sourceMappingURL=git-push-changes.js.map