npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

langchain-assistanthub

v0.1.4

Published

LangChain.js toolkit for Assistant Hub — crypto intelligence via MCP

Readme

langchain-assistanthub

Crypto Intelligence Toolkit for LangChain.js / LangGraph.js agents

npm version npm downloads License: MIT

Add real-time crypto prices, risk scores, AI forecasts, and more to any LangChain.js agent in 3 lines of code. Connects to Assistant Hub via MCP (Model Context Protocol).

Install

# Recommended: pin to current stable version
npm install [email protected]

# Or latest
# npm install langchain-assistanthub

We're at v0.1.4 — pinned install recommended for stability. Check the changelog for updates!

Quick Start

import { AssistantHubToolkit } from 'langchain-assistanthub';
import { createReactAgent } from '@langchain/langgraph/prebuilt';
import { ChatOpenAI } from '@langchain/openai';

// 1. Create toolkit
const toolkit = AssistantHubToolkit.fromApiKey('your-hub-api-key');

// 2. Get tools
const tools = toolkit.getTools();

// 3. Plug into any agent
const model = new ChatOpenAI({ model: 'gpt-4o' });
const agent = createReactAgent({ llm: model, tools });

const result = await agent.invoke({
  messages: [{ role: 'user', content: 'What are the current crypto prices?' }],
});

Authentication

Option A: API Key

const toolkit = AssistantHubToolkit.fromApiKey('ahk_abc123');

Option B: Environment Variable

export ASSISTANT_HUB_API_KEY=ahk_abc123
const toolkit = AssistantHubToolkit.fromEnv();

Option C: Login with Credentials

const toolkit = await AssistantHubToolkit.fromLogin('[email protected]', 'password');

Option D: Zero-Code MCP (no wrapper needed)

If you already use @langchain/mcp-adapters, point directly at the MCP endpoint:

import { MultiServerMCPClient } from '@langchain/mcp-adapters';

const client = new MultiServerMCPClient({
  'assistant-hub': {
    transport: 'streamable-http',
    url: 'https://rmassistanthub.io/mcp',
    headers: { 'X-API-Key': 'ahk_abc123' },
  },
});

const tools = await client.getTools();

Available Tools

Free Tools (no API key required)

| Tool | Description | |------|-------------| | live_prices | Real-time prices for BTC, ETH, SOL, DOGE, AVAX, LINK, ADA, DOT | | fear_greed | Crypto Fear & Greed Index (0-100) | | crypto_news | Latest 12 crypto headlines from CryptoCompare | | risk_scores | AI-computed risk scores (0-100) per coin | | daily_pulse | Daily Macro Pulse: top 3 threats + top 3 opportunities |

Premium Tools (Pro/Premium tier or x402 USDC)

| Tool | Description | |------|-------------| | ai_forecast | AI-powered 24h/7d price predictions | | monte_carlo_backtest | Monte Carlo strategy backtesting | | slippage_estimate | Trade slippage estimation | | create_alert | Price/change alerts |

Configuration

const toolkit = new AssistantHubToolkit({
  apiKey: 'ahk_abc123',          // Hub API key or JWT
  baseUrl: 'https://rmassistanthub.io',  // default
  includePremium: true,           // include premium tools (default: true)
  tools: ['live_prices', 'fear_greed'],  // filter to specific tools
  maxRetries: 2,                  // retry on transient failures (default: 2)
  timeout: 30_000,                // request timeout in ms (default: 30s)
});

Tool Metadata

Query tool info before calling — lets agents decide if they need to pay:

const meta = toolkit.getToolMetadata('ai_forecast');
console.log(meta);
// {
//   hubToolId: 'ai_forecast',
//   name: 'assistant_hub_ai_forecast',
//   tierRequired: true,
//   dailyLimits: { anonymous: 10, free: 50, pro: 200, premium: 'unlimited' },
//   x402PriceUsdc: 0.01,
//   stakingDiscountPct: 50,
//   description: '...'
// }

x402 Auto-Payment (USDC on Base)

Premium tools return HTTP 402 when payment is required. With x402 configured, the SDK auto-pays via USDC on Base and retries — zero friction for agents:

Option A: BANKR Agent Wallet (easiest — no private key needed)

const toolkit = new AssistantHubToolkit({
  apiKey: 'ahk_abc123',
  x402: {
    bankrApiKey: 'your-bankr-api-key',
    maxPerCallUsdc: 0.10,     // safety cap per call (default: $0.10)
    maxPerSessionUsdc: 1.00,  // safety cap per session (default: $1.00)
    verbose: true,            // log payments to console
  },
});

// Premium tools now auto-pay — no 402 errors!
const tools = toolkit.getTools();

Option B: Custom Signer (viem, ethers, etc.)

import { createWalletClient, http } from 'viem';
import { base } from 'viem/chains';

const toolkit = new AssistantHubToolkit({
  apiKey: 'ahk_abc123',
  x402: {
    signer: async (payment) => {
      // Build and send USDC transfer, return tx hash
      const txHash = await sendUsdcTransfer(
        payment.recipientAddress,
        payment.amountUsdc
      );
      return txHash;
    },
  },
});

Session Spend Tracking

const handler = toolkit.x402;
if (handler) {
  console.log(`Session spend: $${handler.spent}`);
  handler.resetSession(); // Reset counter
}

Error Handling

All errors extend AssistantHubError with actionable CTAs:

import {
  AssistantHubError,
  AssistantHubRateLimitError,
  AssistantHubPaymentRequiredError,
  AssistantHubForbiddenError,
  AssistantHubServerError,
} from 'langchain-assistanthub';

try {
  await tool.invoke({ coin: 'BTC' });
} catch (e) {
  if (e instanceof AssistantHubRateLimitError) {
    console.log(e.detail);  // "Free tier: 10 calls/day limit reached."
    console.log(e.message); // Includes upgrade CTA
  }
}

Telemetry

Anonymous, privacy-first telemetry ping on toolkit init (no PII, no IP logging).

Opt out:

export ASSISTANT_HUB_TELEMETRY_OPT_OUT=1

Links

License

MIT — see LICENSE