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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool connects to the XMTP network, implying a setup/initialization operation, but lacks details on authentication needs (e.g., permissions required), side effects (e.g., whether it establishes a persistent session), rate limits, error handling, or what happens on failure. The description is minimal and misses key behavioral traits for a connection tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—it directly states the tool's purpose without fluff or redundancy. It's appropriately sized for a simple connection tool and front-loaded with the core action. Every word earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a connection operation with authentication), lack of annotations, and no output schema, the description is incomplete. It doesn't cover what the tool returns (e.g., a connection object, status), error cases, dependencies on sibling tools, or behavioral nuances. For a tool that likely enables other messaging functions, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with both parameters ('privateKey' and 'environment') fully documented in the schema. The description adds no parameter-specific semantics beyond what the schema provides, such as explaining the wallet key format or environment implications. Baseline score is 3 since the schema does the heavy lifting, but the description doesn't compensate or add extra context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Connect to XMTP network') and the resource ('XMTP network'), with the method ('with wallet key') specified. It distinguishes this as a connection/initialization tool versus messaging or querying siblings, though it doesn't explicitly name alternatives. The purpose is specific and actionable, but lacks explicit sibling differentiation for a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or context. It doesn't mention if this is required before using sibling tools like 'send_message' or 'get_messages', nor does it specify scenarios like initial setup or reconnection. Usage is implied only by the tool's name and basic function, with no explicit when/when-not instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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