add_answer
Add a new answer to a multiple choice market on Manifold Markets.
Instructions
Add a new answer to a multiple choice market
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contractId | Yes | Market ID | |
| text | Yes | Answer text |
Implementation Reference
- src/index.ts:102-105 (schema)Zod schema (AddAnswerSchema) for add_answer tool: validates contractId (string) and text (non-empty string).
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 list of available tools, including its name, description, and inputSchema (contractId, text).
{ 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'] } }, - src/index.ts:861-898 (handler)Handler implementation for 'add_answer' tool. Parses args with AddAnswerSchema, calls Manifold API POST /v0/market/{contractId}/answer with API key auth, returns the newAnswerId.
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}`, }, ], }; }