execute_query
Execute queries against enterprise APIs like Salesforce or NetSuite using languages such as SOQL or SuiteQL. Retrieve structured data with pagination and authentication support.
Instructions
Execute a query against the upstream API.
TEMPLATE: Replace with your API's query language documentation. Examples: SuiteQL (NetSuite), SOQL (Salesforce), GraphQL, OData, etc.
Args: query: Query string in the upstream API's query language. account_id: Account ID (required if not configured on server). base_url: Optional full API URL (overrides account_id). limit: Maximum number of results. offset: Starting offset for pagination.
Returns: Structured response with query results.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| account_id | No | ||
| base_url | No | ||
| limit | No | ||
| offset | No |
Implementation Reference
- src/my_mcp_server/server.py:717-749 (handler)The implementation of the `execute_query` tool, which is an asynchronous function decorated with `@mcp.tool()`. It uses an API client to run the query and returns the serialized response.
async def execute_query( query: str, account_id: Optional[str] = None, base_url: Optional[str] = None, limit: Optional[int] = None, offset: Optional[int] = None, ) -> Dict[str, Any]: """ Execute a query against the upstream API. TEMPLATE: Replace with your API's query language documentation. Examples: SuiteQL (NetSuite), SOQL (Salesforce), GraphQL, OData, etc. Args: query: Query string in the upstream API's query language. account_id: Account ID (required if not configured on server). base_url: Optional full API URL (overrides account_id). limit: Maximum number of results. offset: Starting offset for pagination. Returns: Structured response with query results. """ token = _get_oauth_token() async with _get_client(base_url, account_id) as client: response = await client.execute_query( access_token=token, query=query, limit=limit, offset=offset, ) return _serialize_response(response) - src/my_mcp_server/server.py:716-716 (registration)Registration of the `execute_query` tool using the `@mcp.tool()` decorator in `server.py`.
@mcp.tool()