> ## 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.

# Introduction

> Build production-ready MCP servers with LeanMCP

# 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.

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

| Problem           | LeanMCP Solution                                             |
| ----------------- | ------------------------------------------------------------ |
| **Auth**          | Integrate with Auth0, Supabase, Cognito, Firebase, or custom |
| **Multi-tenancy** | Per-user API keys and permissions                            |
| **Elicitation**   | Handle user input during tool execution                      |
| **Audit**         | Logging, 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.

<Note>
  LeanMCP abstracts protocol complexity so you focus on your business logic, not MCP internals.
</Note>

## Installation

<Tabs>
  <Tab title="One-Line Install (Mac/Linux)">
    ```bash theme={null}
    curl -fsSL https://raw.githubusercontent.com/Leanmcp-Community/sdk-examples/refs/heads/main/cli/install.sh | bash
    ```
  </Tab>

  <Tab title="npm">
    ```bash theme={null}
    npm i -g @leanmcp/cli
    ```
  </Tab>

  <Tab title="npx (no install)">
    ```bash theme={null}
    npx @leanmcp/cli create my-mcp-server
    ```
  </Tab>
</Tabs>

Then create your project:

```bash theme={null}
leanmcp create my-mcp-server
```

<Tip>
  The CLI provides an interactive setup that installs dependencies and starts the dev server automatically.
</Tip>

## 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

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

```bash theme={null}
npx @modelcontextprotocol/inspector http://localhost:3001/mcp
```

## Deployment

Deploy anywhere Node.js runs. Or use LeanMCP's deployment platform:

```bash theme={null}
leanmcp deploy
```

You're not locked in — deploy to AWS, GCP, Vercel, Railway, or any platform.

## Next Steps

<CardGroup cols={2}>
  <Card title="Quick Start" icon="rocket" href="/quickstart">
    Build your first MCP in 5 minutes
  </Card>

  <Card title="Tools" icon="wrench" href="/core-concepts/tools">
    Create tools AI can execute
  </Card>

  <Card title="Resources" icon="database" href="/core-concepts/resources">
    Expose data to AI agents
  </Card>

  <Card title="Prompts" icon="message" href="/core-concepts/prompts">
    Template prompts for AI
  </Card>

  <Card title="Auth" icon="lock" href="/building/auth">
    Secure your MCP server
  </Card>

  <Card title="CLI Reference" icon="terminal" href="/cli/installation">
    CLI commands and options
  </Card>
</CardGroup>

## Support

LeanMCP is MIT-licensed open source.

* **GitHub**: [github.com/Leanmcp-Community](https://github.com/Leanmcp-Community)
* **npm**: [@leanmcp/core](https://www.npmjs.com/package/@leanmcp/core)
