sell_shares
Sell YES or NO shares from a prediction market. Specify the market ID and optionally the number of shares to sell.
Instructions
Sell shares in a market
Input 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:77-81 (schema)Zod schema for validating sell_shares input parameters (marketId required, outcome and shares optional).
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 list of available tools, defining its name, description, and input 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'], }, }, - src/index.ts:684-722 (handler)Handler logic for sell_shares: parses args, validates API key, POSTs to Manifold's sell endpoint, and returns the JSON result.
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), }, ], }; }