react
Add or remove reactions (like/dislike) to markets or comments on Manifold Markets using an MCP interface, enabling interactive engagement with platform content.
Instructions
React to a market or comment
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contentId | Yes | ID of market or comment | |
| contentType | Yes | Type of content to react to | |
| reactionType | No | Type of reaction | |
| remove | No | Optional. True to remove reaction |
Implementation Reference
- src/index.ts:1054-1088 (handler)Handler function for the 'react' tool. Parses input using ReactSchema, makes POST request to Manifold API /v0/react endpoint with API key, handles errors, and returns success message.case 'react': { const params = ReactSchema.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/react`, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Key ${apiKey}`, }, body: JSON.stringify(params), }); if (!response.ok) { throw new McpError( ErrorCode.InternalError, `Manifold API error: ${response.statusText}` ); } return { content: [ { type: 'text', text: params.remove ? 'Reaction removed' : 'Reaction added', }, ], }; }
- src/index.ts:128-133 (schema)Zod schema definition for validating 'react' tool inputs: contentId (string), contentType (enum: 'comment' or 'contract'), optional remove (boolean), reactionType (enum: 'like' or 'dislike', defaults to 'like'). Used in handler for parsing.const ReactSchema = z.object({ contentId: z.string(), contentType: z.enum(['comment', 'contract']), remove: z.boolean().optional(), reactionType: z.enum(['like', 'dislike']).default('like'), });
- src/index.ts:398-411 (registration)Tool registration in listTools handler. Defines name 'react', description, and JSON inputSchema matching the Zod schema.{ name: 'react', description: 'React to a market or comment', inputSchema: { type: 'object', properties: { contentId: { type: 'string', description: 'ID of market or comment' }, contentType: { type: 'string', enum: ['comment', 'contract'], description: 'Type of content to react to' }, remove: { type: 'boolean', description: 'Optional. True to remove reaction' }, reactionType: { type: 'string', enum: ['like', 'dislike'], description: 'Type of reaction' } }, required: ['contentId', 'contentType'] } },