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

@postmcp/core

v0.1.37

Published

PostMCP core engine - OpenAPI parser, Token Diet, JIT router, and MCP protocol server

Readme

@postmcp/core

PostMCP Core Engine - OpenAPI parser, Token Diet optimizer, JIT dynamic router, safety guardrails, and Model Context Protocol (MCP) server.

License: MIT MCP Compliant npm package


Overview

@postmcp/core is the runtime and compilation engine that powers PostMCP. It provides programmatic APIs for parsing OpenAPI specifications, compressing JSON payloads via Token Diet, managing JIT dynamic tool discovery, and running compliant MCP servers over stdio or Streamable HTTP.

Capabilities

  1. AST Parser & Resolver: Circular-safe $ref dereferencing and schema normalization for OpenAPI 2.0 (Swagger), 3.0, and 3.1.
  2. Token Diet Engine: JSON response pruning, field masking, and homogeneous array-to-Markdown table serialization (70%–95% token savings).
  3. Adaptive Hybrid JIT Router: BM25 lexical + semantic search indexing for on-demand tool mounting (tool_search), keeping active tool definitions under 1,500 prompt tokens.
  4. Safety Circuit Breaker & Dry-Run: 3-tier risk classification (READ_ONLY, MUTATION, CRITICAL) with mutation interception and simulation diffs.
  5. Macro Workflow Chainer: Sequential multi-step request orchestration with JSONPath variable passing in server memory.
  6. Multimodal Media Adapters: Automatic binary-to-image encoding (image/png, image/jpeg) as native MCP image blocks, CSV-to-Markdown conversion, and HTTP 202 async task polling.

Installation

npm install @postmcp/core
# or
pnpm add @postmcp/core

Programmatic Usage

1. Parse an OpenAPI Specification

import { parseOpenAPI } from '@postmcp/core';

const ast = await parseOpenAPI('https://api.stripe.com/openapi.json');

console.log(`Loaded API: ${ast.title} (${ast.operations.length} endpoints)`);

2. Apply Token Diet Optimization to Payloads

import { applyTokenDiet } from '@postmcp/core';

const rawApiResponse = [
  { id: 'usr_1', name: 'Alice', _links: { self: '/usr_1' }, meta: null },
  { id: 'usr_2', name: 'Bob', _links: { self: '/usr_2' }, meta: null },
];

const optimized = applyTokenDiet(rawApiResponse, {
  convertToMarkdownTable: true,
  maxTokens: 2500,
});

// Output text is a clean, compact GitHub Markdown table:
// | id | name |
// | usr_1 | Alice |
// | usr_2 | Bob |
console.log(optimized.text);

3. Start an MCP Server Programmatically

import { parseOpenAPI, startStdioServer } from '@postmcp/core';

const spec = await parseOpenAPI('https://api.stripe.com/openapi.json');
const server = await startStdioServer({
  spec,
  auth: {
    bearerToken: process.env.STRIPE_SECRET_KEY,
  },
  jit: true,
  tokenDiet: true,
});

Architecture Components

  • src/parser: OpenAPI 2.0/3.0/3.1 AST parser, parameter extractor, and recursive $ref resolver.
  • src/tokendiet: Payload pruner, JSONPath masking engine, and Markdown table serializer.
  • src/jit: In-memory BM25 indexer, tool registry, and tool_search meta-tool implementation.
  • src/safety: Risk tier classifier, execution gate, and dry-run mutation interceptor.
  • src/macro: Step-by-step in-memory workflow orchestrator with template interpolation.
  • src/media: Image content encoder, CSV parser, and HTTP 202 async polling runner.
  • src/server: Model Context Protocol server implementation supporting both stdio and Streamable HTTP.

License

MIT (c) PostMCP Contributors