Skip to main content
Glama
usama-dtc

Salesforce MCP Server

by usama-dtc

salesforce_search_objects

Search Salesforce standard and custom objects by name pattern to quickly find relevant data structures for integration or development tasks.

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 main handler function that executes the tool's logic: retrieves all Salesforce objects via describeGlobal, filters by search pattern 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,
      };
    }
  • Defines the Tool object with name, description, and input schema for validating the searchPattern argument.
    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:57-61 (registration)
    Registers the handler by dispatching tool calls with name 'salesforce_search_objects' to handleSearchObjects function within the CallToolRequestSchema handler.
    case "salesforce_search_objects": {
      const { searchPattern } = args as { searchPattern: string };
      if (!searchPattern) throw new Error('searchPattern is required');
      return await handleSearchObjects(conn, searchPattern);
    }
  • src/index.ts:37-47 (registration)
    Registers the tool schema by including SEARCH_OBJECTS in the list returned by ListToolsRequestSchema handler.
      tools: [
        SEARCH_OBJECTS, 
        DESCRIBE_OBJECT, 
        QUERY_RECORDS, 
        DML_RECORDS,
        MANAGE_OBJECT,
        MANAGE_FIELD,
        SEARCH_ALL,
        UPLOAD_REPORT_XML  // Add new tool to the list
      ],
    }));
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions searching for standard and custom objects with examples, but doesn't disclose behavioral traits such as whether this is a read-only operation, if there are rate limits, authentication needs, or what the return format looks like. For a search tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and front-loaded, consisting of two sentences that directly explain the tool's purpose and provide illustrative examples. Every sentence earns its place without unnecessary elaboration, making it efficient and easy to understand.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a search operation with no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects (e.g., read-only status, rate limits), output format, and doesn't fully compensate for the absence of structured data. This makes it inadequate for an AI agent to fully understand the tool's behavior and usage context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the parameter 'searchPattern' fully documented in the input schema. The description adds examples like 'Account' and 'Order' to illustrate usage, but doesn't provide additional semantic details beyond what the schema already states (e.g., pattern matching rules or case sensitivity). Baseline 3 is appropriate as the schema handles the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as searching for Salesforce objects by name pattern, with specific examples like 'Account' and 'Order'. It distinguishes from siblings by focusing on object search rather than describing objects (salesforce_describe_object), managing objects (salesforce_manage_object), or searching all data (salesforce_search_all). However, it doesn't explicitly contrast with salesforce_search_all, which might handle broader searches.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when searching for objects by name pattern, as shown in the examples. However, it doesn't explicitly state when to use this tool versus alternatives like salesforce_search_all or salesforce_describe_object, nor does it provide exclusions or prerequisites. The context is clear but lacks explicit guidance on tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/usama-dtc/salesforce_mcp'

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