create_form
Generate and customize Google Forms using a user's Google email, form title, optional description, and document title. Returns form ID and edit URL for quick access and management.
Instructions
Create a new form using the title given in the provided form message in the request.
Args: user_google_email (str): The user's Google email address. Required. title (str): The title of the form. description (Optional[str]): The description of the form. document_title (Optional[str]): The document title (shown in browser tab).
Returns: str: Confirmation message with form ID and edit URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | ||
| document_title | No | ||
| title | Yes | ||
| user_google_email | Yes |
Implementation Reference
- gforms/forms_tools.py:19-65 (handler)The handler function for the 'create_form' tool. It creates a new Google Form using the Google Forms API with the provided title, optional description, and document title. Returns a confirmation message with the form ID and URLs. Registered via @server.tool() decorator.@server.tool() @handle_http_errors("create_form", service_type="forms") @require_google_service("forms", "forms") async def create_form( service, user_google_email: str, title: str, description: Optional[str] = None, document_title: Optional[str] = None ) -> str: """ Create a new form using the title given in the provided form message in the request. Args: user_google_email (str): The user's Google email address. Required. title (str): The title of the form. description (Optional[str]): The description of the form. document_title (Optional[str]): The document title (shown in browser tab). Returns: str: Confirmation message with form ID and edit URL. """ logger.info(f"[create_form] Invoked. Email: '{user_google_email}', Title: {title}") form_body: Dict[str, Any] = { "info": { "title": title } } if description: form_body["info"]["description"] = description if document_title: form_body["info"]["document_title"] = document_title created_form = await asyncio.to_thread( service.forms().create(body=form_body).execute ) form_id = created_form.get("formId") edit_url = f"https://docs.google.com/forms/d/{form_id}/edit" responder_url = created_form.get("responderUri", f"https://docs.google.com/forms/d/{form_id}/viewform") confirmation_message = f"Successfully created form '{created_form.get('info', {}).get('title', title)}' for {user_google_email}. Form ID: {form_id}. Edit URL: {edit_url}. Responder URL: {responder_url}" logger.info(f"Form created successfully for {user_google_email}. ID: {form_id}") return confirmation_message
- gforms/forms_tools.py:19-19 (registration)Registers the create_form tool with the MCP server using the @server.tool() decorator.@server.tool()
- gforms/forms_tools.py:22-28 (schema)Input schema defined by function parameters: user_google_email (str, required), title (str, required), description (str, optional), document_title (str, optional). Returns str.async def create_form( service, user_google_email: str, title: str, description: Optional[str] = None, document_title: Optional[str] = None ) -> str: