get_form_response
Retrieve specific response data from a Google Form by providing the user's email, form ID, and response ID, including detailed answers and metadata.
Instructions
Get one response from the form.
Args:
user_google_email (str): The user's Google email address. Required.
form_id (str): The ID of the form.
response_id (str): The ID of the response to retrieve.
Returns:
str: Response details including answers and metadata.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| form_id | Yes | ||
| response_id | Yes | ||
| service | Yes | ||
| user_google_email | Yes |
Implementation Reference
- gforms/forms_tools.py:162-213 (handler)The complete implementation of the get_form_response tool handler, including decorators for registration (@server.tool()), error handling, and service requirement. This function fetches a specific response from a Google Form using the Forms API.@server.tool() @handle_http_errors("get_form_response", is_read_only=True, service_type="forms") @require_google_service("forms", "forms") async def get_form_response( service, user_google_email: str, form_id: str, response_id: str ) -> str: """ Get one response from the form. Args: user_google_email (str): The user's Google email address. Required. form_id (str): The ID of the form. response_id (str): The ID of the response to retrieve. Returns: str: Response details including answers and metadata. """ logger.info(f"[get_form_response] Invoked. Email: '{user_google_email}', Form ID: {form_id}, Response ID: {response_id}") response = await asyncio.to_thread( service.forms().responses().get(formId=form_id, responseId=response_id).execute ) response_id = response.get("responseId", "Unknown") create_time = response.get("createTime", "Unknown") last_submitted_time = response.get("lastSubmittedTime", "Unknown") answers = response.get("answers", {}) answer_details = [] for question_id, answer_data in answers.items(): question_response = answer_data.get("textAnswers", {}).get("answers", []) if question_response: answer_text = ", ".join([ans.get("value", "") for ans in question_response]) answer_details.append(f" Question ID {question_id}: {answer_text}") else: answer_details.append(f" Question ID {question_id}: No answer provided") answers_text = "\n".join(answer_details) if answer_details else " No answers found" result = f"""Form Response Details for {user_google_email}: - Form ID: {form_id} - Response ID: {response_id} - Created: {create_time} - Last Submitted: {last_submitted_time} - Answers: {answers_text}""" logger.info(f"Successfully retrieved response for {user_google_email}. Response ID: {response_id}") return result
- gforms/forms_tools.py:162-162 (registration)The @server.tool() decorator registers the get_form_response function as an MCP tool.@server.tool()
- gforms/forms_tools.py:165-181 (schema)Input schema defined by function parameters and type hints, along with docstring describing args and return type.async def get_form_response( service, user_google_email: str, form_id: str, response_id: str ) -> str: """ Get one response from the form. Args: user_google_email (str): The user's Google email address. Required. form_id (str): The ID of the form. response_id (str): The ID of the response to retrieve. Returns: str: Response details including answers and metadata. """