Overview
Theleanmcp add command creates a new service in your MCP project with boilerplate code for tools, prompts, and resources.
Basic Usage
What Gets Created
When you runleanmcp add weather, the CLI:
- Creates
mcp/weather/index.tswith boilerplate - Includes example
@Tool,@Prompt, and@Resourcedecorators - Adds schema validation with
@SchemaConstraint - Automatically registers in your server (via auto-discovery)
Generated Service Template
mcp/weather/index.ts
Terminal Output
Auto-Discovery
LeanMCP automatically discovers services in themcp/ directory. No manual registration needed!
How it works:
main.ts
Real-World Example
Let’s create a weather service:Multiple Services
Add as many services as you need:Service Organization
For complex services, organize with multiple files:mcp/weather/index.ts
Error Handling
Not a LeanMCP Project
Service Already Exists
Best Practices
1. Name Services Descriptively
2. Use Clear Tool Names
3. Add Comprehensive Schema Validation
4. Handle Errors Gracefully
5. Document Your Tools
Next Steps
Dev Commands
Start developing with hot-reload
Tools
Learn about @Tool decorator
Prompts
Create reusable prompts
Resources
Expose data with resources