close_market
Close a Manifold Markets prediction market to stop trading and resolve outcomes using the market ID and optional timestamp.
Instructions
Close a market for trading
Input Schema
TableJSON 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:823-859 (handler)Handler for the 'close_market' tool. Parses input parameters using CloseMarketSchema, checks for API key, makes a POST request to Manifold Markets API to close the specified market, and returns a success message.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:97-100 (schema)Zod schema defining the input parameters for the close_market tool: contractId (required string) and closeTime (optional nonnegative integer Unix timestamp).const CloseMarketSchema = z.object({ contractId: z.string(), closeTime: z.number().int().nonnegative().optional(), });
- src/index.ts:325-336 (registration)MCP tool registration for 'close_market', including name, description, and JSON input schema matching the Zod schema.{ 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'] } },