Skip to main content
Glama

Close Survey

close_survey

Permanently close a survey to stop accepting new responses when data collection is complete or enough responses have been gathered. Returns the final response count. Note: Closing is irreversible via this tool.

Instructions

Permanently close a survey so it no longer accepts new responses. Use this when you have enough responses or the data collection window has passed. Returns the final response count. Closing is irreversible via MCP — use PATCH /api/surveys/{id} to re-open.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
survey_idYesThe survey ID to close

Implementation Reference

  • Registration of the close_survey tool with the MCP server, including its title, description, and input schema.
    server.registerTool(
      'close_survey',
      {
        title: 'Close Survey',
        description: 'Permanently close a survey so it no longer accepts new responses. Use this when you have enough responses or the data collection window has passed. Returns the final response count. Closing is irreversible via MCP — use PATCH /api/surveys/{id} to re-open.',
        inputSchema: {
          survey_id: z.string().min(1).describe('The survey ID to close'),
        },
      },
  • Handler function that fetches the survey, PATCHes it to 'closed' status, then fetches response count and returns a confirmation message.
      async ({ survey_id: surveyId }) => {
        const apiKeyError = requireApiKey()
        if (apiKeyError) {
          return apiKeyError
        }
    
        const surveyResponse = await fetch(`${API_BASE_URL}/api/surveys/${encodeURIComponent(surveyId)}`)
        const surveyPayload = (await surveyResponse.json().catch(() => null)) as
          | { id?: string; title?: string; error?: string }
          | null
    
        if (!surveyResponse.ok || !surveyPayload?.id) {
          return {
            content: [
              {
                type: 'text',
                text: `Failed to fetch survey: ${surveyPayload?.error ?? surveyResponse.statusText}`,
              },
            ],
            isError: true,
          }
        }
    
        const closeResponse = await fetch(`${API_BASE_URL}/api/surveys/${encodeURIComponent(surveyId)}`, {
          method: 'PATCH',
          headers: {
            'Content-Type': 'application/json',
            Authorization: `Bearer ${process.env.HUMANSURVEY_API_KEY}`,
          },
          body: JSON.stringify({ status: 'closed' }),
        })
        const closePayload = (await closeResponse.json().catch(() => null)) as
          | { id?: string; error?: string }
          | null
    
        if (!closeResponse.ok || !closePayload?.id) {
          return {
            content: [
              {
                type: 'text',
                text: `Failed to close survey: ${closePayload?.error ?? closeResponse.statusText}`,
              },
            ],
            isError: true,
          }
        }
    
        const resultsResponse = await fetch(
          `${API_BASE_URL}/api/surveys/${encodeURIComponent(surveyId)}/responses`,
          {
            headers: {
              Authorization: `Bearer ${process.env.HUMANSURVEY_API_KEY}`,
            },
          },
        )
        const resultsPayload = (await resultsResponse.json().catch(() => null)) as
          | { count?: number; error?: string }
          | null
    
        if (!resultsResponse.ok) {
          return {
            content: [
              {
                type: 'text',
                text: `Survey '${surveyPayload.title ?? surveyId}' closed.`,
              },
            ],
          }
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `Survey '${surveyPayload.title ?? surveyId}' closed. Total responses received: ${resultsPayload?.count ?? 0}`,
            },
          ],
        }
      },
    )
  • Input schema for close_survey: requires a non-empty survey_id string.
    inputSchema: {
      survey_id: z.string().min(1).describe('The survey ID to close'),
    },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses permanence ('Permanently close', 'irreversible via MCP') and return value ('Returns the final response count'). With no annotations, this covers key behavioral traits, though auth or side effects are not mentioned.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences: first states purpose, second adds usage context and alternative. Front-loaded and no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one param and no output schema, the description covers purpose, when to use, irreversibility, and return value fully.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Only one parameter survey_id, with 100% schema coverage. The description doesn't add extra meaning beyond the schema's 'The survey ID to close', but this is sufficient.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'close' and the resource 'survey' with the effect of no longer accepting new responses. This distinguishes it from siblings like create_survey, list_surveys, etc.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says 'Use this when you have enough responses or the data collection window has passed.' Also provides an alternative for re-opening via PATCH, guiding when not to use it irreversibly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/sunsiyuan/human-survey'

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