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

@lordcraymen/rivetbench

v0.2.0

Published

Lightweight TypeScript framework for dual-exposed endpoints (REST + MCP).

Readme

RivetBench

RivetBench is a lightweight TypeScript framework for building dual‑exposed endpoints that work over both REST and MCP (Model Context Protocol), with OpenAPI 3 documentation generated automatically.

Write an endpoint once — expose it everywhere.


Features

  • Unified endpoint definitions with Zod schemas for validation and typing
  • RPC over REST: POST-only routes that dispatch by endpoint name (no resource modeling)
  • Automatic generation of REST routes, MCP tools, and OpenAPI 3 specs
  • Built‑in Swagger UI for exploration and testing
  • Type‑safe handlers shared between REST and MCP
  • Production-ready error handling with custom error classes and consistent responses
  • Structured logging with Pino (MCP stdio-compatible)

Tech Stack

  • Node.js 20+ / TypeScript
  • Fastify for REST APIs
  • fastmcp for MCP
  • Zod + zod‑to‑openapi for schema generation
  • Pino for structured logging
  • Vitest + Cucumber for testing

Project Layout

rivetbench/
├─ src/
│  ├─ core/                # framework core (endpoint factory, openapi, registry)
│  ├─ server/              # rest + mcp servers
│  ├─ endpoints/           # your endpoints live here
│  └─ config/              # environment and startup settings
├─ test/
│  └─ sample.test.ts
├─ package.json
└─ README.md

Example Endpoint (RPC style)

import { z } from "zod";
import { makeEndpoint } from "../core/endpoint";

const EchoInput = z.object({ message: z.string() });
const EchoOutput = z.object({ echoed: z.string() });

export default makeEndpoint({
  name: "echo",
  summary: "Echo a message",
  input: EchoInput,
  output: EchoOutput,
  // handler is opaque; only input/output are exposed in MCP & OpenAPI
  handler: async ({ input }) => ({ echoed: input.message })
});

Quick Start

npm install
npm run dev:rest     # Start REST + Swagger on :3000
npm run dev:mcp      # Start MCP server (stdio transport)
npm run dev:cli      # Launch the runtime-generated CLI

REST Server

Swagger UI → http://localhost:3000/docs

MCP Server

stdio transport (default):

npm run dev:mcp

HTTP Stream transport (TCP):

RIVETBENCH_MCP_TRANSPORT=tcp RIVETBENCH_MCP_PORT=3001 npm run dev:mcp

The MCP server exposes all registered endpoints as MCP tools with automatic schema validation.

CLI

The CLI inspects the endpoint registry at startup so that available commands always mirror the REST and MCP transports. It provides flexible input methods and output formatting:

Input Methods

Named Parameters (recommended for most use cases):

# String parameters
npm run dev:cli -- call echo -message "Hello World"

# Automatic type parsing for numbers and booleans  
npm run dev:cli -- call myfunc -count 42 -enabled true -rate 3.14

# JSON objects and arrays as parameter values
npm run dev:cli -- call complexFunc -config '{"timeout": 30}' -tags '["web", "api"]'

JSON Input (for complex nested objects):

npm run dev:cli -- call echo --params-json '{"message": "Hello World"}'

Output Formatting

JSON Output (default):

npm run dev:cli -- call echo -message "Hello"
# Output: {"echoed": "Hello"}

Raw Output (for scripting and simple values):

npm run dev:cli -- call echo -message "Hello" --raw
# Output: Hello

npm run dev:cli -- call uppercase -text "world" --raw
# Output: WORLD

Raw output automatically extracts simple values from single-property objects. Complex objects fall back to JSON formatting even in raw mode.

Note: CLI flags use double dashes (--) and endpoint parameters use single dash (-) to avoid naming collisions.

Basic Commands

# List registered endpoints
npm run dev:cli -- list

# Get help
npm run dev:cli -- --help  # Show detailed CLI usage and examples
npm run dev:cli            # Also shows help when no command provided

RPC‑over‑REST semantics

  • POST‑only: Each call is POST /rpc/:name (default) or POST /tools/:name.
  • Stateless: All data comes from the request body; no server session required.
  • Opaque handler: Only the Zod input/output are published (MCP & OpenAPI). The implementation never leaks.
  • OpenAPI: Paths are generated for each endpoint as POST /rpc/{name} with requestBody = input schema and response = output schema.
  • MCP parity: The same definition becomes an MCP tool with matching input/output JSON Schema.

Optional conventions

  • Idempotency: Support Idempotency-Key header for safe retries of POST.
  • Long‑running jobs: If needed, return an operationId in the output; a separate status endpoint/tool can be defined like any other RPC (kept optional).

Documentation


License

MIT


RivetBench — forge and test your API connections.