Skip to main content
Glama

get-pull-requests

Retrieve pull requests from Azure DevOps repositories filtered by status, creator, or quantity. Automatically integrates with multiple organizations using dynamic authentication.

Instructions

Get pull requests from Azure DevOps repository

Input Schema

NameRequiredDescriptionDefault
createdByNoFilter by creator (user ID or email)
repositoryIdNoRepository ID or name (optional, defaults to all repos)
statusNoPull request status filter (default: active)
topNoNumber of pull requests to return (default: 25)

Input Schema (JSON Schema)

{ "properties": { "createdBy": { "description": "Filter by creator (user ID or email)", "type": "string" }, "repositoryId": { "description": "Repository ID or name (optional, defaults to all repos)", "type": "string" }, "status": { "description": "Pull request status filter (default: active)", "enum": [ "active", "completed", "abandoned", "all" ], "type": "string" }, "top": { "description": "Number of pull requests to return (default: 25)", "type": "number" } }, "type": "object" }

Implementation Reference

  • The handler function that executes the 'get-pull-requests' tool logic. It constructs a query to the Azure DevOps Git pull requests API with optional filters for status, creator, repository ID, and top limit, processes the response, and formats it as MCP content.
    private async getPullRequests(args: any): Promise<any> { try { let endpoint = '/git/pullrequests?api-version=7.1'; const params = []; // Status filter (default to active) const status = args.status || 'active'; if (status !== 'all') { params.push(`searchCriteria.status=${status}`); } // Creator filter if (args.createdBy) { params.push(`searchCriteria.creatorId=${encodeURIComponent(args.createdBy)}`); } // Repository filter if (args.repositoryId) { params.push(`searchCriteria.repositoryId=${encodeURIComponent(args.repositoryId)}`); } // Top (limit) parameter const top = args.top || 25; params.push(`$top=${top}`); if (params.length > 0) { endpoint += '&' + params.join('&'); } const result = await this.makeApiRequest(endpoint); const pullRequests = result.value.map((pr: any) => ({ id: pr.pullRequestId, title: pr.title, description: pr.description, status: pr.status, createdBy: { displayName: pr.createdBy.displayName, uniqueName: pr.createdBy.uniqueName }, creationDate: pr.creationDate, repository: { id: pr.repository.id, name: pr.repository.name }, sourceRefName: pr.sourceRefName, targetRefName: pr.targetRefName, url: pr._links?.web?.href || `${this.currentConfig!.organizationUrl}/${this.currentConfig!.project}/_git/${pr.repository.name}/pullrequest/${pr.pullRequestId}`, isDraft: pr.isDraft || false, mergeStatus: pr.mergeStatus })); return { content: [{ type: 'text', text: JSON.stringify({ count: pullRequests.length, status: status, pullRequests }, null, 2), }], }; } catch (error) { throw new Error(`Failed to get pull requests: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
  • The switch statement in handleToolCall that dispatches the 'get-pull-requests' tool call to the getPullRequests handler method.
    switch (name) { case 'get-work-items': return await this.getWorkItems(args || {}); case 'create-work-item': return await this.createWorkItem(args || {}); case 'update-work-item': return await this.updateWorkItem(args || {}); case 'add-work-item-comment': return await this.addWorkItemComment(args || {}); case 'get-repositories': return await this.getRepositories(args || {}); case 'get-builds': return await this.getBuilds(args || {}); case 'get-pull-requests': return await this.getPullRequests(args || {}); case 'trigger-pipeline': return await this.triggerPipeline(args || {}); case 'get-pipeline-status': return await this.getPipelineStatus(args || {}); default: throw new Error(`Unknown tool: ${name}`); }
  • src/index.ts:260-285 (registration)
    Registers the 'get-pull-requests' tool in the MCP server's listTools handler, providing the tool name, description, and input schema for validation.
    { name: 'get-pull-requests', description: 'Get pull requests from Azure DevOps repository', inputSchema: { type: 'object', properties: { repositoryId: { type: 'string', description: 'Repository ID or name (optional, defaults to all repos)', }, status: { type: 'string', enum: ['active', 'completed', 'abandoned', 'all'], description: 'Pull request status filter (default: active)', }, createdBy: { type: 'string', description: 'Filter by creator (user ID or email)', }, top: { type: 'number', description: 'Number of pull requests to return (default: 25)', }, }, }, },
  • Defines the input schema for the 'get-pull-requests' tool, specifying properties and types for parameters like repositoryId, status, createdBy, and top.
    inputSchema: { type: 'object', properties: { repositoryId: { type: 'string', description: 'Repository ID or name (optional, defaults to all repos)', }, status: { type: 'string', enum: ['active', 'completed', 'abandoned', 'all'], description: 'Pull request status filter (default: active)', }, createdBy: { type: 'string', description: 'Filter by creator (user ID or email)', }, top: { type: 'number', description: 'Number of pull requests to return (default: 25)', }, }, }, },

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/wangkanai/devops-enhanced-mcp'

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