close_market
Shut down a market for trading by specifying the market ID and optional close time, ensuring no further bets are placed. Part of the Manifold Markets MCP Server.
Instructions
Close a market for trading
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| closeTime | No | Optional. Unix timestamp in milliseconds when market will close | |
| contractId | Yes | Market ID |
Input Schema (JSON Schema)
{
"properties": {
"closeTime": {
"description": "Optional. Unix timestamp in milliseconds when market will close",
"type": "number"
},
"contractId": {
"description": "Market ID",
"type": "string"
}
},
"required": [
"contractId"
],
"type": "object"
}
Implementation Reference
- src/index.ts:823-859 (handler)Handler for close_market tool. Parses input parameters using CloseMarketSchema, requires MANIFOLD_API_KEY, sends POST request to Manifold Markets API to close the specified market (optionally at a future closeTime), handles errors, 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 input for close_market: required contractId (string), optional closeTime (non-negative integer Unix timestamp in ms).const CloseMarketSchema = z.object({ contractId: z.string(), closeTime: z.number().int().nonnegative().optional(), });
- src/index.ts:325-336 (registration)Tool registration in ListTools response: defines name 'close_market', description, and inputSchema 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'] } },