sheets_create
Generate a new Google Sheet with a specified title and optional sheet names using MCP Google Suite, enabling direct integration with Google Workspace for efficient spreadsheet creation.
Instructions
Create a new Google Sheet
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sheets | No | Sheet names | |
| title | Yes | Title of the spreadsheet |
Input Schema (JSON Schema)
{
"properties": {
"sheets": {
"description": "Sheet names",
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"description": "Title of the spreadsheet",
"type": "string"
}
},
"required": [
"title"
],
"type": "object"
}
Implementation Reference
- src/mcp_google_suite/server.py:356-369 (handler)MCP tool handler that extracts title and sheets from arguments and delegates to SheetsService.create_spreadsheetasync def _handle_sheets_create( self, context: GoogleWorkspaceContext, arguments: dict ) -> Dict[str, Any]: """Handle sheets create requests.""" title = arguments.get("title") sheets = arguments.get("sheets", []) if not title: raise ValueError("Spreadsheet title is required") logger.debug(f"Creating spreadsheet - Title: {title}, Sheets: {sheets}") result = await context.sheets.create_spreadsheet(title=title, sheets=sheets) logger.debug(f"Spreadsheet created - ID: {result.get('spreadsheetId')}") return result
- Tool schema defining input parameters for sheets_create: title (required), sheets (optional array of sheet names)types.Tool( name="sheets_create", description="Create a new Google Sheet", inputSchema={ "type": "object", "properties": { "title": {"type": "string", "description": "Title of the spreadsheet"}, "sheets": { "type": "array", "items": {"type": "string"}, "description": "Sheet names", }, }, "required": ["title"], }, ),
- Implements spreadsheet creation using Google Sheets API v4, constructing body with title and optional sheetsdef create_spreadsheet(self, title: str, sheets: Optional[List[str]] = None) -> Dict[str, Any]: """Create a new Google Spreadsheet with optional sheets.""" try: spreadsheet_body = {"properties": {"title": title}} if sheets: spreadsheet_body["sheets"] = [ {"properties": {"title": sheet_name}} for sheet_name in sheets ] spreadsheet = self.service.spreadsheets().create(body=spreadsheet_body).execute() return {"success": True, "spreadsheet": spreadsheet} except HttpError as error: return {"success": False, **self.handle_error(error)}