run_soql_query
Execute SOQL queries to retrieve Salesforce data using the MCP Salesforce Connector.
Instructions
Executes a SOQL query against Salesforce
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SOQL query to execute |
Implementation Reference
- src/salesforce/server.py:315-326 (handler)The handler logic within handle_call_tool that executes the SOQL query using Salesforce client's query_all method and returns the results as JSON text.if name == "run_soql_query": query = arguments.get("query") if not query: raise ValueError("Missing 'query' argument") results = sf_client.sf.query_all(query) return [ types.TextContent( type="text", text=f"SOQL Query Results (JSON):\n{json.dumps(results, indent=2)}", ) ]
- src/salesforce/server.py:106-118 (registration)Tool registration in the list_tools function, defining name, description, and input schema for run_soql_query.name="run_soql_query", description="Executes a SOQL query against Salesforce", inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "The SOQL query to execute", }, }, "required": ["query"], }, ),
- src/salesforce/server.py:108-117 (schema)JSON schema defining the input for run_soql_query tool: an object with required 'query' string property.inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "The SOQL query to execute", }, }, "required": ["query"], },