Skip to content

Commit 1fa4f79

Browse files
fix(devops): add critical instruction to avoid git commands for SFDX commit (#276)
1 parent 7b368cb commit 1fa4f79

File tree

3 files changed

+50
-40
lines changed

3 files changed

+50
-40
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import axios from "axios";
2+
import { getConnection } from "./shared/auth.js";
3+
4+
export interface CommitStatusResult {
5+
requestId: string;
6+
status: string;
7+
recordId?: string;
8+
message: string;
9+
}
10+
11+
export async function fetchCommitStatus(username: string, requestId: string): Promise<CommitStatusResult> {
12+
const connection = await getConnection(username);
13+
const query = `SELECT Id, Status__c, RequestToken__c FROM DevopsRequestInfo WHERE RequestToken__c = '${requestId}' LIMIT 1`;
14+
15+
const response = await axios.get(`${connection.instanceUrl}/services/data/v65.0/query`, {
16+
headers: {
17+
'Authorization': `Bearer ${connection.accessToken}`,
18+
'Content-Type': 'application/json'
19+
},
20+
params: { q: query }
21+
});
22+
23+
if (response.data.records && response.data.records.length > 0) {
24+
const record = response.data.records[0];
25+
return {
26+
requestId,
27+
status: record.Status__c,
28+
recordId: record.Id,
29+
message: `Request ${requestId} has status: ${record.Status__c}`
30+
};
31+
}
32+
33+
return {
34+
requestId,
35+
status: 'NOT_FOUND',
36+
message: `No record found for request ID: ${requestId}`
37+
};
38+
}
39+
40+

packages/mcp-provider-devops/src/tools/checkCommitStatus.ts

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { z } from "zod";
22
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
33
import { McpTool, McpToolConfig, ReleaseState, Toolset, TelemetryService } from "@salesforce/mcp-provider-api";
4-
import axios from "axios";
5-
import { getConnection } from "../shared/auth.js";
4+
import { fetchCommitStatus } from "../getCommitStatus.js";
65

76
const inputSchema = z.object({
87
username: z.string().describe("Username of the DevOps Center org"),
@@ -56,44 +55,13 @@ export class CheckCommitStatus extends McpTool<InputArgsShape, OutputArgsShape>
5655

5756
public async exec(input: InputArgs): Promise<CallToolResult> {
5857
try {
59-
const connection = await getConnection(input.username);
60-
const query = `SELECT Id, Status__c, RequestToken__c FROM DevopsRequestInfo WHERE RequestToken__c = '${input.requestId}' LIMIT 1`;
61-
62-
const response = await axios.get(`${connection.instanceUrl}/services/data/v60.0/query`, {
63-
headers: {
64-
'Authorization': `Bearer ${connection.accessToken}`,
65-
'Content-Type': 'application/json'
66-
},
67-
params: { q: query }
68-
});
69-
70-
if (response.data.records && response.data.records.length > 0) {
71-
const record = response.data.records[0];
72-
const status = {
73-
requestId: input.requestId,
74-
status: record.Status__c,
75-
recordId: record.Id,
76-
message: `Request ${input.requestId} has status: ${record.Status__c}`
77-
};
78-
return {
79-
content: [{
80-
type: "text",
81-
text: JSON.stringify(status, null, 2)
82-
}]
83-
};
84-
} else {
85-
const status = {
86-
requestId: input.requestId,
87-
status: 'NOT_FOUND',
88-
message: `No record found for request ID: ${input.requestId}`
89-
};
90-
return {
91-
content: [{
92-
type: "text",
93-
text: JSON.stringify(status, null, 2)
94-
}]
95-
};
96-
}
58+
const status = await fetchCommitStatus(input.username, input.requestId);
59+
return {
60+
content: [{
61+
type: "text",
62+
text: JSON.stringify(status, null, 2)
63+
}]
64+
};
9765
} catch (error: any) {
9866
return {
9967
content: [{

packages/mcp-provider-devops/src/tools/sfDevopsCommitWorkItem.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ When user asks to "commit work item" or "commit changes", DO NOT use this tool d
4747
4848
**THIS TOOL IS ONLY USED AS THE FINAL STEP AFTER COMPLETING ALL PREREQUISITES**
4949
50+
**CRITICAL:** Never use \`git commit\` to commit SFDX project changes. Always use commit_devops_center_work_item tool to commit SFDX project changes so DevOps Center correctly tracks metadata and ties commits to Work Items.
51+
5052
**MANDATORY workflow for committing work items: DO NOT skip any of the steps and DO NOT move to the next step until the current step is completed.**
5153
1. **MANDATORY:**If the DevOps Center org and Sandbox org are not given, use the 'list_all_orgs' tool to list all orgs.
5254
The list will indicate which org is DevOps Center and a Sandbox. If BOTH these details are not provided in the list, then

0 commit comments

Comments
 (0)