Installation
LeanMCP is a modular TypeScript SDK for building Model Context Protocol servers. This guide covers installation for all package managers and system requirements.System Requirements
Node.js
Node.js 20.x or higher required
TypeScript
TypeScript 5.0+ recommended for best experience
Package Manager
npm, yarn, or pnpm supported
Operating System
Windows, macOS, or Linux
LeanMCP uses TypeScript decorators and
reflect-metadata. Make sure your tsconfig.json has experimentalDecorators and emitDecoratorMetadata enabled.Quick Installation
The fastest way to get started is using the LeanMCP CLI to scaffold a new project:Package Overview
LeanMCP is split into modular packages. Install only what you need:Core Packages (Required)
@leanmcp/core - Core Runtime
@leanmcp/core - Core Runtime
Version: 0.4.7The core package provides MCP server runtime, decorators, and schema validation.Includes:
@Tool,@Prompt,@Resourcedecorators@SchemaConstraint,@Optionalschema decoratorscreateHTTPServer()andMCPServerclasses- Auto-discovery of services
- Built-in validation with AJV
@modelcontextprotocol/sdk- Official MCP SDKreflect-metadata- Decorator metadata supportajv- JSON Schema validationdotenv- Environment variables
@leanmcp/cli - Command Line Interface
@leanmcp/cli - Command Line Interface
Version: 0.5.12CLI tool for scaffolding projects, adding services, and deployment.Commands:
leanmcp create <name>- Create new projectleanmcp add <service>- Add new serviceleanmcp deploy- Deploy to production
npx @leanmcp/cli without global installation.Optional Packages
@leanmcp/auth - Authentication
@leanmcp/auth - Authentication
Authentication and access control for MCP servers.Use when:
- You need user authentication
- Multi-user MCP servers
- Permission-based access control
- AWS Cognito
- Auth0
- Clerk
- Custom JWT providers
@leanmcp/elicitation - User Input
@leanmcp/elicitation - User Input
Structured user input during tool execution.Use when:
- Tools need guided user input
- Multi-step workflows
- Interactive forms during execution
@leanmcp/env-injection - Environment Injection
@leanmcp/env-injection - Environment Injection
Request-scoped environment and secret injection.Use when:
- Multi-tenant secrets management
- Per-request configuration
- Dynamic environment variables
@leanmcp/ui - UI Components
@leanmcp/ui - UI Components
UI components for building MCP Apps (advanced).Use when:
- Building interactive MCP experiences
- Custom UI components for tools
Manual Setup
If you prefer to set up a project manually without the CLI:Verify Installation
Verify your installation is working:Environment Configuration
Create a.env file for environment variables:
.env
Troubleshooting
Decorator errors
Decorator errors
If you see errors about decorators:Error:
Experimental support for decorators is a feature that is subject to changeSolution: Ensure your tsconfig.json has:Module resolution errors
Module resolution errors
If you see errors about module imports:Error:
Cannot find module '@leanmcp/core'Solutions:- Ensure
package.jsonhas"type": "module" - Check that dependencies are installed:
npm install - Clear node_modules and reinstall:
rm -rf node_modules package-lock.json && npm install
Port already in use
Port already in use
If port 8080 is already in use:Error:
EADDRINUSE: address already in useSolutions:- Change the port in
main.ts:port: 3000 - Or set
PORTenvironment variable:PORT=3000 npm start - Or kill the process using the port:
lsof -ti:8080 | xargs kill
Next Steps
Quick Start
Create your first MCP server
Core Concepts
Learn about Tools, Prompts, and Resources
API Reference
Explore the complete API
Examples
See example implementations
Need help? Join our Discord community or open an issue on GitHub.