Skip to main content
Glama
bmorphism

Manifold Markets MCP Server

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
NameRequiredDescriptionDefault
contractIdYesMarket ID
closeTimeNoOptional. Unix timestamp in milliseconds when market will close

Implementation Reference

  • 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',
          },
        ],
      };
    }
  • 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']
      }
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bmorphism/manifold-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server