Skip to main content
Glama
tsmztech

Salesforce MCP Server

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 handler function that implements the core logic: retrieves all objects via describeGlobal, filters them based on the search pattern in name or label, and returns formatted results or no-match message.
    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 object defining the name, description, and input schema requiring a searchPattern string.
    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:73-77 (registration)
    Switch case in the main CallToolRequest handler that extracts arguments and invokes the handleSearchObjects function.
    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:47-47 (registration)
    Inclusion of the SEARCH_OBJECTS tool in the list returned by ListToolsRequestHandler.
    SEARCH_OBJECTS, 
  • src/index.ts:12-12 (registration)
    Import of the tool schema and handler from the search module.
    import { SEARCH_OBJECTS, handleSearchObjects } from "./tools/search.js";
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 of behavioral disclosure. It mentions that the search is by 'name pattern' and gives examples, but it doesn't specify whether this is a read-only operation, what permissions are required, how results are returned (e.g., list format, pagination), or any rate limits. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 front-loaded with the core purpose in the first sentence, followed by concise examples that illustrate usage without redundancy. Every sentence earns its place by clarifying the tool's functionality, making it efficient and well-structured.

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

Completeness3/5

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

Given the tool's moderate complexity (search operation with one parameter), no annotations, and no output schema, the description is adequate but incomplete. It covers the basic purpose and parameter usage but lacks details on behavioral aspects like return format, error handling, or prerequisites. This makes it minimally viable but with clear gaps for an agent to rely on.

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 input schema has 100% description coverage, with the parameter 'searchPattern' well-documented in the schema. The description adds minimal value by reinforcing the pattern concept with examples ('Account' will find Account, AccountHistory), but it doesn't provide additional semantics beyond what the schema already states (e.g., exact syntax, wildcard rules). This meets the baseline of 3 for high schema coverage.

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: 'Search for Salesforce standard and custom objects by name pattern.' It specifies the verb ('Search'), resource ('Salesforce standard and custom objects'), and scope ('by name pattern'). However, it doesn't explicitly differentiate from sibling tools like 'salesforce_search_all' or 'salesforce_describe_object', which limits it to a 4 rather than a 5.

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 provides implied usage through examples (e.g., 'Account' will find Account, AccountHistory), suggesting it's for fuzzy matching. However, it lacks explicit guidance on when to use this tool versus alternatives like 'salesforce_search_all' (which might search across all metadata) or 'salesforce_describe_object' (which retrieves detailed info for a specific object). This makes the guidelines incomplete but not absent.

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/tsmztech/mcp-server-salesforce'

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