Skip to main content
Glama

salesforce_search_objects

Find Salesforce standard and custom objects using a specific search pattern to locate relevant data structures. Ideal for quickly identifying objects like 'Account' or 'Order' across Salesforce metadata.

Instructions

Search for Salesforce standard and custom objects by name pattern. Examples: 'Account' will find Account, AccountHistory; 'Order' will find WorkOrder, ServiceOrder__c etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchPatternYesSearch pattern to find objects (e.g., 'Account Coverage' will find objects like 'AccountCoverage__c')

Implementation Reference

  • The handler function that executes the tool logic: fetches all objects via describeGlobal, filters by search terms in name or label, and formats the results.
    export async function handleSearchObjects(conn: any, searchPattern: string) { // Get list of all objects const describeGlobal = await conn.describeGlobal(); // Process search pattern to create a more flexible search const searchTerms = searchPattern.toLowerCase().split(' ').filter(term => term.length > 0); // Filter objects based on search pattern const matchingObjects = describeGlobal.sobjects.filter((obj: SalesforceObject) => { const objectName = obj.name.toLowerCase(); const objectLabel = obj.label.toLowerCase(); // Check if all search terms are present in either the API name or label return searchTerms.every(term => objectName.includes(term) || objectLabel.includes(term) ); }); if (matchingObjects.length === 0) { return { content: [{ type: "text", text: `No Salesforce objects found matching "${searchPattern}".` }], isError: false, }; } // Format the output const formattedResults = matchingObjects.map((obj: SalesforceObject) => `${obj.name}${obj.custom ? ' (Custom)' : ''}\n Label: ${obj.label}` ).join('\n\n'); return { content: [{ type: "text", text: `Found ${matchingObjects.length} matching objects:\n\n${formattedResults}` }], isError: false, }; }
  • The tool definition with name, description, and input schema requiring 'searchPattern'.
    export const SEARCH_OBJECTS: Tool = { name: "salesforce_search_objects", description: "Search for Salesforce standard and custom objects by name pattern. Examples: 'Account' will find Account, AccountHistory; 'Order' will find WorkOrder, ServiceOrder__c etc.", inputSchema: { type: "object", properties: { searchPattern: { type: "string", description: "Search pattern to find objects (e.g., 'Account Coverage' will find objects like 'AccountCoverage__c')" } }, required: ["searchPattern"] } };
  • src/index.ts:35-45 (registration)
    Registration of the tool in the list of available tools returned by ListToolsRequest.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ SEARCH_OBJECTS, DESCRIBE_OBJECT, QUERY_RECORDS, DML_RECORDS, MANAGE_OBJECT, MANAGE_FIELD, SEARCH_ALL ], }));
  • src/index.ts:55-59 (registration)
    Dispatch registration in the CallToolRequest handler switch statement that invokes the tool handler.
    case "salesforce_search_objects": { const { searchPattern } = args as { searchPattern: string }; if (!searchPattern) throw new Error('searchPattern is required'); return await handleSearchObjects(conn, searchPattern); }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SurajAdsul/mcp-server-salesforce'

If you have feedback or need assistance with the MCP directory API, please join our Discord server