Skip to main content
The official Node.js SDK for VaultGraph, the hosted MCP gateway for e-commerce merchants. This enables AI chats to interact with your merchant backend and turns your AI chat into a full, interactive shopping experience for your customers. Use this SDK to:
  • Integrate your storefront with VaultGraph in one file with the @vaultgraph/sdk/adapter helper. The hosted gateway POSTs to one HTTPS endpoint you expose; your cart/checkout/order records never leave your infrastructure. This is the merchant integration path — your storefront never calls VaultGraph.
  • Manage your VaultGraph workspace from your backend (create shops, rotate keys).
  • Generate Ed25519 signing keys with the bundled key helpers.

Install

Also works with npm install @vaultgraph/sdk or yarn add @vaultgraph/sdk.

Before you start

  1. Sign up at app.vaultgraph.com and create your organization.
  2. Create a shop, then a deployment for that shop. Each deployment gets its own MCP endpoint.
  3. Generate an API key. Organization keys (vk_...) cover org-wide operations such as listing shops; deployment keys (dk_...) are scoped to a single deployment.
Keep API keys out of browser code — the SDK is server-side only.

Integrate your storefront (@vaultgraph/sdk/adapter)

Mount one HTTPS endpoint and your storefront is wired to VaultGraph. The helper handles signing, replay protection, idempotency dedupe, and error serialization. Callbacks are typed over Checkout, Buyer, LineItem, Order, Product, Variant, … from @vaultgraph/sdk/adapter. If you’re integrating an existing storefront, this is the only thing you need to implement on your side. There are no merchant-side calls to VaultGraph and no REST endpoints to consume. The gateway calls your endpoint; you respond. Every method is optional. Implement only what you need today — anything you skip auto-returns not_implemented (501), which the gateway surfaces as commerce_backend_unavailable to agents. The gateway also advertises only the tools you implement: the handler reports your method set on request, so agents see exactly what your backend serves. Add methods incrementally as you build out your storefront:
The handler is framework-agnostic — it returns (req) => Promise<res>. Mount it from any HTTP server:
Configure the endpoint URL and a shared HMAC secret on your deployment in app.vaultgraph.com and you’re live. The full wire contract — envelope shape, signing scheme, error mapping, idempotency rules, and retry policy — is documented in the Remote adapter protocol reference. Pass an optional idempotencyStore to createAdapterHandler — any { get(key), set(key, { status, body }) } and the helper replays the cached response on retries instead of re-running your code. Pass an optional verifySession to authenticate the caller once per request: it is the sole consumer of context.session_token, turning it into a typed identity that the handler hands to every method as the final session argument. The handler strips session_token from the context methods receive, so a method can’t bypass the hook by trusting the raw token. Return null for an anonymous caller, or throw to reject the request. Omit it and every method is still called with a final session argument, but it is always undefined — configure the hook to authorize owner-scoped reads. Implement requestAuthentication / verifyAuthentication to let customers sign in mid-conversation: you email a one-time code and return an AuthChallenge, then verify the code and return an AuthSession whose session_token arrives on later requests as context.session_token — the same token verifySession authenticates. Flow details and security guidance (enumeration resistance, attempt caps, token scope) are in the protocol reference’s Customer sign-in section.

Manage shops

Use the shops client for control-plane operations against /api/shops — separate from storefront integration:

Key helpers

The SDK exports server-side helpers for Ed25519 signing keys:
These run entirely locally and do not call the VaultGraph API.

API reference

Client factories

FunctionDescription
createShopsClient(options)CRUD for /api/shops (org-wide, vk_ keys)
createAdapterHandler(adapter)Build a typed webhook handler for a VaultGraph commerce backend

Key helpers

FunctionDescription
generateKeyPair()Generate a PEM-encoded Ed25519 key pair
derivePublicKeyPem(key)Derive the SPKI PEM public key from a private key

Types

Shops: ShopRecord, ShopCreateInput, ShopUpdateInput, ShopsClient, ShopsClientOptions Adapter (@vaultgraph/sdk/adapter subpath): MerchantCommerceAdapter, AdapterHandler, AdapterHandlerOptions, AdapterHandlerRequest, AdapterHandlerResponse, AdapterIdempotencyStore, AdapterHandlerError, Product, Variant, Price, PriceRange, Media, ProductPage, ProductPagination, RequestContext, SearchCatalogInput, FulfillmentMethod, Checkout, CheckoutCreateInput, Order, Buyer, BillingAddress, LineItem, ShippingDestination, AuthChallenge, AuthSession.