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

@xmcp-dev/upstash

v0.1.0

Published

Upstash rate limiting middleware for xmcp tools

Readme

@xmcp-dev/upstash

Apply shared Upstash rate limits to xmcp tool calls with one MCP middleware. Requires xmcp 1.6+ and @upstash/ratelimit 2.2+.

pnpm add @xmcp-dev/upstash @upstash/ratelimit @upstash/redis
// src/middleware.ts
import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";
import { upstashRateLimit } from "@xmcp-dev/upstash";

export const mcp = upstashRateLimit({
  limiter: new Ratelimit({
    redis: Redis.fromEnv(),
    limiter: Ratelimit.fixedWindow(100, "1 m"),
    prefix: "my-app:tools",
  }),
  // An earlier authenticated MCP middleware must set this request-local value.
  identifier: (context) => context.get<string>("customerId"),
});

Set UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN. All replicas must use the same Redis database and prefix to share a budget. Supply an identifier from verified authentication on every request; missing identifiers deny execution. Do not use an unverified customer header or an API key as the Redis identifier.

Options:

  • limiter: an application-owned Upstash Ratelimit instance (or an object with its limit method).
  • identifier(context): required, possibly asynchronous, verified customer ID.
  • rate: positive safe integer or asynchronous callback; defaults to one unit per attempt.
  • failureMode: "closed" (default) denies on Redis failures, SDK timeouts, or failed background work. "open" explicitly allows execution when a quota decision is unavailable. Missing identity and known quota denials always deny.

The middleware only checks tools/call. Quota denial returns an MCP tool error (isError: true) with _meta["xmcp.dev/rateLimit"] containing reason, limit, remaining, reset (Unix milliseconds), and retryAfterSeconds. It does not produce HTTP 429. The middleware awaits the SDK's pending work so serverless runtimes do not discard it. This adds that work's latency to the call.

Each admitted attempt consumes units, including a tool that subsequently fails, is cancelled, or requires another execution round for input. No refunds or billing ledger are provided. Quota algorithms and their consistency guarantees remain those of the supplied Upstash limiter. STDIO works with a server-side identity callback; it has no HTTP headers.

See the integration guide and runnable HTTP example for authenticated identities and weighted tool costs.