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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@leanmcp/cli

v0.2.5

Published

Command-line interface for scaffolding LeanMCP projects

Readme

@leanmcp/cli

Command-line tool for creating LeanMCP projects with production-ready templates.

Features

  • Interactive setup - Guided prompts for dependency installation and dev server
  • Quick project scaffolding - Create new MCP servers in seconds
  • Complete setup - Includes TypeScript, dependencies, and configuration
  • Best practices - Generated projects follow MCP standards
  • Ready to run - Start developing immediately with hot reload
  • Example service - Includes working examples to get started
  • Pure ESM - Modern ES modules with full TypeScript support

Installation

# npm 
npm install -g @leanmcp/cli

# GitHub Packages 
npm install -g @leanmcp/cli --registry=https://npm.pkg.github.com

Or use without installing:

npx @leanmcp/cli create my-mcp-server

Usage

Create a New Project

leanmcp create <project-name>

Or with npx:

npx @leanmcp/cli create my-mcp-server

Example

$ leanmcp create my-sentiment-tool
✔ Project my-sentiment-tool created!

Success! Your MCP server is ready.

Next, navigate to your project:
  cd my-sentiment-tool

? Would you like to install dependencies now? (Y/n) Yes
✔ Dependencies installed successfully!
? Would you like to start the development server? (Y/n) Yes

Starting development server...

> [email protected] dev
> tsx watch main.ts

[HTTP][INFO] Starting LeanMCP HTTP Server...
[HTTP][INFO] Server running on http://localhost:3001
[HTTP][INFO] MCP endpoint: http://localhost:3001/mcp

Add a New Service

After creating a project, you can quickly add new services:

leanmcp add <service-name>

This command:

  • Creates a new service file in mcp/<service-name>.ts
  • Includes example Tool, Prompt, and Resource decorators
  • Automatically registers the service in main.ts
  • Includes schema validation examples

Example:

$ leanmcp add weather
✔ Created new service: weather
   File: mcp/weather.ts
   Tool: greet
   Prompt: welcomePrompt
   Resource: getStatus

Service automatically registered in main.ts!

The generated service includes:

  • Tool - greet(): A callable function with schema validation
  • Prompt - welcomePrompt(): A reusable prompt template
  • Resource - getStatus(): A data endpoint

You can then customize these to fit your needs.

Generated Project Structure

my-mcp-server/
├── main.ts              # Entry point with HTTP server
├── package.json         # Dependencies and scripts
├── tsconfig.json        # TypeScript configuration
└── mcp/                 # Services directory
    └── example.ts       # Example service with tools

Generated Files

main.ts

Entry point that:

  • Loads environment variables
  • Creates MCP server instance
  • Registers services
  • Starts HTTP server with session management

mcp/example.ts

Example service demonstrating:

  • @Tool decorator for callable functions
  • @Resource decorator for data sources
  • @Prompt decorator for prompt templates
  • Class-based schema validation with @SchemaConstraint
  • Input/output type safety

package.json

Includes:

  • @leanmcp/core - Core MCP functionality
  • @modelcontextprotocol/sdk - Official MCP SDK
  • express - HTTP server
  • tsx - TypeScript execution with hot reload
  • All type definitions

tsconfig.json

Configured with:

  • ESNext modules
  • Decorator support
  • Strict type checking
  • Source maps

NPM Scripts

Generated projects include:

npm run dev     # Start with hot reload (tsx watch)
npm run build   # Build for production
npm run start   # Run production build
npm run clean   # Remove build artifacts

Development Workflow

Interactive Setup (Recommended)

The CLI provides an interactive setup experience:

# Create project
leanmcp create my-mcp-server

# The CLI will:
# 1. Create project structure
# 2. Ask if you want to install dependencies (Y/n)
# 3. If yes, ask if you want to start dev server (Y/n)
# 4. If yes, start server with hot reload

# If you choose "No" to installation:
cd my-mcp-server
npm install
npm run dev

Manual Setup

If you prefer manual control:

