Skip to content

bosonprotocol/chat-sdk

Repository files navigation

banner

Chat SDK for Boson Protocol v2

🛠️ Tools for building on top of the Boson Protocol.

JS lib which extends @xmtp/xmtp-js, adding support for chat threads and further message types.


Install

npm i @bosonprotocol/chat-sdk

Usage

  • Initialise SDK
    • import { BosonXmtpClient } from "@bosonprotocol/chat-sdk";
      const client = await BosonXmtpClient.initialise(signer, "test");
  • Get Chat Threads
    • const counterparties = ["0xabc123", "0xdef456", ...];
      const threads = await client.getThreads(counterparties);
  • Send Message
    • const messageObj = {
        threadId: {
          exchangeId: "1",
          buyerId: "2",
          sellerId: "3"
        },
        contentType: MessageType.String,
        version: "0.0.1",
        content: {
          value: "Example message"
        }
      };
      const recipient = "0xabc123...";
      await client.encodeAndSendMessage(messageObj, recipient);
  • Monitor Chat Thread (i.e. for incoming messages)
    • for await (const message of await client.monitorThread(threadId, counterparty)) {
        console.log(message);
      }

MCP server & client

This package also ships a Model Context Protocol (MCP) server and client (under src/mcp/) that expose Boson XMTP messaging as tools — initialise an XMTP client, read threads, send messages, and revoke installations — so AI agents can use them. It is published with the boson-xmtp-mcp-server binary and supports two transports:

  • stdio — the server runs as a local subprocess on the end user's machine (recommended).
  • HTTP — a long-running server that you host on infrastructure you control.

⚠️ Security: the MCP server acts on behalf of a wallet and needs its private key. Anyone who can reach the server or read its logs/memory can sign as that wallet. Run it locally (stdio) or self-host it privately — never point a client at a shared/public server, and never expose it unauthenticated. Provide the key as a hosting secret, never in client requests or committed files.

Read SECURITY.md and the self-hosting guide before running or deploying the MCP server.


Local Development

  • Build
    • npm run build
  • Test
    • npm run test:all
      npm run test:unit
      npm run test:integration
  • Lint
    • npm run lint
      npm run lint:fix
  • Format
    • npm run prettier

About

Implementation of XMTP Protocol to facilitate Buyer to Seller Communications in the Boson Protocol dApp https://bosonapp.io/

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors