add_answer
Add a new answer option to a multiple choice market on Manifold Markets by specifying the market ID and the answer text.
Instructions
Add a new answer to a multiple choice market
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contractId | Yes | Market ID | |
| text | Yes | Answer text |
Input Schema (JSON Schema)
{
"properties": {
"contractId": {
"description": "Market ID",
"type": "string"
},
"text": {
"description": "Answer text",
"type": "string"
}
},
"required": [
"contractId",
"text"
],
"type": "object"
}
Implementation Reference
- src/index.ts:861-898 (handler)The handler for the 'add_answer' tool. Parses arguments using AddAnswerSchema, requires MANIFOLD_API_KEY, sends POST request to Manifold Markets API to add an answer to the specified market, handles errors, and returns a success message with the 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 validation schema for 'add_answer' tool inputs: 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)Tool registration in the MCP server's listTools handler, defining name, description, and JSON schema for inputs.{ 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'] } },