Skip to main content
Glama

zetrix_ws_connect

Connect to Zetrix blockchain WebSocket for real-time updates and register for specific API message types to monitor network events.

Instructions

Connect and register to Zetrix WebSocket for real-time updates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiListNoOptional list of API message types to register (numbers)

Implementation Reference

  • src/index.ts:355-367 (registration)
    Tool registration object defining name, description, and input schema for zetrix_ws_connect
    { name: "zetrix_ws_connect", description: "Connect and register to Zetrix WebSocket for real-time updates", inputSchema: { type: "object", properties: { apiList: { type: "array", description: "Optional list of API message types to register (numbers)", }, }, }, },
  • MCP CallToolRequest handler case for zetrix_ws_connect, delegates to ZetrixWebSocketClient.registerAndConnect
    case "zetrix_ws_connect": { const wsClient = getWebSocketClient(); const result = await wsClient.registerAndConnect( args?.apiList as number[] | undefined ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
  • Core implementation of WebSocket connection and CHAIN_HELLO registration in ZetrixWebSocketClient
    async registerAndConnect(apiList?: number[]): Promise<ChainHelloResponse> { await this.connect(); return new Promise((resolve, reject) => { const helloMessage: ChainHelloRequest = { type: ChainMessageType.CHAIN_HELLO, api_list: apiList || [ ChainMessageType.CHAIN_SUBMITTRANSACTION, ChainMessageType.CHAIN_SUBSCRIBE_TX, ChainMessageType.CHAIN_LEDGER_HEADER, ChainMessageType.CHAIN_TX_STATUS, ChainMessageType.CHAIN_TX_ENV_STORE, ], timestamp: Date.now(), }; const timeout = setTimeout(() => { this.off("hello", onHello); reject(new Error("CHAIN_HELLO timeout")); }, 10000); const onHello = (response: ChainHelloResponse) => { clearTimeout(timeout); resolve(response); }; this.once("hello", onHello); this.sendMessage(helloMessage); }); }
  • Helper function providing singleton ZetrixWebSocketClient instance
    function getWebSocketClient(): ZetrixWebSocketClient { if (!zetrixWsClient) { const wsUrl = ZETRIX_WS_URL || WS_NETWORK_URLS[ZETRIX_NETWORK]; zetrixWsClient = new ZetrixWebSocketClient(wsUrl); } return zetrixWsClient; }

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/Zetrix-Chain/zetrix-mcp-server'

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