finalize_poll
Finalize a poll by picking the winning time slot from get_results. Locks the poll and notifies participants via email. Passphrase auto-used from create_poll if available.
Instructions
Finalize a poll by picking the winning time slot. Call get_results first to find the best optionId. Uses the passphrase auto-saved from create_poll. If the MCP server was restarted since poll creation, provide the passphrase manually. This locks the poll and notifies participants who provided an email.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pollId | Yes | Poll UUID | |
| optionId | Yes | Winning time slot option UUID (pick from get_results) | |
| passphrase | No | Admin passphrase (auto-used from create_poll if available) |
Implementation Reference
- src/tools.ts:183-207 (handler)Handler logic for finalize_poll: parses pollId, optionId, and optional passphrase; retrieves or uses provided passphrase; gets admin token; calls API to finalize; returns success with poll details.
case "finalize_poll": { const input = z.object({ pollId: z.string(), optionId: z.string(), passphrase: z.string().optional(), }).parse(args); const passphrase = input.passphrase || passphraseMap.get(input.pollId); if (!passphrase) { return JSON.stringify({ error: "No passphrase available. Provide the passphrase that was returned when the poll was created.", }); } const adminToken = await client.getAdminToken(input.pollId, passphrase); const result = await client.finalize(input.pollId, input.optionId, adminToken); return JSON.stringify({ success: true, pollId: result.id, title: result.title, status: result.status, finalizedOption: result.finalizedOption, }, null, 2); } - src/index.ts:115-131 (registration)MCP server registration of the finalize_poll tool with name, description, Zod schema for arguments, and handler that delegates to handleToolCall.
server.tool( "finalize_poll", TOOL_DESCRIPTIONS.finalize_poll, { pollId: z.string().describe("Poll UUID"), optionId: z.string().describe("Winning time slot option UUID (pick from get_results)"), passphrase: z.string().optional().describe("Admin passphrase (auto-used from create_poll if available)"), }, async (args) => { try { const text = await handleToolCall("finalize_poll", args, client, stdioSession()); return { content: [{ type: "text", text }] }; } catch (e) { return { content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : String(e)}` }], isError: true }; } }, ); - src/client.ts:61-67 (schema)Type definition for the result returned by the finalize API call.
export interface FinalizeResult { id: string; title: string; status: string; finalizedOptionId: string; finalizedOption: { id: string; start: string; end: string }; } - src/client.ts:130-132 (helper)Client helper that sends a POST request to the finalize endpoint with optionId and adminToken.
async finalize(pollId: string, optionId: string, adminToken: string): Promise<FinalizeResult> { return this.request<FinalizeResult>("POST", `/api/open/polls/${pollId}/finalize`, { optionId, adminToken }); } - src/client.ts:125-128 (helper)Client helper that exchanges the poll passphrase for an admin token needed to finalize.
async getAdminToken(pollId: string, passphrase: string): Promise<string> { const data = await this.request<{ token: string }>("POST", `/api/open/polls/${pollId}/admin-token`, { passphrase }); return data.token; }