Skip to main content

LeanMCP SDK

A TypeScript SDK for building Model Context Protocol (MCP) servers with decorators, authentication, and production-ready features.

Overview

LeanMCP SDK provides a modern, decorator-based approach to building MCP servers. It handles the complexity of the MCP protocol while letting you focus on building great tools.

Key Features

Type-Safe Decorators

Use @Tool, @Prompt, @Resource decorators with full TypeScript support

Built-in Authentication

Token-based auth with support for Firebase, Supabase, and custom providers

Input Validation

Automatic validation using JSON Schema and AJV

Production Ready

HTTP server, session management, error handling, and logging out of the box

Quick Example

import { Tool, SchemaConstraint } from "@leanmcp/core";

class AnalyzeSentimentInput {
  @SchemaConstraint({
    description: 'Text to analyze',
    minLength: 1
  })
  text!: string;
}

export class SentimentService {
  @Tool({ 
    description: 'Analyze sentiment of text',
    inputClass: AnalyzeSentimentInput
  })
  async analyzeSentiment(input: AnalyzeSentimentInput) {
    return {
      sentiment: 'positive',
      score: 0.8
    };
  }
}

Packages

The SDK is organized into several packages:

Installation

Install the core package to get started:
npm install @leanmcp/core
Or use the CLI to create a new project:
npx @leanmcp/cli create my-mcp-server

Next Steps

Resources