Skip to main content
Glama
Zetrix-Chain

Zetrix MCP Server

Official
by Zetrix-Chain

zetrix_ws_connect

Connect to Zetrix blockchain WebSocket to receive real-time updates and notifications for registered API message types.

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 and input schema definition 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 server handler for zetrix_ws_connect tool that invokes 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);
      });
    }
  • Singleton factory for ZetrixWebSocketClient instance used by WS tools
    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