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

@mokei/http-server

v0.14.0

Published

Mokei MCP HTTP server handler

Readme

@mokei/http-server

MCP Streamable HTTP server handler for Mokei.

Serves an MCP ContextServer over the MCP Streamable HTTP transport, with session management, SSE streaming, replay buffering, and origin validation (DNS-rebinding protection).

Installation

pnpm add @mokei/http-server

Usage

Both protocol revisions are served. A 2025-11-25 client gets a session (Mcp-Session-Id, resumable GET stream, DELETE to terminate); a 2026-07-28 client is handled statelessly — no session is minted, GET and DELETE return 405, and each request is answered by its own short-lived ContextServer. List both revisions in protocolVersions to reach both.

The 2025-11-25 session GET/SSE stream is deprecated on 2026-07-28 (SEP-2577): on 2026-07-28, notifications travel on the POST response of the request that triggered them, so there is no equivalent stream to deprecate on that revision — it simply doesn't apply there. The 2025-11-25 session GET stream itself remains fully supported for the deprecation window. This does not affect the 2026-07-28 Streamable HTTP transport, which is current and not deprecated.

serveHTTP starts an HTTP server (via @hono/node-server) that bridges each session to a ContextServer you create per connection:

import { serveHTTP } from '@mokei/http-server'
import { ContextServer } from '@mokei/context-server'

const { server, dispose } = serveHTTP({
  port: 3000,
  hostname: '127.0.0.1',
  path: '/mcp',
  createServer: (transport) =>
    new ContextServer({
      transport,
      name: 'my-server',
      version: '1.0.0',
      protocolVersions: ['2026-07-28', '2025-11-25'],
      tools,
    }),
})

// Later, to shut down:
dispose()

To embed the handler in an existing HTTP framework, use createHTTPHandler and route requests to its handleRequest(request) method:

import { createHTTPHandler } from '@mokei/http-server'

const handler = createHTTPHandler({
  createServer: (transport) =>
    new ContextServer({
      transport,
      name: 'my-server',
      version: '1.0.0',
      protocolVersions: ['2026-07-28', '2025-11-25'],
      tools,
    }),
  allowedOrigins: ['https://app.example.com'],
})

const response = await handler.handleRequest(request)

Subscriptions & graceful shutdown

When subscriptionHub is passed to serveHTTP / createHTTPHandler, 2026-07-28 subscriptions/listen POSTs are served against transport-isolated per-POST servers that borrow that hub — they do not own it. The handler's own dispose() (the value returned by serveHTTP, or handler.dispose()) is therefore only the abrupt backstop: it does not gracefully complete open subscriptions, so any still-open subscriptions/listen stream is torn down abruptly with no terminal frame written.

To shut down gracefully, dispose the durable hub-owning ContextServer first (or call hub.endAllGracefully() directly), and only then call the HTTP handler's dispose():

// 1. Gracefully complete every open subscription against the durable hub-owning server.
await hub.endAllGracefully()

// 2. Only now tear down the HTTP layer.
await dispose()

Documentation

See the full documentation at mokei.dev.

License

MIT