add_answer
Add a new answer option to a multiple choice prediction market on Manifold Markets, enabling users to expand market possibilities and participate in forecasting.
Instructions
Add a new answer to a multiple choice market
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contractId | Yes | Market ID | |
| text | Yes | Answer text |
Implementation Reference
- src/index.ts:861-898 (handler)Handler for the 'add_answer' tool: parses arguments with AddAnswerSchema, checks for API key, sends POST request to Manifold Markets API to add a new answer to the specified market, and returns success message with new answer ID.case 'add_answer': { const params = AddAnswerSchema.parse(args); const apiKey = process.env.MANIFOLD_API_KEY; if (!apiKey) { throw new McpError( ErrorCode.InternalError, 'MANIFOLD_API_KEY environment variable is required' ); } const response = await fetch(`${API_BASE}/v0/market/${params.contractId}/answer`, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Key ${apiKey}`, }, body: JSON.stringify({ text: params.text, }), }); if (!response.ok) { throw new McpError( ErrorCode.InternalError, `Manifold API error: ${response.statusText}` ); } const result = await response.json(); return { content: [ { type: 'text', text: `Answer added with ID: ${result.newAnswerId}`, }, ], }; }
- src/index.ts:102-105 (schema)Zod schema defining the input parameters for the 'add_answer' tool: contractId (market ID) and text (answer text, min length 1).const AddAnswerSchema = z.object({ contractId: z.string(), text: z.string().min(1), });
- src/index.ts:337-348 (registration)Registration of the 'add_answer' tool in the ListToolsRequestSchema handler, specifying name, description, and input schema matching AddAnswerSchema.{ name: 'add_answer', description: 'Add a new answer to a multiple choice market', inputSchema: { type: 'object', properties: { contractId: { type: 'string', description: 'Market ID' }, text: { type: 'string', description: 'Answer text' } }, required: ['contractId', 'text'] } },