git_create_pull_request
Create a new pull request in an Azure DevOps repository to merge code changes from a source branch to a target branch, facilitating code review and collaboration.
Instructions
Creates a new pull request in a repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organization | Yes | The name of the Azure DevOps organization | |
| project | Yes | Project ID or name | |
| repositoryId | Yes | The repository ID or name | |
| sourceRefName | Yes | Source branch name (e.g. refs/heads/feature/my-feature) | |
| targetRefName | Yes | Target branch name (e.g. refs/heads/main) | |
| title | Yes | Title of the pull request | |
| description | No | Description of the pull request | |
| isDraft | No | Create as a draft PR |
Implementation Reference
- src/tools/repositories.ts:125-142 (handler)The handler function that creates a pull request by calling the Azure DevOps Git API's createPullRequest method and returns the created PR as JSON.async ({ organization, project, repositoryId, sourceRefName, targetRefName, title, description, isDraft }) => { const connection = await connectionManager.getConnection(organization); const gitApi = await connection.getGitApi(); const prToCreate = { sourceRefName, targetRefName, title, description, isDraft }; const pr = await gitApi.createPullRequest(prToCreate, repositoryId, project); return { content: [{ type: "text", text: JSON.stringify(pr, null, 2) }], }; }
- src/tools/repositories.ts:115-124 (schema)Zod schema defining the input parameters for the git_create_pull_request tool.{ organization: z.string().describe("The name of the Azure DevOps organization"), project: z.string().describe("Project ID or name"), repositoryId: z.string().describe("The repository ID or name"), sourceRefName: z.string().describe("Source branch name (e.g. refs/heads/feature/my-feature)"), targetRefName: z.string().describe("Target branch name (e.g. refs/heads/main)"), title: z.string().describe("Title of the pull request"), description: z.string().optional().describe("Description of the pull request"), isDraft: z.boolean().optional().describe("Create as a draft PR"), },
- src/tools/repositories.ts:112-143 (registration)Registration of the git_create_pull_request tool using server.tool, including name, description, input schema, and handler.server.tool( "git_create_pull_request", "Creates a new pull request in a repository", { organization: z.string().describe("The name of the Azure DevOps organization"), project: z.string().describe("Project ID or name"), repositoryId: z.string().describe("The repository ID or name"), sourceRefName: z.string().describe("Source branch name (e.g. refs/heads/feature/my-feature)"), targetRefName: z.string().describe("Target branch name (e.g. refs/heads/main)"), title: z.string().describe("Title of the pull request"), description: z.string().optional().describe("Description of the pull request"), isDraft: z.boolean().optional().describe("Create as a draft PR"), }, async ({ organization, project, repositoryId, sourceRefName, targetRefName, title, description, isDraft }) => { const connection = await connectionManager.getConnection(organization); const gitApi = await connection.getGitApi(); const prToCreate = { sourceRefName, targetRefName, title, description, isDraft }; const pr = await gitApi.createPullRequest(prToCreate, repositoryId, project); return { content: [{ type: "text", text: JSON.stringify(pr, null, 2) }], }; } );