react
Like or dislike a market or comment on Manifold Markets, with the option to remove your reaction.
Instructions
React to a market or comment
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contentId | Yes | ID of market or comment | |
| contentType | Yes | Type of content to react to | |
| remove | No | Optional. True to remove reaction | |
| reactionType | No | Type of reaction |
Implementation Reference
- src/index.ts:128-133 (schema)Zod schema for the 'react' tool input validation: contentId (string), contentType (comment/contract), remove (optional boolean), reactionType (like/dislike with default 'like').
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)Registration of the 'react' tool as part of the ListToolsRequestSchema handler, defining its name, description, and JSON Schema input 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'] } }, - src/index.ts:1054-1088 (handler)Handler for the 'react' tool execution. Parses args via ReactSchema, calls the Manifold API POST /v0/react with the API key, returns success message indicating whether the reaction was added or removed.
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', }, ], }; }