Skip to main content
Glama

create_pull_request

Generate a pull request by specifying title, description, source and target branches, and reviewers. Integrates with the azure-devops MCP Server for streamlined code collaboration.

Instructions

Create a new pull request

Input Schema

NameRequiredDescriptionDefault
descriptionYesDescription of the pull request
reviewersNoArray of reviewer email addresses
sourceBranchYesSource branch name
targetBranchYesTarget branch name
titleYesTitle of the pull request

Input Schema (JSON Schema)

{ "properties": { "description": { "description": "Description of the pull request", "type": "string" }, "reviewers": { "description": "Array of reviewer email addresses", "items": { "type": "string" }, "type": "array" }, "sourceBranch": { "description": "Source branch name", "type": "string" }, "targetBranch": { "description": "Target branch name", "type": "string" }, "title": { "description": "Title of the pull request", "type": "string" } }, "required": [ "title", "description", "sourceBranch", "targetBranch" ], "type": "object" }

Implementation Reference

  • The core handler function for the 'create_pull_request' tool. It validates input using createPullRequestSchema, formats branch refs, calls gitClient.createPullRequest with project/repo details, and returns the created PR as JSON.
    export async function createPullRequest(rawParams: any) { // Parse arguments with defaults from environment variables const params = createPullRequestSchema.parse({ title: rawParams.title, description: rawParams.description, sourceBranch: rawParams.sourceBranch, targetBranch: rawParams.targetBranch, reviewers: rawParams.reviewers, workItemIds: rawParams.workItemIds, isDraft: rawParams.isDraft, }); console.error( "[API] Creating pull request:", JSON.stringify(params, null, 2) ); try { // Get the Git API client const gitClient = await getGitClient(); // Format branch names if they don't have refs/heads/ prefix const sourceBranch = params.sourceBranch.startsWith("refs/") ? params.sourceBranch : `refs/heads/${params.sourceBranch}`; const targetBranch = params.targetBranch.startsWith("refs/") ? params.targetBranch : `refs/heads/${params.targetBranch}`; // Create pull request if (!DEFAULT_PROJECT || !DEFAULT_REPOSITORY) { throw new Error("Default project and repository must be configured"); } const pullRequest = await gitClient.createPullRequest( { sourceRefName: sourceBranch, targetRefName: targetBranch, title: params.title, description: params.description, reviewers: params.reviewers ? params.reviewers.map((email: string) => ({ id: email })) // Assuming email maps to user ID/descriptor : undefined, // Link work items if provided workItemRefs: params.workItemIds ? params.workItemIds.map((id: number) => ({ id: id.toString(), url: `${ORG_URL}/_apis/wit/workItems/${id}`, // Construct work item URL })) : undefined, }, DEFAULT_REPOSITORY, DEFAULT_PROJECT ); console.error(`[API] Created pull request: ${pullRequest.pullRequestId}`); return { content: [ { type: "text", text: JSON.stringify(pullRequest, null, 2), }, ], }; } catch (error) { logError("Error creating pull request", error); throw error; } }
  • Zod schema used for input validation in the createPullRequest handler. Defines required fields like title, description, branches, and optional reviewers, workItemIds.
    export const createPullRequestSchema = z.object({ title: z.string(), description: z.string(), sourceBranch: z.string(), targetBranch: z.string(), reviewers: z.array(z.string()).optional(), workItemIds: z .array(z.number()) .optional() .describe("Array of work item IDs to link"), isDraft: z.boolean().optional(), });
  • src/index.ts:81-82 (registration)
    Registration in the main MCP server request handler switch statement. Dispatches calls to the createPullRequest function.
    case "create_pull_request": return await createPullRequest(request.params.arguments || {});
  • Tool registration in the pullRequestTools array, providing name, description, and JSON inputSchema for the MCP listTools response.
    { name: "create_pull_request", description: "Create a new pull request", inputSchema: { type: "object", properties: { title: { type: "string", description: "Title of the pull request", }, description: { type: "string", description: "Description of the pull request", }, sourceBranch: { type: "string", description: "Source branch name", }, targetBranch: { type: "string", description: "Target branch name", }, reviewers: { type: "array", items: { type: "string" }, description: "Array of reviewer email addresses", }, workItemIds: { type: "array", items: { type: "number" }, description: "Array of work item IDs to link", }, }, required: ["title", "description", "sourceBranch", "targetBranch"], },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mmruesch12/azdo-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server