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

@curatedmcp/tokenshield-core

v1.3.2

Published

TokenShield proxy engine — Anthropic API-layer middleware with token accounting

Readme

@curatedmcp/tokenshield-core

The proxy engine behind TokenShield. Anthropic API-layer middleware with token accounting, conversation dedup, and response cache.

npm version license

You probably want @curatedmcp/tokenshield instead. That's the CLI. This package is the embeddable engine — use it if you're integrating TokenShield directly into another Node server.


Install

npm install @curatedmcp/tokenshield-core

What's in the box

  • Pipeline — middleware runner with fail-open semantics and per-processor circuit breakers
  • conversationDedup — content-hash tool_result blocks; replace 2nd+ with deterministic pointer stubs
  • responseCache — LRU+TTL cache for temperature === 0 && stream === false requests
  • anthropic — provider adapter (URL matching, SSE usage parsing, message conversion)
  • Ledger — SQLite-backed request log using Node 22's built-in node:sqlite (zero native deps)
  • dollarsFor() — accurate pricing math across all Anthropic models (Opus 4.7, Sonnet 4.6, Haiku 4.5, …)

Minimal example

import { Pipeline, conversationDedup, anthropic } from "@curatedmcp/tokenshield-core";

const pipeline = new Pipeline({
  processors: [conversationDedup],
  enabled: new Set(["conversation-dedup"]),
});

const conv = anthropic.toConversation(anthropicMessagesRequest);
const result = pipeline.run(conv, {
  providerId: "anthropic",
  conversationFingerprint: "...",
  inboundBytes: 12_345,
});

const compressedRequest = anthropic.applyConversation(anthropicMessagesRequest, result.conversation);
// → send compressedRequest to api.anthropic.com

Provider adapter interface

If you want to add OpenAI, Gemini, or a custom provider, implement:

interface Provider {
  id: "anthropic" | "openai" | "gemini" | string;
  matches(url: URL, headers: Record<string, string>): boolean;
  parseUsageFromJson(body: unknown): { usage: UsageCounts; model: string | null };
  parseUsageFromSSE(event: SSEEvent, acc: UsageAccumulator): void;
  extractModel(requestBody: unknown): string;
  toConversation(requestBody: unknown): Conversation | null;
  applyConversation(requestBody: unknown, conv: Conversation): unknown;
}

OpenAI lands in v1.1, Gemini in v1.2 — or send a PR.

Privacy guarantees

  • All work happens in-process. Nothing leaves the host that calls this library.
  • No network I/O except the upstream provider call you make yourself.
  • The optional ledger writes to a SQLite file you control (~/.tokenshield/ledger.db by default).

Architecture & full docs

This is the engine. For the full CLI, dashboard, integrations, and end-user docs, see:

Part of the CuratedMCP control plane

TokenShield is one of three products at curatedmcp.com — the MCP governance control plane for engineering organizations:

  • 🛡️ TokenShield — cut your Claude Code bill 40–70%
  • 🔍 MCP Auditor — static analysis for MCP server security
  • 📊 Sentinel — runtime anomaly detection

Start an enterprise pilot →

License

MIT — see LICENSE.