UNPKG

@mcp-apps/azure-devops-mcp-server

Version:

A Model Context Protocol (MCP) server for Azure DevOps integration

96 lines (93 loc) 4.32 kB
"use strict"; 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.gitCommandTool = 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 execute Git commands exports.gitCommandTool = { name: "git-command", description: ` Executes a Git command in the context of an Azure DevOps repository. *Always* prefer this tool over running Git commands in terminal. This tool allows you to run any Git command against a local clone of an Azure DevOps repository. You must specify the local repository path and the Git command to execute. Parameters: - repositoryPath: The local path to the Git repository Example: "C:\\projects\\my-repo" or "/home/user/projects/my-repo" - command: The Git command to execute (without 'git' prefix) Example: "status", "log --oneline -5", "branch -a" - workingDirectory: Optional working directory for the command (defaults to repositoryPath) Example: "C:\\projects\\my-repo\\src" or "/home/user/projects/my-repo/src" `, parameters: { repositoryPath: zod_1.z.string().describe("Local path to the Git repository"), command: zod_1.z.string().describe("Git command to execute (without 'git' prefix)"), workingDirectory: zod_1.z.string().optional().describe("Working directory for the command (defaults to repositoryPath)"), }, handler: async ({ repositoryPath, command, workingDirectory }) => { try { const cwd = workingDirectory || repositoryPath; const fullCommand = `git ${command}`; console.log(`Executing '${fullCommand}' in directory: ${cwd}`); const { stdout, stderr } = await execPromise(fullCommand, { cwd }); if (stderr && stderr.trim() !== '') { // Git sometimes outputs non-error information to stderr return { content: [{ type: "text", text: `Command output (stderr):\n${stderr}\n\nCommand output (stdout):\n${stdout || "No output"}` }], }; } return { content: [{ type: "text", text: stdout || "Command executed successfully with no output." }], }; } catch (error) { console.error("Error executing Git command:", error); const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error executing Git command: ${errorMessage}` }], }; } } }; //# sourceMappingURL=git-command.js.map