salesforce_describe_object
Retrieve comprehensive schema metadata for Salesforce objects, including all fields, relationships, and field properties to understand data structures.
Instructions
Get detailed schema metadata including all fields, relationships, and field properties of any Salesforce object. Examples: 'Account' shows all Account fields including custom fields; 'Case' shows all Case fields including relationships to Account, Contact etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| objectName | Yes | API name of the object (e.g., 'Account', 'Contact', 'Custom_Object__c') |
Implementation Reference
- src/tools/describe.ts:19-40 (handler)The core handler function that executes the Salesforce describe operation using conn.describe(), formats the fields with types, requirements, references, and picklist values, and returns a formatted text response.export async function handleDescribeObject(conn: any, objectName: string) { const describe = await conn.describe(objectName) as SalesforceDescribeResponse; // Format the output const formattedDescription = ` Object: ${describe.name} (${describe.label})${describe.custom ? ' (Custom Object)' : ''} Fields: ${describe.fields.map((field: SalesforceField) => ` - ${field.name} (${field.label}) Type: ${field.type}${field.length ? `, Length: ${field.length}` : ''} Required: ${!field.nillable} ${field.referenceTo && field.referenceTo.length > 0 ? `References: ${field.referenceTo.join(', ')}` : ''} ${field.picklistValues && field.picklistValues.length > 0 ? `Picklist Values: ${field.picklistValues.map((v: { value: string }) => v.value).join(', ')}` : ''}` ).join('\n')}`; return { content: [{ type: "text", text: formattedDescription }], isError: false, }; }
- src/tools/describe.ts:4-17 (schema)The tool definition including name, description, and input schema for validating the objectName parameter.export const DESCRIBE_OBJECT: Tool = { name: "salesforce_describe_object", description: "Get detailed schema metadata including all fields, relationships, and field properties of any Salesforce object. Examples: 'Account' shows all Account fields including custom fields; 'Case' shows all Case fields including relationships to Account, Contact etc.", inputSchema: { type: "object", properties: { objectName: { type: "string", description: "API name of the object (e.g., 'Account', 'Contact', 'Custom_Object__c')" } }, required: ["objectName"] } };
- src/index.ts:45-63 (registration)Registration of the DESCRIBE_OBJECT tool in the MCP server's listTools handler.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ SEARCH_OBJECTS, DESCRIBE_OBJECT, QUERY_RECORDS, AGGREGATE_QUERY, DML_RECORDS, MANAGE_OBJECT, MANAGE_FIELD, MANAGE_FIELD_PERMISSIONS, SEARCH_ALL, READ_APEX, WRITE_APEX, READ_APEX_TRIGGER, WRITE_APEX_TRIGGER, EXECUTE_ANONYMOUS, MANAGE_DEBUG_LOGS ], }));
- src/index.ts:79-83 (registration)Dispatcher case in the CallToolRequestSchema handler that extracts arguments and calls the handleDescribeObject function.case "salesforce_describe_object": { const { objectName } = args as { objectName: string }; if (!objectName) throw new Error('objectName is required'); return await handleDescribeObject(conn, objectName); }
- src/index.ts:13-13 (registration)Import of the tool schema (DESCRIBE_OBJECT) and handler function from the describe module.import { DESCRIBE_OBJECT, handleDescribeObject } from "./tools/describe.js";