# Leanmcp Builder

Build MCP servers using the Leanmcp SDK with decorator-based TypeScript.

- Repository: https://github.com/Leanmcp/gateway-skills (2122 stars)
- Category: AI and agents
- License: MIT
- Last updated: 2026-10-07
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add Leanmcp/gateway-skills --skill leanmcp-builder -g -a claude-code -y`
Codex: `npx skills add Leanmcp/gateway-skills --skill leanmcp-builder -g -a codex -y`
Cursor: `npx skills add Leanmcp/gateway-skills --skill leanmcp-builder -g -a cursor -y`
Gemini CLI: `npx skills add Leanmcp/gateway-skills --skill leanmcp-builder -g -a gemini-cli -y`

## Description

Build MCP servers using the Leanmcp SDK with decorator-based TypeScript. Use this skill when users ask for "leanmcp", "MCP with decorators", "MCP with authentication", "MCP with elicitation", "MCP with environment injection", or want a simpler, more elegant way to build MCP servers. Leanmcp provides automatic schema generation, dependency injection, authentication, and user input collection.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Leanmcp Builder Skill

This skill guides you in building MCP servers using the Leanmcp SDK - a decorator-based TypeScript framework for elegant MCP development.

## When to Use This Skill

- User asks for "leanmcp server"
- User wants "MCP with decorators"
- User needs "authenticated MCP server"
- User wants "simpler MCP development"
- User mentions "@leanmcp/core"
- User needs "user input collection" or "elicitation"
- User wants "environment injection" for multi-tenant secrets

## Leanmcp vs Vanilla MCP

| Feature | Vanilla MCP | Leanmcp SDK |
|---------|-------------|-------------|
| Tool definition | Manual schema | `@Tool` decorator with auto-schema |
| Input validation | Manual | Automatic with `@SchemaConstraint` |
| Service discovery | Manual registration | Auto-discovery from `./mcp` directory |
| Authentication | DIY | `@Authenticated` decorator |
| User input | Not built-in | `@Elicitation` decorator |
| Secrets | DIY | `@RequireEnv` + `getEnv()` |

## Core Packages

```bash
# Minimal setup
npm install @leanmcp/core

# With authentication
npm install @leanmcp/auth

# With user input forms
npm install @leanmcp/elicitation

# With user secrets
npm install @leanmcp/env-injection

# CLI (global or dev)
npm install -g @leanmcp/cli
```

## Project Structure

```
my-leanmcp-server/
├── main.ts                 # Entry point (minimal)
├── mcp/                    # Auto-discovered services
│   ├── example/
│   │   └── index.ts        # Exports ExampleService
│   └── myservice/
│       └── index.ts        # Exports MyService
├── package.json
├── tsconfig.json
└── .env
```

## Required package.json

The rest: https://github.com/Leanmcp/gateway-skills/blob/HEAD/skills/leanmcp-builder/SKILL.md
