Skip to main content

LeanMCP

LeanMCP is a framework for building production-ready MCP servers. It uses TypeScript decorators, service-based architecture, and schema validation to create AI-ready tool interfaces. Built on top of the official @modelcontextprotocol/sdk, LeanMCP uses Express for HTTP transport and implements the Streamable HTTP specification. It provides session management, tool registration, and schema validation out of the box.
import { Tool, SchemaConstraint } from "@leanmcp/core";

class GenerateInput {
  @SchemaConstraint({ description: "Text prompt for image generation" })
  prompt!: string;
}

export class ImageService {
  @Tool({ description: "Generate an image", inputClass: GenerateInput })
  async generate(input: GenerateInput) {
    const image = await gemini.generateImage(input.prompt);
    return { url: image.url };
  }
}

Why LeanMCP?

A basic MCP connects tools to AI agents. But production means solving real problems:
ProblemLeanMCP Solution
AuthIntegrate with Auth0, Supabase, Cognito, Firebase, or custom
Multi-tenancyPer-user API keys and permissions
ElicitationHandle user input during tool execution
AuditLogging, monitoring, production observability

Core Principles

  • Developer Experience first — decorators, auto-discovery
  • Convention over configuration — sensible defaults
  • Type-safe by default — TypeScript + schema validation
  • Production-ready — HTTP transport, session management

Building MCPs is Easy. Production MCPs are Hard.

Building a basic MCP that connects tools to an AI agent is straightforward — define your tools, add descriptions, done. But the make-or-break features that separate a toy from production are much harder:
  • Authentication — OAuth integration, token validation, scope management
  • Elicitation — User input collection with validation
  • Payments — Stripe integration, subscription checks, usage-based billing
  • MCP Apps & UI — Rendering UI components inside ChatGPT, Claude, and other clients
These features require deep MCP protocol knowledge and weeks of implementation. LeanMCP handles them out of the box with @leanmcp/auth, @leanmcp/elicitation, and built-in UI support.

Protocol Upgrades Without Pain

The MCP protocol evolves. When updates come — new capabilities, schema changes, security patches — you’d normally rewrite significant code. With LeanMCP, you update one dependency. Your tools, auth, and elicitation continue working.
LeanMCP abstracts protocol complexity so you focus on your business logic, not MCP internals.

Installation

curl -fsSL https://raw.githubusercontent.com/Leanmcp-Community/sdk-examples/refs/heads/main/cli/install.sh | bash
Then create your project:
leanmcp create my-mcp-server
The CLI provides an interactive setup that installs dependencies and starts the dev server automatically.

Project Structure

my-mcp-server/
├── main.ts              # Entry point with HTTP server
├── package.json
├── tsconfig.json
└── mcp/                 # Services directory (auto-discovered)
    └── example/
        └── index.ts     # Your tools, resources, prompts

Start the Server

npm run dev
Server running on http://localhost:3001
MCP endpoint: http://localhost:3001/mcp
Health check: http://localhost:3001/health

Test with MCP Inspector

npx @modelcontextprotocol/inspector http://localhost:3001/mcp

Deployment

Deploy anywhere Node.js runs. Or use LeanMCP’s deployment platform:
leanmcp deploy
You’re not locked in — deploy to AWS, GCP, Vercel, Railway, or any platform.

Next Steps

Support

LeanMCP is MIT-licensed open source.