Skip to main content
Glama
bmorphism

Manifold Markets MCP Server

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
NameRequiredDescriptionDefault
userIdYesUser ID

Implementation Reference

  • 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'],
      },
    },
  • Zod schema used for input validation in the get_positions handler, requiring a 'userId' string parameter.
    const GetUserPositionsSchema = z.object({
      userId: z.string(),
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bmorphism/manifold-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server