close_market
Closes a prediction market to new trades, optionally at a specified time.
Instructions
Close a market for trading
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contractId | Yes | Market ID | |
| closeTime | No | Optional. Unix timestamp in milliseconds when market will close |
Implementation Reference
- src/index.ts:97-100 (schema)Zod schema for close_market tool validation. Expects contractId (string) and optional closeTime (nonnegative integer).
const CloseMarketSchema = z.object({ contractId: z.string(), closeTime: z.number().int().nonnegative().optional(), }); - src/index.ts:823-859 (handler)Handler for the 'close_market' tool. Parses arguments with Zod schema, checks for MANIFOLD_API_KEY env var, sends POST request to Manifold API /v0/market/{contractId}/close endpoint, and returns success text on completion.
case 'close_market': { const params = CloseMarketSchema.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.contractId}/close`, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Key ${apiKey}`, }, body: JSON.stringify({ closeTime: params.closeTime, }), }); if (!response.ok) { throw new McpError( ErrorCode.InternalError, `Manifold API error: ${response.statusText}` ); } return { content: [ { type: 'text', text: 'Market closed successfully', }, ], }; } - src/index.ts:326-336 (registration)Registration of the close_market tool with name, description, and inputSchema for the MCP server.
name: 'close_market', description: 'Close a market for trading', inputSchema: { type: 'object', properties: { contractId: { type: 'string', description: 'Market ID' }, closeTime: { type: 'number', description: 'Optional. Unix timestamp in milliseconds when market will close' } }, required: ['contractId'] } },