Skip to content

Commit 49f5f59

Browse files
Add CommentThreadStatus parameter to repos.create_pull_request_thread (#357)
Add CommentThreadStatus parameter to repos.create_pull_request_thread to fix all comments being created with "Unknown" status ## GitHub issue number [339](#339) ## **Associated Risks** N/A ## ✅ **PR Checklist** - [x] **I have read the [contribution guidelines](https://github.com/microsoft/azure-devops-mcp/blob/main/CONTRIBUTING.md)** - [x] **I have read the [code of conduct guidelines](https://github.com/microsoft/azure-devops-mcp/blob/main/CODE_OF_CONDUCT.md)** - [x] Title of the pull request is clear and informative. - [x] 👌 Code hygiene - [x] 🔭 Telemetry added, updated, or N/A - [x] 📄 Documentation added, updated, or N/A - [x] 🛡️ Automated tests added, or N/A ## 🧪 **How did you test it?** Used GPT-4.1 with prompt "Create a comment on {PR url} with the content "Test 123" and status of Fixed" <img width="441" height="491" alt="pr_review_1" src="https://github.com/user-attachments/assets/56e10956-bb6c-4ef9-b798-658fe0a71c8c" /> <img width="1749" height="192" alt="pr_review_2" src="https://github.com/user-attachments/assets/26518526-50a8-442c-8c04-d7e2e9a77ea5" />
1 parent 09ac13c commit 49f5f59

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/tools/repos.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
GitPullRequestQueryInput,
1616
GitPullRequestQueryType,
1717
CommentThreadContext,
18+
CommentThreadStatus,
1819
} from "azure-devops-node-api/interfaces/GitInterfaces.js";
1920
import { z } from "zod";
2021
import { getCurrentUserDetails } from "./auth.js";
@@ -603,6 +604,11 @@ function configureRepoTools(server: McpServer, tokenProvider: () => Promise<Acce
603604
content: z.string().describe("The content of the comment to be added."),
604605
project: z.string().optional().describe("Project ID or project name (optional)"),
605606
filePath: z.string().optional().describe("The path of the file where the comment thread will be created. (optional)"),
607+
status: z
608+
.enum(getEnumKeys(CommentThreadStatus) as [string, ...string[]])
609+
.optional()
610+
.default(CommentThreadStatus[CommentThreadStatus.Active])
611+
.describe("The status of the comment thread. Defaults to 'Active'."),
606612
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)"),
607613
rightFileStartOffset: z
608614
.number()
@@ -623,7 +629,7 @@ function configureRepoTools(server: McpServer, tokenProvider: () => Promise<Acce
623629
"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)"
624630
),
625631
},
626-
async ({ repositoryId, pullRequestId, content, project, filePath, rightFileStartLine, rightFileStartOffset, rightFileEndLine, rightFileEndOffset }) => {
632+
async ({ repositoryId, pullRequestId, content, project, filePath, status, rightFileStartLine, rightFileStartOffset, rightFileEndLine, rightFileEndOffset }) => {
627633
const connection = await connectionProvider();
628634
const gitApi = await connection.getGitApi();
629635

@@ -665,7 +671,12 @@ function configureRepoTools(server: McpServer, tokenProvider: () => Promise<Acce
665671
}
666672
}
667673

668-
const thread = await gitApi.createThread({ comments: [{ content: content }], threadContext: threadContext }, repositoryId, pullRequestId, project);
674+
const thread = await gitApi.createThread(
675+
{ comments: [{ content: content }], threadContext: threadContext, status: CommentThreadStatus[status as keyof typeof CommentThreadStatus] },
676+
repositoryId,
677+
pullRequestId,
678+
project
679+
);
669680

670681
return {
671682
content: [{ type: "text", text: JSON.stringify(thread, null, 2) }],

0 commit comments

Comments
 (0)