create_record
Add a new record to a specified Airtable base and table using field values, with optional automatic data conversion. Simplified through secure OAuth 2.0 authentication.
Instructions
Create a single record
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| base_id | Yes | The Airtable base ID | |
| fields | Yes | Field values for the new record | |
| table_id | Yes | The table ID or name | |
| typecast | No | Enable automatic data conversion |
Implementation Reference
- src/airtable_mcp/mcp/server.py:302-328 (handler)The MCP tool handler for 'create_record'. This function executes the core logic: authenticates a client, wraps the input fields in a records list, calls the underlying client.create_records API method, and returns the created record details.@self.mcp.tool(description="Create a single record") async def create_record( base_id: Annotated[str, Field(description="The Airtable base ID")], table_id: Annotated[str, Field(description="The table ID or name")], fields: Annotated[ dict[str, Any], Field(description="Field values for the new record") ], typecast: Annotated[ bool, Field(description="Enable automatic data conversion") ] = False, ) -> dict[str, Any]: """Create a single record in a table.""" client = await self._get_authenticated_client() records = await client.create_records( base_id, table_id, [{"fields": fields}], typecast, ) record = records[0] return { "id": record.id, "fields": record.fields, "createdTime": record.created_time, }
- src/airtable_mcp/mcp/server.py:302-302 (registration)The @self.mcp.tool decorator registers the create_record function as an MCP tool with FastMCP.@self.mcp.tool(description="Create a single record")
- Pydantic schema class defining the input arguments for the create_record tool, matching the handler's signature.class CreateRecordArgs(BaseArgs): """Arguments for create_record tool.""" base_id: str = Field(description="The Airtable base ID") table_id: str = Field(description="The table ID or name") fields: dict[str, Any] = Field(description="Field values for the new record") typecast: bool | None = Field( default=False, description="Enable automatic data conversion" )
- Helper method in AirtableClient that performs the actual API call to create records. Called by the MCP handler, wrapping single record input into a list.async def create_records( self, base_id: str, table_id: str, records: list[dict[str, Any]], typecast: bool = False, ) -> list[AirtableRecord]: """Create new records in a table. Args: base_id: The Airtable base ID table_id: The table ID or name records: List of record data (each should have 'fields' key) typecast: Whether to enable automatic data conversion Returns: List of created records """ logger.info(f"Creating {len(records)} records in {base_id}/{table_id}") request_data = CreateRecordsRequest( records=records, typecast=typecast, ) response = await self._make_request( "POST", f"/v0/{base_id}/{table_id}", data=request_data.model_dump(by_alias=True, exclude_none=True), response_model=CreateRecordsResponse, ) return response.records