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

@tklein1801/express-mcp-template

v1.0.0

Published

ExpressJS server exposing an MCP (Model Context Protocol) service — usable as npx executable

Readme

@tklein1801/express-mcp-template

A ready-to-use template for building an MCP (Model Context Protocol) service on top of Express.js, written in TypeScript.

Features

| Feature | Tool | |---|---| | HTTP server | Express.js | | MCP protocol | @modelcontextprotocol/sdk via Streamable HTTP transport | | Language | TypeScript (ESM, NodeNext) | | Linting & formatting | Biome | | Git hooks | Husky + lint-staged | | Unit tests | Vitest | | CI | GitHub Actions | | npx executable | bin entry + shebang |


Quick start (npx)

Run the MCP server without cloning:

# Install globally (optional)
npm install -g @tklein1801/express-mcp-template

npx express-mcp-template

The server starts on http://localhost:3000 by default.

CLI flags (take precedence over environment variables):

npx express-mcp-template --port 8080
npx express-mcp-template --port 8080 --host 0.0.0.0
npx express-mcp-template --help

Environment variables (used when no CLI flag is given):

| Variable | Default | Description | |---|---|---| | PORT | 3000 | TCP port | | HOST | localhost | Bind address |


MCP endpoint

| Endpoint | Description | |---|---| | POST /mcp | Initialize a new session or send a message (primary endpoint) | | GET /mcp | Open SSE stream for server-initiated notifications | | DELETE /mcp | Close a session | | GET /health | Health check |

Connecting with an MCP client

{
  "mcpServers": {
    "my-server": {
      "url": "http://localhost:3000/mcp"
    }
  }
}

Built-in capabilities

Tools

| Tool | Description | |---|---| | echo | Returns the input message unchanged | | add | Adds two numbers | | get_current_time | Current date/time, optionally in a given IANA timezone | | random_number | Random integer in [min, max] | | base64_encode | Encodes a UTF-8 string to Base64 | | base64_decode | Decodes a Base64 string to UTF-8 | | server_info | Returns runtime info (name, version, Node.js, platform, uptime) |

Prompts

| Prompt | Description | |---|---| | summarize | Summarize text at a given length (short / medium / long) | | code_review | Review a code snippet for bugs, quality, and security | | explain_error | Explain an error message or stack trace and suggest fixes | | write_commit_message | Generate a Conventional Commits message from a diff |

Resources

| URI | Description | |---|---| | mcp://server/info | Runtime info (name, version, Node.js, platform, arch, uptime) | | mcp://server/env | Safe env vars (NODE_ENV, PORT, HOST, TZ) | | mcp://server/tools | Human-readable catalogue of all registered tools |

Add your own tools in src/mcp/tools.ts, prompts in src/mcp/prompts.ts, and resources in src/mcp/resources.ts.


Development

Prerequisites

  • Node.js ≥ 18
  • npm ≥ 9

Setup

git clone [email protected]:tklein1801/express-mcp-template.git
cd express-mcp-template
npm install

Scripts

npm run dev          # Start with hot-reload (tsx watch)
npm run build        # Compile TypeScript → dist/
npm run start        # Run compiled output
npm test             # Run unit tests (Vitest)
npm run test:watch   # Watch mode
npm run test:coverage # Coverage report
npm run lint         # Biome check
npm run lint:fix     # Biome check + auto-fix
npm run format       # Biome format (write)

Pre-commit hook

Husky runs lint-staged before every commit. Staged *.ts, *.js, and *.json files are automatically checked and fixed by Biome.


Project structure

.
├── src/
│   ├── index.ts          # Bin entry point (shebang, starts the server)
│   ├── server.ts         # Express app factory (Streamable HTTP transport)
│   └── mcp/
│       ├── server.ts     # MCP server factory (one per session)
│       ├── tools.ts      # Tool registrations
│       ├── prompts.ts    # Prompt registrations
│       └── resources.ts  # Resource registrations
├── tests/
│   ├── server.test.ts    # Express route tests
│   └── tools.test.ts     # MCP tool unit tests
├── .github/workflows/
│   └── ci.yml            # Build · Lint · Test on Node 18 / 20 / 22
├── .husky/
│   └── pre-commit        # lint-staged
├── biome.json
├── tsconfig.json
└── package.json

GitHub Actions CI

The workflow (.github/workflows/ci.yml) runs on every push / pull request:

  1. Lintbiome check .
  2. Buildtsc
  3. Testvitest run
  4. Pack dry-runnpm pack --dry-run (verifies publish readiness)

Matrix: Node.js 18, 20, 22.


Documentation

| File | Contents | |---|---| | docs/transports.md | Streamable HTTP transport internals, all endpoint details, comparison with legacy SSE & stdio |


License

MIT