> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leanmcp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LeanMCP SDK

> Build production-ready MCP servers with TypeScript decorators

# 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

<CardGroup cols={2}>
  <Card title="Type-Safe Decorators" icon="code">
    Use `@Tool`, `@Prompt`, `@Resource` decorators with full TypeScript support
  </Card>

  <Card title="Built-in Authentication" icon="lock">
    Token-based auth with support for Firebase, Supabase, and custom providers
  </Card>

  <Card title="Input Validation" icon="shield-check">
    Automatic validation using JSON Schema and AJV
  </Card>

  <Card title="Production Ready" icon="rocket">
    HTTP server, session management, error handling, and logging out of the box
  </Card>
</CardGroup>

## Quick Example

```typescript theme={null}
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:

* **[@leanmcp/core](/sdk/core)** - Core decorators and server functionality
* **[@leanmcp/auth](/sdk/auth)** - Authentication decorators and providers
* **[@leanmcp/env-injection](/sdk/env-injection)** - Request-scoped user secrets injection
* **[@leanmcp/elicitation](/sdk/elicitation)** - Structured user input collection
* **[@leanmcp/ui](/sdk/ui)** - MCP-native React components and hooks for MCP Apps
* **[@leanmcp/cli](/sdk/cli)** - Command-line tool for project scaffolding
* **[@leanmcp/utils](/sdk/utils)** - Utility functions and helpers

## Installation

Install the core package to get started:

```bash theme={null}
npm install @leanmcp/core
```

Or use the CLI to create a new project:

```bash theme={null}
npx @leanmcp/cli create my-mcp-server
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Core Package" icon="cube" href="/sdk/core">
    Learn about decorators and schema definition
  </Card>

  <Card title="Authentication" icon="key" href="/sdk/auth">
    Add authentication to your MCP server
  </Card>

  <Card title="CLI Tool" icon="terminal" href="/sdk/cli">
    Scaffold projects with the CLI
  </Card>

  <Card title="Examples" icon="code-branch" href="/sdk/examples">
    View complete examples
  </Card>
</CardGroup>

## Resources

* [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
* [MCP Specification](https://modelcontextprotocol.io/specification/2025-11-25)
* [NPM Package](https://www.npmjs.com/package/@leanmcp/core)
