Skip to main content
Glama
taylorwilsdon

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

get_form

Retrieve detailed form information including title, description, questions, and URLs from Google Workspace by providing the user's email address and form ID.

Instructions

Get a form.

Args:
    user_google_email (str): The user's Google email address. Required.
    form_id (str): The ID of the form to retrieve.

Returns:
    str: Form details including title, description, questions, and URLs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
form_idYes
serviceYes
user_google_emailYes

Implementation Reference

  • The main execution logic for the 'get_form' MCP tool, decorated with registration (@server.tool()), error handling, and auth requirements. Retrieves Google Form details by ID and returns formatted summary.
    @server.tool()
    @handle_http_errors("get_form", is_read_only=True, service_type="forms")
    @require_google_service("forms", "forms")
    async def get_form(
        service,
        user_google_email: str,
        form_id: str
    ) -> str:
        """
        Get a form.
    
        Args:
            user_google_email (str): The user's Google email address. Required.
            form_id (str): The ID of the form to retrieve.
    
        Returns:
            str: Form details including title, description, questions, and URLs.
        """
        logger.info(f"[get_form] Invoked. Email: '{user_google_email}', Form ID: {form_id}")
    
        form = await asyncio.to_thread(
            service.forms().get(formId=form_id).execute
        )
    
        form_info = form.get("info", {})
        title = form_info.get("title", "No Title")
        description = form_info.get("description", "No Description")
        document_title = form_info.get("documentTitle", title)
    
        edit_url = f"https://docs.google.com/forms/d/{form_id}/edit"
        responder_url = form.get("responderUri", f"https://docs.google.com/forms/d/{form_id}/viewform")
    
        items = form.get("items", [])
        questions_summary = []
        for i, item in enumerate(items, 1):
            item_title = item.get("title", f"Question {i}")
            item_type = item.get("questionItem", {}).get("question", {}).get("required", False)
            required_text = " (Required)" if item_type else ""
            questions_summary.append(f"  {i}. {item_title}{required_text}")
    
        questions_text = "\n".join(questions_summary) if questions_summary else "  No questions found"
    
        result = f"""Form Details for {user_google_email}:
    - Title: "{title}"
    - Description: "{description}"
    - Document Title: "{document_title}"
    - Form ID: {form_id}
    - Edit URL: {edit_url}
    - Responder URL: {responder_url}
    - Questions ({len(items)} total):
    {questions_text}"""
    
        logger.info(f"Successfully retrieved form for {user_google_email}. ID: {form_id}")
        return result
  • Registers the get_form tool with the MCP server.
    @server.tool()

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