run_soql_query
Execute SOQL queries to retrieve data from Salesforce. Input a SOQL query string to interact directly with Salesforce data via the salesforce-mcp server.
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:306-317 (handler)The handler logic within the call_tool function that parses the query argument, executes sf_client.sf.query_all(query), and returns the JSON-formatted results as TextContent.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:97-109 (registration)Tool registration in the list_tools handler, defining the name, description, and input schema requiring a 'query' string.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:99-108 (schema)JSON schema for the tool input, specifying an object with a required 'query' string property.inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "The SOQL query to execute", }, }, "required": ["query"], },