UNPKG

@advanced-communities/salesforce-mcp-server

Version:

MCP server enabling AI assistants to interact with Salesforce orgs through the Salesforce CLI

51 lines (50 loc) 1.71 kB
import { permissions } from "../config/permissions.js"; import { executeSfCommand } from "../utils/sfCommand.js"; import z from "zod"; const schemaGenerateTabInputSchema = z.object({ object: z .string() .describe("API name of the custom object (e.g., MyObject__c)"), directory: z .string() .describe("Path to a 'tabs' directory that will contain the source files"), icon: z .number() .min(1) .max(100) .default(1) .describe("Number from 1 to 100 that specifies the color scheme and icon for the custom tab"), }); const schemaGenerateTab = async (input) => { const { object, directory, icon } = input; if (permissions.isReadOnly()) { return { error: "Operation not permitted in read-only mode", }; } try { let sfCommand = `sf schema generate tab --object "${object}" --directory "${directory}" --icon ${icon}`; const result = await executeSfCommand(sfCommand); return { result }; } catch (error) { return { error: error.message || "Failed to generate tab", }; } }; export const registerSchemaTools = (server) => { server.tool("schema_generate_tab", "Generate metadata source files for a new custom tab on a custom object. Custom tabs display custom object data in Salesforce navigation.", { input: schemaGenerateTabInputSchema, }, async ({ input }) => { const result = await schemaGenerateTab(input); return { content: [ { type: "text", text: JSON.stringify(result), }, ], }; }); };