Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

repo_create_pull_request_thread

Add a comment thread to a specific pull request in Azure DevOps, enabling detailed discussions on files or code sections using repository ID, pull request ID, and content.

Instructions

Creates a new comment thread on a pull request.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe content of the comment to be added.
filePathNoThe path of the file where the comment thread will be created. (optional)
projectNoProject ID or project name (optional)
pullRequestIdYesThe ID of the pull request where the comment thread exists.
repositoryIdYesThe ID of the repository where the pull request is located.
rightFileEndLineNoPosition of last character of the thread's span in right file. The line number of a thread's position. Starts at 1. Must only be set if rightFileStartLine is also specified. (optional)
rightFileEndOffsetNoPosition of last character of the thread's span in right file. The character offset of a thread's position inside of a line. Must only be set if rightFileEndLine is also specified. (optional)
rightFileStartLineNoPosition of first character of the thread's span in right file. The line number of a thread's position. Starts at 1. (optional)
rightFileStartOffsetNoPosition of first character of the thread's span in right file. The line number of a thread's position. The character offset of a thread's position inside of a line. Starts at 1. Must only be set if rightFileStartLine is also specified. (optional)
statusNoThe status of the comment thread. Defaults to 'Active'.Active

Implementation Reference

  • The handler function for the 'repo_create_pull_request_thread' tool. It constructs a CommentThreadContext based on provided parameters and uses the Azure DevOps Git API to create a new comment thread on the specified pull request.
    async ({ repositoryId, pullRequestId, content, project, filePath, status, rightFileStartLine, rightFileStartOffset, rightFileEndLine, rightFileEndOffset }) => {
      const connection = await connectionProvider();
      const gitApi = await connection.getGitApi();
    
      const threadContext: CommentThreadContext = { filePath: filePath };
    
      if (rightFileStartLine !== undefined) {
        if (rightFileStartLine < 1) {
          throw new Error("rightFileStartLine must be greater than or equal to 1.");
        }
    
        threadContext.rightFileStart = { line: rightFileStartLine };
    
        if (rightFileStartOffset !== undefined) {
          if (rightFileStartOffset < 1) {
            throw new Error("rightFileStartOffset must be greater than or equal to 1.");
          }
    
          threadContext.rightFileStart.offset = rightFileStartOffset;
        }
      }
    
      if (rightFileEndLine !== undefined) {
        if (rightFileStartLine === undefined) {
          throw new Error("rightFileEndLine must only be specified if rightFileStartLine is also specified.");
        }
    
        if (rightFileEndLine < 1) {
          throw new Error("rightFileEndLine must be greater than or equal to 1.");
        }
    
        threadContext.rightFileEnd = { line: rightFileEndLine };
    
        if (rightFileEndOffset !== undefined) {
          if (rightFileEndOffset < 1) {
            throw new Error("rightFileEndOffset must be greater than or equal to 1.");
          }
    
          threadContext.rightFileEnd.offset = rightFileEndOffset;
        }
      }
    
      const thread = await gitApi.createThread(
        { comments: [{ content: content }], threadContext: threadContext, status: CommentThreadStatus[status as keyof typeof CommentThreadStatus] },
        repositoryId,
        pullRequestId,
        project
      );
    
      return {
        content: [{ type: "text", text: JSON.stringify(thread, null, 2) }],
      };
    }
  • Zod schema defining the input parameters for the 'repo_create_pull_request_thread' tool, including repositoryId, pullRequestId, content, and optional positioning parameters.
      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 where the comment thread exists."),
      content: z.string().describe("The content of the comment to be added."),
      project: z.string().optional().describe("Project ID or project name (optional)"),
      filePath: z.string().optional().describe("The path of the file where the comment thread will be created. (optional)"),
      status: z
        .enum(getEnumKeys(CommentThreadStatus) as [string, ...string[]])
        .optional()
        .default(CommentThreadStatus[CommentThreadStatus.Active])
        .describe("The status of the comment thread. Defaults to 'Active'."),
      rightFileStartLine: z.number().optional().describe("Position of first character of the thread's span in right file. The line number of a thread's position. Starts at 1. (optional)"),
      rightFileStartOffset: z
        .number()
        .optional()
        .describe(
          "Position of first character of the thread's span in right file. The line number of a thread's position. The character offset of a thread's position inside of a line. Starts at 1. Must only be set if rightFileStartLine is also specified. (optional)"
        ),
      rightFileEndLine: z
        .number()
        .optional()
        .describe(
          "Position of last character of the thread's span in right file. The line number of a thread's position. Starts at 1. Must only be set if rightFileStartLine is also specified. (optional)"
        ),
      rightFileEndOffset: z
        .number()
        .optional()
        .describe(
          "Position of last character of the thread's span in right file. The character offset of a thread's position inside of a line. Must only be set if rightFileEndLine is also specified. (optional)"
        ),
    },
  • The server.tool call that registers the 'repo_create_pull_request_thread' tool with its schema and handler.
    server.tool(
      REPO_TOOLS.create_pull_request_thread,
      "Creates a new comment thread on a pull request.",
      {
        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 where the comment thread exists."),
        content: z.string().describe("The content of the comment to be added."),
        project: z.string().optional().describe("Project ID or project name (optional)"),
        filePath: z.string().optional().describe("The path of the file where the comment thread will be created. (optional)"),
        status: z
          .enum(getEnumKeys(CommentThreadStatus) as [string, ...string[]])
          .optional()
          .default(CommentThreadStatus[CommentThreadStatus.Active])
          .describe("The status of the comment thread. Defaults to 'Active'."),
        rightFileStartLine: z.number().optional().describe("Position of first character of the thread's span in right file. The line number of a thread's position. Starts at 1. (optional)"),
        rightFileStartOffset: z
          .number()
          .optional()
          .describe(
            "Position of first character of the thread's span in right file. The line number of a thread's position. The character offset of a thread's position inside of a line. Starts at 1. Must only be set if rightFileStartLine is also specified. (optional)"
          ),
        rightFileEndLine: z
          .number()
          .optional()
          .describe(
            "Position of last character of the thread's span in right file. The line number of a thread's position. Starts at 1. Must only be set if rightFileStartLine is also specified. (optional)"
          ),
        rightFileEndOffset: z
          .number()
          .optional()
          .describe(
            "Position of last character of the thread's span in right file. The character offset of a thread's position inside of a line. Must only be set if rightFileEndLine is also specified. (optional)"
          ),
      },
      async ({ repositoryId, pullRequestId, content, project, filePath, status, rightFileStartLine, rightFileStartOffset, rightFileEndLine, rightFileEndOffset }) => {
        const connection = await connectionProvider();
        const gitApi = await connection.getGitApi();
    
        const threadContext: CommentThreadContext = { filePath: filePath };
    
        if (rightFileStartLine !== undefined) {
          if (rightFileStartLine < 1) {
            throw new Error("rightFileStartLine must be greater than or equal to 1.");
          }
    
          threadContext.rightFileStart = { line: rightFileStartLine };
    
          if (rightFileStartOffset !== undefined) {
            if (rightFileStartOffset < 1) {
              throw new Error("rightFileStartOffset must be greater than or equal to 1.");
            }
    
            threadContext.rightFileStart.offset = rightFileStartOffset;
          }
        }
    
        if (rightFileEndLine !== undefined) {
          if (rightFileStartLine === undefined) {
            throw new Error("rightFileEndLine must only be specified if rightFileStartLine is also specified.");
          }
    
          if (rightFileEndLine < 1) {
            throw new Error("rightFileEndLine must be greater than or equal to 1.");
          }
    
          threadContext.rightFileEnd = { line: rightFileEndLine };
    
          if (rightFileEndOffset !== undefined) {
            if (rightFileEndOffset < 1) {
              throw new Error("rightFileEndOffset must be greater than or equal to 1.");
            }
    
            threadContext.rightFileEnd.offset = rightFileEndOffset;
          }
        }
    
        const thread = await gitApi.createThread(
          { comments: [{ content: content }], threadContext: threadContext, status: CommentThreadStatus[status as keyof typeof CommentThreadStatus] },
          repositoryId,
          pullRequestId,
          project
        );
    
        return {
          content: [{ type: "text", text: JSON.stringify(thread, null, 2) }],
        };
      }
    );
  • Constant object mapping internal tool names to their string identifiers, used for registration.
    const REPO_TOOLS = {
      list_repos_by_project: "repo_list_repos_by_project",
      list_pull_requests_by_repo: "repo_list_pull_requests_by_repo",
      list_pull_requests_by_project: "repo_list_pull_requests_by_project",
      list_branches_by_repo: "repo_list_branches_by_repo",
      list_my_branches_by_repo: "repo_list_my_branches_by_repo",
      list_pull_request_threads: "repo_list_pull_request_threads",
      list_pull_request_thread_comments: "repo_list_pull_request_thread_comments",
      get_repo_by_name_or_id: "repo_get_repo_by_name_or_id",
      get_branch_by_name: "repo_get_branch_by_name",
      get_pull_request_by_id: "repo_get_pull_request_by_id",
      create_pull_request: "repo_create_pull_request",
      update_pull_request: "repo_update_pull_request",
      update_pull_request_reviewers: "repo_update_pull_request_reviewers",
      reply_to_comment: "repo_reply_to_comment",
      create_pull_request_thread: "repo_create_pull_request_thread",
      resolve_comment: "repo_resolve_comment",
      search_commits: "repo_search_commits",
      list_pull_requests_by_commits: "repo_list_pull_requests_by_commits",
    };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool creates a comment thread but doesn't mention permissions required, whether this is a write operation (implied but not explicit), rate limits, or what happens on success/failure. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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?

For a mutation tool with 10 parameters, no annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like permissions, side effects, or response format, leaving significant gaps for the agent to infer or guess.

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?

The schema description coverage is 100%, meaning all parameters are documented in the schema itself. The description adds no additional parameter information beyond what's in the schema (e.g., it doesn't explain relationships between parameters like filePath and line offsets). Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Creates') and target ('new comment thread on a pull request'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'repo_reply_to_comment' or 'repo_resolve_comment', which also involve pull request comments, so it misses full sibling differentiation.

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. The description doesn't mention prerequisites, context (e.g., when to create a thread vs. reply to an existing one), or exclusions, leaving the agent with no usage direction beyond the basic purpose.

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

Related 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/ennuiii/DevOpsMcpPAT'

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