restful
Initiate REST API calls to Salesforce endpoints using specified HTTP methods, paths, and parameters to retrieve, update, or delete data directly.
Instructions
Makes a direct REST API call to Salesforce
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | Data for POST/PATCH requests | |
| method | No | The HTTP method (default: 'GET') | GET |
| params | No | Query parameters for the request | |
| path | Yes | The path of the REST API endpoint (e.g., 'sobjects/Account/describe') |
Implementation Reference
- src/salesforce/server.py:439-456 (handler)Handler for the 'restful' tool: extracts arguments, validates, calls Salesforce RESTful API via simple-salesforce library, and returns JSON-formatted results.elif name == "restful": path = arguments.get("path") method = arguments.get("method", "GET") params = arguments.get("params") data = arguments.get("data") if not path: raise ValueError("Missing 'path' argument") if not sf_client.sf: raise ValueError("Salesforce connection not established.") results = sf_client.sf.restful(path, method=method, params=params, json=data) return [ types.TextContent( type="text", text=f"RESTful API Call Result (JSON):\n{json.dumps(results, indent=2)}", ) ]
- src/salesforce/server.py:270-301 (registration)Registration of the 'restful' tool in the list_tools handler, including name, description, and input schema for path, method, params, and data.types.Tool( name="restful", description="Makes a direct REST API call to Salesforce", inputSchema={ "type": "object", "properties": { "path": { "type": "string", "description": "The path of the REST API endpoint (e.g., 'sobjects/Account/describe')", }, "method": { "type": "string", "description": "The HTTP method (default: 'GET')", "enum": ["GET", "POST", "PATCH", "DELETE"], "default": "GET", }, "params": { "type": "object", "description": "Query parameters for the request", "properties": {}, "additionalProperties": True, }, "data": { "type": "object", "description": "Data for POST/PATCH requests", "properties": {}, "additionalProperties": True, }, }, "required": ["path"], }, ),
- src/salesforce/server.py:273-300 (schema)JSON Schema defining inputs for the 'restful' tool.inputSchema={ "type": "object", "properties": { "path": { "type": "string", "description": "The path of the REST API endpoint (e.g., 'sobjects/Account/describe')", }, "method": { "type": "string", "description": "The HTTP method (default: 'GET')", "enum": ["GET", "POST", "PATCH", "DELETE"], "default": "GET", }, "params": { "type": "object", "description": "Query parameters for the request", "properties": {}, "additionalProperties": True, }, "data": { "type": "object", "description": "Data for POST/PATCH requests", "properties": {}, "additionalProperties": True, }, }, "required": ["path"], },