kintone_create_record
Creates a new record with field validation in a Kintone app. Requires app ID from kintone_list_apps.
Instructions
Create a new record in a Kintone app with field validation. ⚠️ Use 'kintone_list_apps' first to get available app IDs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_id | Yes | The ID of the Kintone app (use kintone_list_apps to see available app IDs) | |
| record_data | Yes | Record data as key-value pairs where keys are field codes and values are field values. Each field value should be an object with 'value' property. |
Implementation Reference
- The _handle_create_record function is the main handler for the kintone_create_record tool. It extracts app_id and record_data from arguments, validates them, calls client.create_record(), and returns a formatted success/error response.
async def _handle_create_record(arguments: Dict[str, Any], client: KintoneClient) -> List[types.TextContent]: """Handle kintone_create_record tool call.""" app_id = arguments.get("app_id") record_data = arguments.get("record_data") if not app_id or not record_data: return [types.TextContent( type="text", text="Error: Both app_id and record_data are required" )] if not isinstance(record_data, dict): return [types.TextContent( type="text", text="Error: record_data must be a dictionary" )] result = client.create_record(app_id=app_id, record_data=record_data) if result.get("success"): record_id = result.get("id") revision = result.get("revision") response_text = f"Successfully created record in app {app_id}\n" response_text += f"Record ID: {record_id}\n" response_text += f"Revision: {revision}\n\n" response_text += f"Created data:\n{json.dumps(record_data, indent=2, ensure_ascii=False)}" return [types.TextContent( type="text", text=response_text )] else: error_msg = result.get("error", "Unknown error occurred") return [types.TextContent( type="text", text=f"Error creating record in app {app_id}: {error_msg}" )] - The create_record method on KintoneClient sends a POST request to the Kintone 'record.json' endpoint with the app_id and record_data, and returns the id and revision on success.
def create_record(self, app_id: str, record_data: Dict[str, Any]) -> Dict[str, Any]: """Create single record with field validation.""" data = { 'app': app_id, 'record': record_data } result = self._make_request('POST', 'record.json', data=data) if result['success']: return { "success": True, "id": result['data'].get('id'), "revision": result['data'].get('revision') } return result - The get_crud_tools function defines the input schema for kintone_create_record (and other CRUD tools), specifying app_id (string) and record_data (object) as required parameters.
def get_crud_tools() -> List[types.Tool]: """Get list of CRUD tools.""" return [ types.Tool( name="kintone_create_record", description="Create a new record in a Kintone app with field validation. ⚠️ Use 'kintone_list_apps' first to get available app IDs.", inputSchema={ "type": "object", "properties": { "app_id": { "type": "string", "description": "The ID of the Kintone app (use kintone_list_apps to see available app IDs)" }, "record_data": { "type": "object", "description": "Record data as key-value pairs where keys are field codes and values are field values. Each field value should be an object with 'value' property." } }, "required": ["app_id", "record_data"] } ), types.Tool( name="kintone_update_record", description="Update an existing record in a Kintone app with revision control. ⚠️ Use 'kintone_list_apps' first to get available app IDs.", inputSchema={ "type": "object", "properties": { "app_id": { "type": "string", "description": "The ID of the Kintone app (use kintone_list_apps to see available app IDs)" }, "record_id": { "type": "string", "description": "The ID of the record to update" }, "record_data": { "type": "object", "description": "Record data to update as key-value pairs where keys are field codes and values are field values. Each field value should be an object with 'value' property." }, "revision": { "type": "integer", "description": "Record revision number for optimistic locking (optional but recommended)" } }, "required": ["app_id", "record_id", "record_data"] } ), types.Tool( name="kintone_delete_record", description="Delete a record from a Kintone app by ID with safety confirmation. ⚠️ Use 'kintone_list_apps' first to get available app IDs.", inputSchema={ "type": "object", "properties": { "app_id": { "type": "string", "description": "The ID of the Kintone app (use kintone_list_apps to see available app IDs)" }, "record_id": { "type": "string", "description": "The ID of the record to delete" }, "revision": { "type": "integer", "description": "Record revision number for optimistic locking (optional but recommended)" }, "confirm": { "type": "boolean", "description": "Confirmation flag to prevent accidental deletions (must be true)", "default": False } }, "required": ["app_id", "record_id", "confirm"] } ) ] - src/mcp_kintone_lite/tools/crud_tools.py:102-121 (registration)The handle_crud_tools function routes the tool name matching 'kintone_create_record' to the _handle_create_record handler.
async def handle_crud_tools(name: str, arguments: Dict[str, Any], client: KintoneClient) -> List[types.TextContent]: """Handle CRUD tool calls.""" try: if name == "kintone_create_record": return await _handle_create_record(arguments, client) elif name == "kintone_update_record": return await _handle_update_record(arguments, client) elif name == "kintone_delete_record": return await _handle_delete_record(arguments, client) else: return [types.TextContent( type="text", text=f"Error: Unknown CRUD tool '{name}'" )] except Exception as e: logger.error(f"Error in CRUD tool {name}: {e}") return [types.TextContent( type="text", text=f"Error executing {name}: {str(e)}" )] - src/mcp_kintone_lite/server.py:69-92 (registration)The handle_call_tool function in server.py routes incoming tool calls; line 79 checks for 'kintone_create_record' and delegates to handle_crud_tools.
@server.call_tool() async def handle_call_tool(name: str, arguments: Dict[str, Any]) -> List[types.TextContent]: """Handle tool calls by routing to appropriate tool modules.""" client = get_client() # Query tools if name in ["kintone_get_records", "kintone_get_record"]: return await handle_query_tools(name, arguments, client) # CRUD tools elif name in ["kintone_create_record", "kintone_update_record", "kintone_delete_record"]: return await handle_crud_tools(name, arguments, client) # Metadata tools elif name in ["kintone_list_apps", "kintone_get_app", "kintone_get_form_fields", "kintone_get_views", "kintone_get_form_layout"]: return await handle_metadata_tools(name, arguments, client) else: logger.error(f"Unknown tool: {name}") return [types.TextContent( type="text", text=f"Error: Unknown tool '{name}'" )]