get_positions
Retrieve a user's positions across prediction markets to track investments and manage risk on the Manifold Markets platform.
Instructions
Get user positions across markets
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | Yes | User ID |
Implementation Reference
- src/index.ts:762-785 (handler)Handler for the 'get_positions' tool. Parses userId from args using GetUserPositionsSchema, fetches user's bets/positions from Manifold Markets API '/v0/bets?userId={userId}', handles errors, and returns JSON stringified positions as tool content.case 'get_positions': { const { userId } = GetUserPositionsSchema.parse(args); const response = await fetch( `${API_BASE}/v0/bets?userId=${userId}`, { headers: { Accept: 'application/json' } } ); if (!response.ok) { throw new McpError( ErrorCode.InternalError, `Manifold API error: ${response.statusText}` ); } const positions = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(positions, null, 2), }, ], }; }
- src/index.ts:302-312 (registration)Tool registration in the MCP server's listTools response, defining name 'get_positions', description, and input schema requiring 'userId'.{ name: 'get_positions', description: 'Get user positions across markets', inputSchema: { type: 'object', properties: { userId: { type: 'string', description: 'User ID' }, }, required: ['userId'], }, },
- src/index.ts:73-75 (schema)Zod schema used for input validation in the get_positions handler, requiring a 'userId' string parameter.const GetUserPositionsSchema = z.object({ userId: z.string(), });