Skip to main content
Glama

Manifold Markets MCP Server

sell_shares

Sell shares in a Manifold Markets prediction market by specifying the market ID, outcome (YES or NO), and number of shares to sell. Defaults sell all shares if no quantity is provided.

Instructions

Sell shares in a market

Input Schema

NameRequiredDescriptionDefault
marketIdYesMarket ID
outcomeNoWhich type of shares to sell (defaults to what you have)
sharesNoHow many shares to sell (defaults to all)

Input Schema (JSON Schema)

{ "properties": { "marketId": { "description": "Market ID", "type": "string" }, "outcome": { "description": "Which type of shares to sell (defaults to what you have)", "enum": [ "YES", "NO" ], "type": "string" }, "shares": { "description": "How many shares to sell (defaults to all)", "type": "number" } }, "required": [ "marketId" ], "type": "object" }

Implementation Reference

  • Handler for the 'sell_shares' tool. Validates input with SellSharesSchema, checks for API key, sends POST request to Manifold Markets API to sell shares, and returns the result as text.
    case 'sell_shares': { const params = SellSharesSchema.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.marketId}/sell`, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Key ${apiKey}`, }, body: JSON.stringify({ outcome: params.outcome, shares: params.shares, }), }); if (!response.ok) { throw new McpError( ErrorCode.InternalError, `Manifold API error: ${response.statusText}` ); } const result = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • Zod schema defining the input parameters for the sell_shares tool: marketId (required string), optional outcome (YES/NO), optional shares (number). Used for validation in the handler.
    const SellSharesSchema = z.object({ marketId: z.string(), outcome: z.enum(['YES', 'NO']).optional(), shares: z.number().optional(), });
  • src/index.ts:277-289 (registration)
    Registration of the 'sell_shares' tool in the ListTools response, including name, description, and JSON input schema matching the Zod schema.
    { name: 'sell_shares', description: 'Sell shares in a market', inputSchema: { type: 'object', properties: { marketId: { type: 'string', description: 'Market ID' }, outcome: { type: 'string', enum: ['YES', 'NO'], description: 'Which type of shares to sell (defaults to what you have)' }, shares: { type: 'number', description: 'How many shares to sell (defaults to all)' }, }, required: ['marketId'], }, },

Other Tools

Related Tools

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