Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

get_pull_request_comments

Retrieve comments from a specific Azure DevOps pull request to review feedback, track discussions, and monitor code review progress.

Instructions

Get comments from a specific pull request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoThe ID or name of the project (Default: MyProject)
organizationIdNoThe ID or name of the organization (Default: mycompany)
repositoryIdYesThe ID or name of the repository
pullRequestIdYesThe ID of the pull request
threadIdNoThe ID of the specific thread to get comments from
includeDeletedNoWhether to include deleted comments
topNoMaximum number of threads/comments to return

Implementation Reference

  • Core handler function that fetches and transforms pull request comment threads using the Azure DevOps Git API, supporting specific thread retrieval, deleted comments, and pagination.
    export async function getPullRequestComments(
      connection: WebApi,
      projectId: string,
      repositoryId: string,
      pullRequestId: number,
      options: GetPullRequestCommentsOptions,
    ): Promise<CommentThreadWithStringEnums[]> {
      try {
        const gitApi = await connection.getGitApi();
    
        if (options.threadId) {
          // If a specific thread is requested, only return that thread
          const thread = await gitApi.getPullRequestThread(
            repositoryId,
            pullRequestId,
            options.threadId,
            projectId,
          );
          return thread ? [transformThread(thread)] : [];
        } else {
          // Otherwise, get all threads
          const threads = await gitApi.getThreads(
            repositoryId,
            pullRequestId,
            projectId,
            undefined, // iteration
            options.includeDeleted ? 1 : undefined, // Convert boolean to number (1 = include deleted)
          );
    
          // Transform and return all threads (with pagination if top is specified)
          const transformedThreads = (threads || []).map(transformThread);
          if (options.top) {
            return transformedThreads.slice(0, options.top);
          }
          return transformedThreads;
        }
      } catch (error) {
        if (error instanceof AzureDevOpsError) {
          throw error;
        }
        throw new Error(
          `Failed to get pull request comments: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
  • Zod input schema for validating parameters to the get_pull_request_comments tool.
    export const GetPullRequestCommentsSchema = z.object({
      projectId: z
        .string()
        .optional()
        .describe(`The ID or name of the project (Default: ${defaultProject})`),
      organizationId: z
        .string()
        .optional()
        .describe(`The ID or name of the organization (Default: ${defaultOrg})`),
      repositoryId: z.string().describe('The ID or name of the repository'),
      pullRequestId: z.number().describe('The ID of the pull request'),
      threadId: z
        .number()
        .optional()
        .describe('The ID of the specific thread to get comments from'),
      includeDeleted: z
        .boolean()
        .optional()
        .describe('Whether to include deleted comments'),
      top: z
        .number()
        .optional()
        .describe('Maximum number of threads/comments to return'),
    });
  • MCP tool definition registration with name, description, and JSON schema derived from Zod schema.
    {
      name: 'get_pull_request_comments',
      description: 'Get comments from a specific pull request',
      inputSchema: zodToJsonSchema(GetPullRequestCommentsSchema),
    },
  • Request handler dispatch case that parses input with schema and invokes the getPullRequestComments handler.
    case 'get_pull_request_comments': {
      const params = GetPullRequestCommentsSchema.parse(
        request.params.arguments,
      );
      const result = await getPullRequestComments(
        connection,
        params.projectId ?? defaultProject,
        params.repositoryId,
        params.pullRequestId,
        {
          projectId: params.projectId ?? defaultProject,
          repositoryId: params.repositoryId,
          pullRequestId: params.pullRequestId,
          threadId: params.threadId,
          includeDeleted: params.includeDeleted,
          top: params.top,
        },
      );
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Helper function to transform Azure DevOps comment threads and comments into types with string enums and additional file position fields.
    function transformThread(
      thread: GitPullRequestCommentThread,
    ): CommentThreadWithStringEnums {
      if (!thread.comments) {
        return {
          ...thread,
          status: transformCommentThreadStatus(thread.status),
          comments: undefined,
        };
      }
    
      // Get file path and positions from thread context
      const filePath = thread.threadContext?.filePath;
      const leftFileStart =
        thread.threadContext && 'leftFileStart' in thread.threadContext
          ? thread.threadContext.leftFileStart
          : undefined;
      const leftFileEnd =
        thread.threadContext && 'leftFileEnd' in thread.threadContext
          ? thread.threadContext.leftFileEnd
          : undefined;
      const rightFileStart =
        thread.threadContext && 'rightFileStart' in thread.threadContext
          ? thread.threadContext.rightFileStart
          : undefined;
      const rightFileEnd =
        thread.threadContext && 'rightFileEnd' in thread.threadContext
          ? thread.threadContext.rightFileEnd
          : undefined;
    
      // Transform each comment to include the new fields and string enums
      const transformedComments = thread.comments.map((comment) => ({
        ...comment,
        filePath,
        leftFileStart,
        leftFileEnd,
        rightFileStart,
        rightFileEnd,
        // Transform enum values to strings
        commentType: transformCommentType(comment.commentType),
      }));
    
      return {
        ...thread,
        comments: transformedComments,
        // Transform thread status to string
        status: transformCommentThreadStatus(thread.status),
      };
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states a read operation ('Get'), but fails to describe key traits like pagination (implied by 'top' parameter), authentication needs, rate limits, error handling, or return format. For a tool with 7 parameters and no annotations, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded and appropriately sized for the tool's purpose, avoiding unnecessary elaboration. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (7 parameters, no annotations, no output schema), the description is incomplete. It lacks behavioral context, usage guidelines, and output details, leaving gaps for an AI agent to infer how to invoke it correctly. It's inadequate for a tool with this parameter count and no structured support.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 7 parameters. The description adds no meaning beyond the schema—it doesn't explain parameter interactions (e.g., 'threadId' vs. 'top'), default behaviors, or examples. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the purpose ('Get comments from a specific pull request') with a clear verb ('Get') and resource ('comments'), but it's vague about scope (e.g., all comments vs. filtered) and doesn't distinguish from siblings like 'get_pull_request_changes' or 'add_pull_request_comment'. It meets the basic requirement but lacks specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_pull_request_changes' for different PR data or 'add_pull_request_comment' for adding comments, nor does it specify prerequisites or exclusions. The description alone offers no usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Tiberriver256/mcp-server-azure-devops'

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