create_record
Add new records like customers or invoices to enterprise systems using JSON payloads. This tool enables AI assistants to create structured data entries through standardized API calls.
Instructions
Create a new record in the upstream API.
TEMPLATE: Replace this docstring with your domain-specific documentation. The docstring is shown to AI clients to help them understand when and how to use this tool.
Args: record_type: The type of record to create (e.g., "customer", "invoice") payload: JSON payload for the record. account_id: Account ID (required if not configured on server). base_url: Optional full API URL (overrides account_id).
Returns: Structured response with ok, status_code, data, errors, request_id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| record_type | Yes | ||
| payload | Yes | ||
| account_id | No | ||
| base_url | No |
Implementation Reference
- src/my_mcp_server/server.py:577-614 (handler)The MCP tool handler for 'create_record'. It retrieves the OAuth token, creates an API client, and executes the call.
async def create_record( record_type: str, payload: Dict[str, Any], account_id: Optional[str] = None, base_url: Optional[str] = None, ) -> Dict[str, Any]: """ Create a new record in the upstream API. TEMPLATE: Replace this docstring with your domain-specific documentation. The docstring is shown to AI clients to help them understand when and how to use this tool. Args: record_type: The type of record to create (e.g., "customer", "invoice") payload: JSON payload for the record. account_id: Account ID (required if not configured on server). base_url: Optional full API URL (overrides account_id). Returns: Structured response with ok, status_code, data, errors, request_id. """ token = _get_oauth_token() async with _get_client(base_url, account_id) as client: response = await client.create_record( access_token=token, record_type=record_type, payload=payload, base_url_override=base_url, ) result = _serialize_response(response) if isinstance(response, RecordResponse): result["internal_id"] = response.internal_id result["record_link"] = response.record_link return result - src/my_mcp_server/api_client.py:354-378 (handler)The actual HTTP client method that executes the API request to create a record.
async def create_record( self, access_token: str, record_type: str, payload: Dict[str, Any], base_url_override: Optional[str] = None, ) -> APIResponse: """ Create a new record in the upstream API. Args: access_token: OAuth Bearer token record_type: The record type/endpoint name (e.g., "customer", "invoice") payload: The record data to create base_url_override: Override the base URL for this request Returns: APIResponse with creation result """ base = base_url_override or self._base_url url = f"{base}/{record_type}" logger.info(f"Creating {record_type} record") return await self._request_with_retry("POST", url, access_token, json_body=payload)