# 1. Create project (answer "No" to prompts)
leanmcp create my-mcp-server

# 2. Navigate to project
cd my-mcp-server

# 3. Install dependencies
npm install

# 4. Start development server
npm run dev

# 5. Server starts on http://localhost:3001
# - Endpoint: http://localhost:3001/mcp
# - Health check: http://localhost:3001/health
# - Hot reload enabled

# 6. Edit files in mcp/ directory
# Server automatically reloads on changes

Testing Your Server

Test with curl:

# List available tools
curl http://localhost:3001/mcp \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/list"
  }'

# Call a tool
curl http://localhost:3001/mcp \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "calculate",
      "arguments": {
        "a": 10,
        "b": 5,
        "operation": "add"
      }
    }
  }'

Customizing Generated Projects

Add New Services

Quick Way (Recommended):

Use the add command to automatically generate and register a new service:

leanmcp add weather

This creates mcp/weather.ts with example Tool, Prompt, and Resource decorators, and automatically registers it in main.ts.

Manual Way:

Create a new file in mcp/:

// mcp/weather.ts
import { Tool } from "@leanmcp/core";

export class WeatherService {
  @Tool({ description: 'Get weather for a city' })
  async getWeather(input: { city: string }) {
    // Your implementation
    return { temperature: 72, condition: 'sunny' };
  }
}

Register in main.ts:

import { WeatherService } from "./mcp/weather.js";

server.registerService(new WeatherService());

Add Authentication

Install auth package:

npm install @leanmcp/auth

See @leanmcp/auth documentation for details.

Configure Port

Set in environment variable:

PORT=4000 npm run dev

Or in .env file:

PORT=4000

Advanced Options

Custom Project Location

leanmcp create my-project
cd my-project

Project is created in current directory with the specified name.

Modify Template

The generated project is fully customizable:

  • Edit main.ts for server configuration
  • Add/remove services in mcp/ directory
  • Modify package.json for additional dependencies
  • Update tsconfig.json for compiler options

Troubleshooting

Port Already in Use

Change the port in .env:

PORT=3002

Module Not Found Errors

Ensure you've installed dependencies:

npm install

TypeScript Errors

Check your tsconfig.json and ensure:

  • experimentalDecorators: true
  • emitDecoratorMetadata: true

Hot Reload Not Working

Try restarting the dev server:

npm run dev

Project Types

Currently supports:

  • MCP Server - Standard MCP server with HTTP transport

Coming soon:

  • MCP Server with Auth
  • MCP Server with Database
  • MCP Server with File Storage

Examples

See the examples directory for complete working examples:

Requirements

  • Node.js >= 18.0.0
  • npm >= 9.0.0

CLI Commands

leanmcp create <name>      # Create new project
leanmcp add <service>      # Add new service to existing project
leanmcp --version          # Show version
leanmcp --help             # Show help

Command Details

create <project-name>

Creates a complete MCP server project with:

  • Entry point (main.ts)
  • Example service with Tool, Resource, and Prompt decorators
  • TypeScript configuration
  • Package.json with all dependencies
  • Development and build scripts

Interactive Prompts:

  • Asks if you want to install dependencies
  • If installed, asks if you want to start dev server
  • Runs commands in the project directory automatically

add <service-name>

Adds a new service to an existing project:

  • Must be run inside a LeanMCP project directory
  • Creates mcp/<service-name>.ts with template code
  • Automatically imports and registers in main.ts
  • Includes example Tool, Prompt, and Resource implementations
  • Uses schema validation with @SchemaConstraint decorators

🌟 Showcase Your MCP Server

Built something cool with LeanMCP? We'd love to feature it!

How to Get Featured

  1. Build an awesome MCP server using LeanMCP
  2. Share your project on GitHub
  3. Submit for showcase:
    • Open an issue: Request Showcase
    • Include:
      • Project name and description
      • GitHub repository link
      • What makes it unique
      • Screenshots or demo

License

MIT

Related Packages

Links