Skip to main content
Glama
bmorphism

Manifold Markets MCP Server

sell_shares

Sell YES or NO shares in Manifold Markets prediction markets to manage your positions and realize profits or limit losses.

Instructions

Sell shares in a market

Input Schema

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

Implementation Reference

  • The handler function for the 'sell_shares' tool. It validates input using SellSharesSchema, checks for API key, makes a POST request to Manifold Markets API endpoint /v0/market/{marketId}/sell to sell shares, handles errors, and returns the result as text content.
    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 for validating input parameters to the sell_shares tool: marketId (required string), outcome (optional YES/NO), shares (optional number).
    const SellSharesSchema = z.object({ marketId: z.string(), outcome: z.enum(['YES', 'NO']).optional(), shares: z.number().optional(), });
  • src/index.ts:277-289 (registration)
    Tool registration in the ListTools handler, defining the name, description, and JSON inputSchema for sell_shares.
    { 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'], }, },

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