salesforce_describe_object
Retrieve comprehensive schema metadata for Salesforce objects, including fields, relationships, and properties, to understand data structure and relationships.
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 main handler function that executes the Salesforce describe operation, fetches metadata, and formats the output as text.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)Tool definition with 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:37-47 (registration)The tool is registered in the listTools response by including DESCRIBE_OBJECT in the tools array.tools: [ SEARCH_OBJECTS, DESCRIBE_OBJECT, QUERY_RECORDS, DML_RECORDS, MANAGE_OBJECT, MANAGE_FIELD, SEARCH_ALL, UPLOAD_REPORT_XML // Add new tool to the list ], }));
- src/index.ts:63-67 (registration)The tool name is matched in the switch statement and dispatches to 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); }