DEV Community

Cover image for AI Survey Generator: Automate with SurveyMars MCP & Zapier
tom yang
tom yang

Posted on

AI Survey Generator: Automate with SurveyMars MCP & Zapier

Tired of manual survey design? With SurveyMars's SurveyMCP on Zapier, you can instantly generate and publish effective surveys using AI. Save hours and start collecting data effortlessly. Automate your research today!

What is SurveyMars

SurveyMars is a free, online survey creation and management platform. It allows users to create and distribute surveys of various types, including traditional surveys, polls, forms, and assessments, for purposes like market research, customer experience management, and employee experience management. The platform is designed to be user-friendly and accessible to everyone, offering unlimited surveys, questions, and responses without any cost or technical expertise needed.

What is MCP and Zapier MCP

MCP is essentially a translator between AI tools and apps, so your AI can more easily take actions on your behalf.

Zapier MCP is a standardized AI agent protocol provided by Zapier, which realizes automated interaction between AI and 8,000+ applications through a unified interface.

How to use MCP to automatically generate SurveyMars questionnaires

Python uses Zapier's MCP AI service to create SurveyMars questionnaires

1、Visit Zapier MCP
2、Click on the new version entrance
Image description

3、Click New MCP Server, we select Python and then Create MCP Server
Image description

4、After creation, click Add tool, search for SurveyMars (uppercase or lowercase), and select the second AI Create Survey
Image description

5、Enter the Account ID and App Key found according to the prompt and log in to our SurveyMars account
Image description

Image description

Image description

6、After clicking Save, you can see the python code given under the connect tab
Image description

Image description

7、Let's analyze this code

import asyncio
import json

from fastmcp import Client
from fastmcp.client.transports import StreamableHttpTransport

# Create the transport with your MCP server URL
# You need to replace it with your own Zapier MCP URL
server_url = "https://mcp.zapier.com/api/mcp/s/ZTIwOTZiMTktYTlmOC0…………"
transport = StreamableHttpTransport(server_url)

# Initialize the client with the transport
client = Client(transport=transport)


async def main():
    # Connection is established here
    print("Connecting to MCP server...")
    async with client:
        print(f"Client connected: {client.is_connected()}")

        # Make MCP calls within the context
        print("Fetching available tools...")
        tools = await client.list_tools()

        print(f"Available tools: {json.dumps([t.name for t in tools], indent=2)}")
        # Tools returned would look like:
        # - name: "surveymars_ai_create_survey"
        #   description: "Create a survey by AI"
        #   params: ["title","purpose","language", ...]

        # Example: Call a specific tool with parameters
        print("Calling surveymars_ai_create_survey...")
        result = await client.call_tool(
            "surveymars_ai_create_survey",
            {
                "instructions": "Execute the SurveyMars: AI Create Survey tool with the following parameters",
                "title": "Collect contact information", # survey title
                "purpose": "Collect basic contact information of users, including name, email, and phone number", # simple content and purpose of the survey
                "language": "2",    # english
                "survey_type": "1", # survey
                "num_questions": "6", # 6 questions
            },
        )

        # Parse the JSON string from the TextContent and print it nicely formatted
        json_result = json.loads(result[0].text)
        print(
            f"\nsurveymars_ai_create_survey result:\n{json.dumps(json_result, indent=2)}"
        )

    # Connection is closed automatically when exiting the context manager
    print("Example completed")


if __name__ == "__main__":
    asyncio.run(main())
Enter fullscreen mode Exit fullscreen mode

There are some variables that need to be replaced with your own needs:

  • server_url :Your Zapier MCP automatically generated service URL
  • title :Survey topic
  • purpose : Simple content and purpose of the survey
  • language : Survey language: ChineseSimplified = 1, English = 2
  • survey_type : Specific types of survey:Survey = 1, 360-Degree Evaluation = 3, Form = 4, FormActivity = 5, FormSign = 6
  • num_questions : Number of questions

8、Then execute your code and you will see the log in the terminal

Connecting to MCP server...
Client connected: True
Fetching available tools...
Available tools: [
  "add_tools",
  "edit_tools",
  "surveymars_ai_create_survey"
]
Calling surveymars_ai_create_survey...

surveymars_ai_create_survey result:
{
  "results": [
    {
      "href": "http://api.surveymars.com/v1/surveys/ai?id=isIgSd&credential=******",
      "data": {
        "task_id": "594604c885aa4be9a1a7db13bc0f59b5",
        "survey_id": "******",
        "url_build": "https://surveymars.com/app/survey/build/******",
        "url_callback": "https://api.surveymars.com/v1/callbacks/create_survey/ai/******"
      },
      "success": true
    }
  ],
  "feedbackUrl": "https://mcp.zapier.com/mcp/servers/e2096b19-a9f8-4134-ba47-ed6e92e3f5ec/history/executions/5f33741e-f8fc-4537-9aa0-f60807eda124",
  "execution": {
    "id": "5f33741e-f8fc-4537-9aa0-f60807eda124",
    "actionId": "68e8b0b8-e0be-47a4-b4b8-047dd58cdde6",
    "mcpServerId": "e2096b19-a9f8-4134-ba47-ed6e92e3f5ec",
    "instructions": "Execute the SurveyMars: AI Create Survey tool with the following parameters",
    "params": {
      "title": "Collect contact information",
      "purpose": "Collect basic contact information of users, including name, email, and phone number",
      "language": "2",
      "survey_type": "1",
      "instructions": "Execute the SurveyMars: AI Create Survey tool with the following parameters",
      "num_questions": "5"
    },
    "resolvedParams": {
      "title": {
        "name": "Summarizing research topic",
        "label": null,
        "value": "Collect contact information",
        "reason": "top-level-hint",
        "status": "locked"
      },
      "purpose": {
        "name": "Detailed description",
        "label": null,
        "value": "Collect basic contact information of users, including name, email, and phone number",
        "reason": "top-level-hint",
        "status": "locked"
      },
      "language": {
        "name": "Language (1: ChineseSimplified, 2: English)",
        "label": "English",
        "value": "2",
        "reason": "exact-static-choices-match",
        "status": "locked"
      },
      "survey_type": {
        "name": "Survey type (1: Survey, 3: 360, 4: Form, 5: FormActivity, 6: FormSign)",
        "label": "Survey",
        "value": "1",
        "reason": "exact-static-choices-match",
        "status": "locked"
      },
      "num_questions": {
        "name": "Number of questions",
        "label": null,
        "value": "5",
        "reason": "top-level-hint",
        "status": "locked"
      }
    },
    "result": [
      {
        "data": {
          "task_id": "594604c885aa4be9a1a7db13bc0f59b5",
          "survey_id": "******",
          "url_build": "https://surveymars.com/app/survey/build/******",
          "url_callback": "https://api.surveymars.com/v1/callbacks/create_survey/ai/******"
        },
        "href": "http://api.surveymars.com/v1/surveys/ai?id=isIgSd&credential=******",
        "success": true
      }
    ],
    "status": "SUCCESS",
    "score": 0,
    "feedback": null,
    "createdDT": "2025-06-03T03:12:48.374Z",
    "updatedDT": "2025-06-03T03:12:48.374Z"
  },
  "isPreview": false
}
Example completed
Enter fullscreen mode Exit fullscreen mode

The parameter url_build is the edit link of your survey

Let’s look at the final questionnaire.

Open url_build and we will see the survey edit page. We select the survey share page and open the link.

Image description

Top comments (0)