ADO PR Comment Publish
Publish a PR comment draft file to post comments, replies, or resolve threads.
CRITICAL: Preview Before All Mutations
NEVER execute without showing the user a preview first.
For every publish operation:
- •Read the draft file
- •Validate frontmatter completeness
- •Resolve repository GUID (required by ADO MCP)
- •Show preview with exact content
- •Ask for approval explicitly
- •Only then execute the MCP call
- •Update draft file with published status
If the user hasn't approved, DO NOT execute.
CRITICAL: Repository GUID Required
The ADO MCP requires repository GUIDs, not names.
Before any MCP call, resolve the repository:
mcp__azure-devops__repo_get_repo_by_name_or_id:
project: "{project}"
repositoryNameOrId: "{repository}"
Extract the id field from the response and use that as repositoryId in subsequent calls.
CRITICAL: project is REQUIRED for ALL MCP calls
Every MCP call WILL FAIL without project. Always include it.
Loading MCP Tools
Load ADO tools at the start:
ToolSearch query: "+azure-devops repo_get_repo_by_name_or_id" ToolSearch query: "+azure-devops repo_create_pull_request_thread" ToolSearch query: "+azure-devops repo_reply_to_comment" ToolSearch query: "+azure-devops repo_update_pull_request_thread"
Workflow
- •Read draft file from provided path
- •Parse frontmatter and body content
- •Validate required fields for action type
- •Resolve repository GUID via MCP lookup
- •Show preview in box format
- •Ask for explicit approval
- •Execute appropriate MCP call
- •Update draft with
status: publishedand thread ID - •Return confirmation with PR URL
Input
User provides path to a draft file:
/dataops-assistant:ado-pr-comment-publish .ado-drafts/20250210-143022-pr-comment-nil-check.md
Validation
Comment Action
- •
projectmust be present - •
repositorymust be present - •
pull_request_idmust be present - •Body must have content
Reply Action
- •All of the above, plus:
- •
thread_idmust be present
Resolve Action
- •All of the above, plus:
- •
thread_idmust be present - •
resolve_statusmust be valid (fixed, wontFix, closed, byDesign)
If validation fails, show error and stop:
Cannot publish: Missing required field 'thread_id' for reply action.
Preview Format
For New Comment
+-----------------------------------------------------+ | PREVIEW: Add Comment | +-----------------------------------------------------+ | Target: PR #12345 in project/repo | | Location: /src/retry.go:42 | | | | Comment: | | --------- | | Consider adding a nil check here - `config.Retry` | | could be nil if the config file doesn't have a | | retry section. | +-----------------------------------------------------+ Post this comment?
For Reply
+-----------------------------------------------------+ | PREVIEW: Reply to Thread | +-----------------------------------------------------+ | Target: PR #12345, Thread #67890 | | | | Reply: | | ------- | | Good catch! I've added the nil check in commit | | `a1b2c3d`. | +-----------------------------------------------------+ Post this reply?
For Resolve
+-----------------------------------------------------+ | PREVIEW: Resolve Thread | +-----------------------------------------------------+ | Target: PR #12345, Thread #67890 | | Status: fixed | | | | Comment (optional): | | ------------------ | | Addressed in latest commit. | +-----------------------------------------------------+ Resolve this thread?
MCP Execution
New Comment (Line-Specific)
mcp__azure-devops__repo_create_pull_request_thread:
project: "{project}"
repositoryId: "{repository_guid}"
pullRequestId: {pull_request_id}
threadContext:
filePath: "{file_path}"
rightFileStart:
line: {line_number}
offset: 1
rightFileEnd:
line: {line_number}
offset: 1
comments:
- content: "{comment_body}"
commentType: 1
status: "active"
New Comment (General)
mcp__azure-devops__repo_create_pull_request_thread:
project: "{project}"
repositoryId: "{repository_guid}"
pullRequestId: {pull_request_id}
comments:
- content: "{comment_body}"
commentType: 1
status: "active"
Reply to Thread
mcp__azure-devops__repo_reply_to_comment:
project: "{project}"
repositoryId: "{repository_guid}"
pullRequestId: {pull_request_id}
threadId: {thread_id}
content: "{reply_body}"
Resolve Thread
First add optional comment (if body present), then update status:
# Optional: Add closing comment
mcp__azure-devops__repo_reply_to_comment:
project: "{project}"
repositoryId: "{repository_guid}"
pullRequestId: {pull_request_id}
threadId: {thread_id}
content: "{resolve_comment}"
# Update thread status
mcp__azure-devops__repo_update_pull_request_thread:
project: "{project}"
repositoryId: "{repository_guid}"
pullRequestId: {pull_request_id}
threadId: {thread_id}
status: "{resolve_status}"
Post-Publish Updates
After successful publish, update the draft file:
- •Change
status: drafttostatus: published - •For new comments: Add
published_thread_id: {thread_id}from response - •Write updated file back
Example update:
# Before status: draft published_thread_id: null # After status: published published_thread_id: 98765
Output
Success
Posted successfully! PR: https://dev.azure.com/org/project/_git/repo/pullrequest/12345 Thread: #98765 Draft updated: .ado-drafts/20250210-143022-pr-comment-nil-check.md
Failure
Failed to post comment: Error: [error message from MCP] Draft NOT modified. Fix the issue and try again.
Example Session
User: /dataops-assistant:ado-pr-comment-publish .ado-drafts/20250210-143022-pr-comment-nil-check.md
Response:
+-----------------------------------------------------+
| PREVIEW: Add Comment |
+-----------------------------------------------------+
| Target: PR #12345 in clinical-matching/cms-service |
| Location: /src/retry.go:42 |
| |
| Comment: |
| --------- |
| Consider adding a nil check here - `config.Retry` |
| could be nil if the config file doesn't have a |
| retry section. |
| |
| ```go |
| if config.Retry == nil { |
| return defaultRetryConfig() |
| } |
| ``` |
+-----------------------------------------------------+
Post this comment?
User: Yes
Response:
Posted successfully! PR: https://dev.azure.com/mcgsead/clinical-matching/_git/cms-service/pullrequest/12345 Thread: #98765 Draft updated: .ado-drafts/20250210-143022-pr-comment-nil-check.md
Rules
- •ALWAYS preview before execution - No exceptions
- •ALWAYS ask for approval - User must explicitly confirm
- •ALWAYS resolve repository GUID - MCP requires GUIDs, not names
- •ALWAYS include project - Required for all MCP calls
- •Validate before preview - Don't show preview if fields missing
- •Update draft after publish - Mark as published with thread ID
- •Don't modify draft on failure - Only update on success