Skip to main content
Glama

connect_xmtp

Connect to the XMTP decentralized messaging network using wallet authentication to enable encrypted communication between AI agents and XMTP-enabled wallets.

Instructions

Connect to XMTP network with wallet key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
privateKeyNoWallet private key (optional, uses env WALLET_KEY if not provided)
environmentNoXMTP environment: local, dev, or productionproduction

Implementation Reference

  • The main handler function that implements the connect_xmtp tool logic: creates a wallet signer from private key, initializes XMTP Client, and stores it in state.
    private async connectXMTP(args: any) { try { const privateKey = args.privateKey || process.env.WALLET_KEY; const environment = args.environment || process.env.XMTP_ENV || "production"; if (!privateKey) { throw new Error("Private key required. Provide via parameter or WALLET_KEY env variable."); } // Create proper EOA signer for XMTP using viem account (exact same as working debug script) const account = privateKeyToAccount(privateKey as `0x${string}`); const signer = { type: "EOA" as const, signMessage: async (message: string) => { const signature = await account.signMessage({ message }); return toBytes(signature); }, getIdentifier: () => { return { identifier: account.address, identifierKind: 0, // IdentifierKind.Ethereum }; }, getChainId: () => BigInt(1), // Ethereum mainnet as bigint }; // Initialize XMTP client with proper signer this.state.client = await Client.create(signer, { env: environment as "local" | "dev" | "production", }); this.state.walletAddress = account.address; return { content: [ { type: "text", text: `Successfully connected to XMTP ${environment} network with address: ${account.address}`, }, ], }; } catch (error) { throw new Error(`XMTP connection failed: ${error}`); } }
  • src/index.ts:113-131 (registration)
    Registers the connect_xmtp tool in the list of available tools, including name, description, and input schema.
    { name: "connect_xmtp", description: "Connect to XMTP network with wallet key", inputSchema: { type: "object", properties: { privateKey: { type: "string", description: "Wallet private key (optional, uses env WALLET_KEY if not provided)", }, environment: { type: "string", description: "XMTP environment: local, dev, or production", enum: ["local", "dev", "production"], default: "production", }, }, }, },
  • Defines the input schema for the connect_xmtp tool, specifying privateKey and environment parameters.
    inputSchema: { type: "object", properties: { privateKey: { type: "string", description: "Wallet private key (optional, uses env WALLET_KEY if not provided)", }, environment: { type: "string", description: "XMTP environment: local, dev, or production", enum: ["local", "dev", "production"], default: "production", }, }, },
  • Dispatcher switch case that routes connect_xmtp tool calls to the connectXMTP handler.
    case "connect_xmtp": return await this.connectXMTP(args);

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/kwaude/xmtp-mcp'

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