Skip to content

Commit 44eecbd

Browse files
committed
feat: remove unused field and sobject generation functions from schema tools because these are interactive commands
1 parent 3bd929a commit 44eecbd

File tree

1 file changed

+5
-143
lines changed

1 file changed

+5
-143
lines changed

src/tools/schema.ts

Lines changed: 5 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -3,128 +3,29 @@ import { permissions } from "../config/permissions.js";
33
import { executeSfCommand } from "../utils/sfCommand.js";
44
import z from "zod";
55

6-
const schemaGenerateFieldInputSchema = z.object({
7-
targetOrg: z.string().describe("Target Salesforce Org Alias"),
8-
label: z.string().describe("The field's label"),
9-
object: z
10-
.string()
11-
.optional()
12-
.describe(
13-
"The directory that contains the object's source files (e.g., force-app/main/default/objects/Account or force-app/main/default/objects/MyObject__c)",
14-
),
15-
});
16-
17-
const schemaGenerateField = async (
18-
input: z.infer<typeof schemaGenerateFieldInputSchema>,
19-
) => {
20-
const { targetOrg, label, object } = input;
21-
22-
if (!permissions.isOrgAllowed(targetOrg)) {
23-
return {
24-
error: `Access denied: Organization '${targetOrg}' is not in the allowed list`,
25-
};
26-
}
27-
28-
if (permissions.isReadOnly()) {
29-
return {
30-
error: "Operation not permitted in read-only mode",
31-
};
32-
}
33-
34-
try {
35-
let sfCommand = `sf schema generate field --label "${label}"`;
36-
37-
if (object) {
38-
sfCommand += ` --object "${object}"`;
39-
}
40-
41-
sfCommand += ` --target-org ${targetOrg} --json`;
42-
43-
const result = await executeSfCommand(sfCommand);
44-
return { result };
45-
} catch (error: any) {
46-
return {
47-
error: error.message || "Failed to generate field",
48-
};
49-
}
50-
};
51-
52-
const schemaGenerateSObjectInputSchema = z.object({
53-
targetOrg: z.string().describe("Target Salesforce Org Alias"),
54-
label: z.string().describe("The custom object's label"),
55-
useDefaultFeatures: z
56-
.boolean()
57-
.optional()
58-
.describe(
59-
"Enable all optional features without prompting (Search, Feeds, Reports, History, Activities, Bulk API, Sharing, Streaming API)",
60-
),
61-
});
62-
63-
const schemaGenerateSObject = async (
64-
input: z.infer<typeof schemaGenerateSObjectInputSchema>,
65-
) => {
66-
const { targetOrg, label, useDefaultFeatures } = input;
67-
68-
if (!permissions.isOrgAllowed(targetOrg)) {
69-
return {
70-
error: `Access denied: Organization '${targetOrg}' is not in the allowed list`,
71-
};
72-
}
73-
74-
if (permissions.isReadOnly()) {
75-
return {
76-
error: "Operation not permitted in read-only mode",
77-
};
78-
}
79-
80-
try {
81-
let sfCommand = `sf schema generate sobject --label "${label}"`;
82-
83-
if (useDefaultFeatures) {
84-
sfCommand += " --use-default-features";
85-
}
86-
87-
sfCommand += ` --target-org ${targetOrg} --json`;
88-
89-
const result = await executeSfCommand(sfCommand);
90-
return { result };
91-
} catch (error: any) {
92-
return {
93-
error: error.message || "Failed to generate custom object",
94-
};
95-
}
96-
};
97-
986
const schemaGenerateTabInputSchema = z.object({
99-
targetOrg: z.string().describe("Target Salesforce Org Alias"),
1007
object: z
1018
.string()
1029
.describe("API name of the custom object (e.g., MyObject__c)"),
10310
directory: z
10411
.string()
10512
.describe(
106-
"Path to a 'tabs' directory that will contain the source files",
13+
"Path to a 'tabs' directory that will contain the source files"
10714
),
10815
icon: z
10916
.number()
11017
.min(1)
11118
.max(100)
11219
.default(1)
11320
.describe(
114-
"Number from 1 to 100 that specifies the color scheme and icon for the custom tab",
21+
"Number from 1 to 100 that specifies the color scheme and icon for the custom tab"
11522
),
11623
});
11724

11825
const schemaGenerateTab = async (
119-
input: z.infer<typeof schemaGenerateTabInputSchema>,
26+
input: z.infer<typeof schemaGenerateTabInputSchema>
12027
) => {
121-
const { targetOrg, object, directory, icon } = input;
122-
123-
if (!permissions.isOrgAllowed(targetOrg)) {
124-
return {
125-
error: `Access denied: Organization '${targetOrg}' is not in the allowed list`,
126-
};
127-
}
28+
const { object, directory, icon } = input;
12829

12930
if (permissions.isReadOnly()) {
13031
return {
@@ -134,7 +35,6 @@ const schemaGenerateTab = async (
13435

13536
try {
13637
let sfCommand = `sf schema generate tab --object "${object}" --directory "${directory}" --icon ${icon}`;
137-
sfCommand += ` --target-org ${targetOrg} --json`;
13838

13939
const result = await executeSfCommand(sfCommand);
14040
return { result };
@@ -146,44 +46,6 @@ const schemaGenerateTab = async (
14646
};
14747

14848
export const registerSchemaTools = (server: McpServer) => {
149-
server.tool(
150-
"schema_generate_field",
151-
"Generate metadata source files for a new custom field on a specified object. This command must be run in a Salesforce DX project directory with existing object source files.",
152-
{
153-
input: schemaGenerateFieldInputSchema,
154-
},
155-
async ({ input }) => {
156-
const result = await schemaGenerateField(input);
157-
return {
158-
content: [
159-
{
160-
type: "text",
161-
text: JSON.stringify(result),
162-
},
163-
],
164-
};
165-
},
166-
);
167-
168-
server.tool(
169-
"schema_generate_sobject",
170-
"Generate metadata source files for a new custom object. This command must be run in a Salesforce DX project directory. The command is interactive and will prompt for Name field details.",
171-
{
172-
input: schemaGenerateSObjectInputSchema,
173-
},
174-
async ({ input }) => {
175-
const result = await schemaGenerateSObject(input);
176-
return {
177-
content: [
178-
{
179-
type: "text",
180-
text: JSON.stringify(result),
181-
},
182-
],
183-
};
184-
},
185-
);
186-
18749
server.tool(
18850
"schema_generate_tab",
18951
"Generate metadata source files for a new custom tab on a custom object. Custom tabs display custom object data in Salesforce navigation.",
@@ -200,6 +62,6 @@ export const registerSchemaTools = (server: McpServer) => {
20062
},
20163
],
20264
};
203-
},
65+
}
20466
);
20567
};

0 commit comments

Comments
 (0)