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
| Name | Required | Description | Default |
|---|---|---|---|
| marketId | Yes | Market ID | |
| outcome | No | Which type of shares to sell (defaults to what you have) | |
| shares | No | How many shares to sell (defaults to all) |
Implementation Reference
- src/index.ts:684-722 (handler)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), }, ], }; }
- src/index.ts:77-81 (schema)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'], }, },