repo_get_pull_request_by_id
Retrieve a specific pull request by its ID from an Azure DevOps repository. Optionally include associated work item references for detailed tracking and management.
Instructions
Get a pull request by its ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| includeWorkItemRefs | No | Whether to reference work items associated with the pull request. | |
| pullRequestId | Yes | The ID of the pull request to retrieve. | |
| repositoryId | Yes | The ID of the repository where the pull request is located. |
Implementation Reference
- src/tools/repos.ts:583-590 (handler)The handler function retrieves the specified pull request using the Azure DevOps Git API's getPullRequest method and returns its details as a JSON-formatted text response.async ({ repositoryId, pullRequestId, includeWorkItemRefs }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); const pullRequest = await gitApi.getPullRequest(repositoryId, pullRequestId, undefined, undefined, undefined, undefined, undefined, includeWorkItemRefs); return { content: [{ type: "text", text: JSON.stringify(pullRequest, null, 2) }], }; }
- src/tools/repos.ts:578-582 (schema)Zod schema defining the input parameters for the tool: repositoryId (string), pullRequestId (number), and optional includeWorkItemRefs (boolean).{ repositoryId: z.string().describe("The ID of the repository where the pull request is located."), pullRequestId: z.number().describe("The ID of the pull request to retrieve."), includeWorkItemRefs: z.boolean().optional().default(false).describe("Whether to reference work items associated with the pull request."), },
- src/tools/repos.ts:575-591 (registration)Registration of the tool using McpServer.tool(), associating the name REPO_TOOLS.get_pull_request_by_id ("repo_get_pull_request_by_id") with its description, input schema, and handler function.server.tool( REPO_TOOLS.get_pull_request_by_id, "Get a pull request by its ID.", { repositoryId: z.string().describe("The ID of the repository where the pull request is located."), pullRequestId: z.number().describe("The ID of the pull request to retrieve."), includeWorkItemRefs: z.boolean().optional().default(false).describe("Whether to reference work items associated with the pull request."), }, async ({ repositoryId, pullRequestId, includeWorkItemRefs }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); const pullRequest = await gitApi.getPullRequest(repositoryId, pullRequestId, undefined, undefined, undefined, undefined, undefined, includeWorkItemRefs); return { content: [{ type: "text", text: JSON.stringify(pullRequest, null, 2) }], }; } );
- src/tools/repos.ts:35-35 (registration)Mapping in REPO_TOOLS constant that associates the internal identifier 'get_pull_request_by_id' with the tool name 'repo_get_pull_request_by_id'.get_pull_request_by_id: "repo_get_pull_request_by_id",