Skip to main content
Glama
taylorwilsdon

Google Workspace MCP Server - Control Gmail, Calendar, Docs, Sheets, Slides, Chat, Forms & Drive

create_form

Generate a new Google Form with a specified title, description, and document tab title using user's Google email. Returns form ID and edit URL for immediate access.

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

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNo
document_titleNo
serviceYes
titleYes
user_google_emailYes

Implementation Reference

  • The handler function for the 'create_form' tool. It is registered via the @server.tool() decorator and implements the logic to create a new Google Form using the Google Forms API, handling title, description, and document_title parameters.
    @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
  • Registration of the 'create_form' tool using the @server.tool() decorator.
    @server.tool()
  • Input schema defined by function parameters with type hints and detailed docstring describing args and return type.
    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).

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/taylorwilsdon/google_workspace_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server