Skip to main content
Glama
ampcome-mcps

MCP Salesforce Connector

by ampcome-mcps

get_object_fields

Retrieve field names, labels, and data types for any Salesforce object to understand its structure and enable accurate data operations.

Instructions

Retrieves field Names, labels and types for a specific Salesforce object

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
object_nameYesThe name of the Salesforce object (e.g., 'Account', 'Contact')

Implementation Reference

  • Core handler function in SalesforceClient that fetches object fields using describe(), filters relevant info (label, name, updateable, type, length, picklistValues), caches results, and returns formatted JSON.
    def get_object_fields(self, object_name: str) -> str:
        """Retrieves field Names, labels and typesfor a specific Salesforce object.
    
        Args:
            object_name (str): The name of the Salesforce object.
    
        Returns:
            str: JSON representation of the object fields.
        """
        if not self.sf:
            raise ValueError("Salesforce connection not established.")
        if object_name not in self.sobjects_cache:
            sf_object = getattr(self.sf, object_name)
            fields = sf_object.describe()['fields']
            filtered_fields = []
            for field in fields:
                filtered_fields.append({
                    'label': field['label'],
                    'name': field['name'],
                    'updateable': field['updateable'],
                    'type': field['type'],
                    'length': field['length'],
                    'picklistValues': field['picklistValues']
                })
            self.sobjects_cache[object_name] = filtered_fields
            
        return json.dumps(self.sobjects_cache[object_name], indent=2)
  • Tool registration in list_tools() defining name, description, and input schema.
    types.Tool(
        name="get_object_fields",
        description="Retrieves field Names, labels and types for a specific Salesforce object",
        inputSchema={
            "type": "object",
            "properties": {
                "object_name": {
                    "type": "string",
                    "description": "The name of the Salesforce object (e.g., 'Account', 'Contact')",
                },
            },
            "required": ["object_name"],
        },
    ),
  • JSON Schema for tool input validation: requires 'object_name' string.
    inputSchema={
        "type": "object",
        "properties": {
            "object_name": {
                "type": "string",
                "description": "The name of the Salesforce object (e.g., 'Account', 'Contact')",
            },
        },
        "required": ["object_name"],
    },
  • MCP server tool dispatcher handler that extracts arguments, calls the core get_object_fields, and formats response as TextContent.
    elif name == "get_object_fields":
        object_name = arguments.get("object_name")
        if not object_name:
            raise ValueError("Missing 'object_name' argument")
        if not sf_client.sf:
            raise ValueError("Salesforce connection not established.")
        results = sf_client.get_object_fields(object_name)
        return [
            types.TextContent(
                type="text",
                text=f"{object_name} Metadata (JSON):\n{results}",
            )
        ]

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/ampcome-mcps/salesforce-mcp'

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