# π SmartLead MCP Server - Project Structure
## ποΈ **Root Directory Structure**
```
smartlead-mcp-server/
βββ π README.md # Main project documentation
βββ π INSTALLATION.md # Installation guide
βββ π CHANGELOG.md # Version history and changes
βββ π SECURITY.md # Security guidelines and policies
βββ π LICENSE # MIT license
βββ π package.json # NPM package configuration
βββ π tsconfig.json # TypeScript configuration
βββ π biome.json # Biome linter/formatter config
βββ π .eslintrc.json # ESLint configuration (legacy)
βββ π .env.example # Environment variables template
βββ π mcp-settings-example.json # MCP client configuration example
βββ π src/ # Source code directory
βββ π scripts/ # Build and utility scripts
βββ π .vscode/ # VS Code workspace settings
βββ π .cursor/ # Cursor IDE rules and settings
βββ π dist/ # Compiled JavaScript output
βββ π node_modules/ # Dependencies (auto-generated)
```
---
## π― **Source Code Architecture (`src/`)**
### **π Core Files**
```
src/
βββ π index.ts # Main entry point & CLI router
βββ π server.ts # MCP server implementation
βββ π client.ts # Legacy SmartLead API client
βββ π installer.tsx # Beautiful React Ink installer
βββ π types.ts # Global TypeScript types & Zod schemas
```
### **π Client Architecture (`src/client/`)**
```
src/client/
βββ π index.ts # Modern SmartLead client (main)
βββ π base.ts # Base client with HTTP handling
```
### **π API Modules (`src/modules/`)**
```
src/modules/
βββ π analytics/client.ts # Analytics & reporting API
βββ π campaigns/client.ts # Campaign management API
βββ π client-management/client.ts # Team & client management API
βββ π email-accounts/client.ts # Email account management API
βββ π leads/client.ts # Lead & prospect management API
βββ π smart-delivery/client.ts # Deliverability & placement API
βββ π smart-senders/client.ts # Domain & sender management API
βββ π statistics/client.ts # Statistics & metrics API
βββ π webhooks/client.ts # Webhook management API
```
### **π MCP Tools (`src/tools/`)**
```
src/tools/
βββ π index.ts # Tool registration exports
βββ π analytics.ts # Analytics MCP tools (18 tools)
βββ π campaigns.ts # Campaign MCP tools (14 tools)
βββ π client-management.ts # Client management MCP tools (8 tools)
βββ π email-accounts.ts # Email account MCP tools (15 tools)
βββ π leads.ts # Lead management MCP tools (17 tools)
βββ π smart-delivery.ts # Smart delivery MCP tools (11 tools)
βββ π smart-senders.ts # Smart senders MCP tools (12 tools)
βββ π statistics.ts # Statistics MCP tools (18 tools)
βββ π webhooks.ts # Webhook MCP tools (9 tools)
```
### **π Type Definitions (`src/types/`)**
```
src/types/
βββ π config.ts # MCP configuration types
```
---
## π§ **Configuration Files**
### **π TypeScript Configuration (`tsconfig.json`)**
- **Target**: ES2022 with modern features
- **Module**: ESNext with bundler resolution
- **Strict**: Full TypeScript strict mode enabled
- **Output**: Compiled to `dist/` directory
- **JSX**: React JSX for installer components
### **π Package Configuration (`package.json`)**
- **Name**: `smartlead-mcp-by-leadmagic`
- **Version**: 1.6.2
- **Type**: ESM module
- **Engines**: Node.js >=20.0.0
- **Dependencies**: MCP SDK, React Ink, Axios, Zod
- **Scripts**: Build, lint, format, test, publish
### **π Biome Configuration (`biome.json`)**
- **Linting**: TypeScript-aware with strict rules
- **Formatting**: Consistent code style
- **Imports**: Organized and sorted
- **Rules**: Production-ready standards
---
## π **Build System**
### **π Scripts Directory (`scripts/`)**
```
scripts/
βββ π add-mcp-annotations.ts # MCP tool annotation utility
```
### **π Build Output (`dist/`)**
```
dist/
βββ π src/ # Compiled TypeScript
βββ π scripts/ # Compiled utility scripts
βββ π *.js.map # Source maps for debugging
```
### **Build Process**
1. **Clean**: Remove old build artifacts
2. **Compile**: TypeScript β JavaScript (ESM)
3. **Post-build**: Set executable permissions
4. **Package**: Create NPM package (.tgz)
---
## π¨ **Development Environment**
### **π VS Code Settings (`.vscode/`)**
```
.vscode/
βββ π settings.json # Workspace settings
βββ π extensions.json # Recommended extensions
```
### **π Cursor Rules (`.cursor/`)**
```
.cursor/
βββ π rules/
βββ π project-overview.mdc # Project structure guide
βββ π api-patterns.mdc # API development patterns
βββ π mcp-tools.mdc # MCP tool development guide
βββ π typescript-standards.mdc # TypeScript coding standards
```
---
## π **Code Metrics**
### **π File Count by Category**
- **Core Files**: 5 files
- **API Modules**: 9 files (116+ tools total)
- **MCP Tools**: 10 files
- **Type Definitions**: 2 files
- **Configuration**: 8 files
- **Documentation**: 5 files
### **π Lines of Code (Estimated)**
- **TypeScript Source**: ~15,000 lines
- **Configuration**: ~500 lines
- **Documentation**: ~2,000 lines
- **Total Project**: ~17,500 lines
---
## π **Dependency Architecture**
### **π¦ Core Dependencies**
- **@modelcontextprotocol/sdk**: MCP protocol implementation
- **axios**: HTTP client for SmartLead API
- **zod**: Runtime type validation
- **dotenv**: Environment variable management
### **π¨ UI Dependencies**
- **react**: React framework for installer
- **ink**: Terminal UI components
- **ink-***: Specialized terminal components
### **π οΈ Development Dependencies**
- **typescript**: TypeScript compiler
- **@biomejs/biome**: Linting and formatting
- **@types/***: TypeScript type definitions
---
## π¦ **Entry Points**
### **π Main Entry Point (`src/index.ts`)**
- **CLI Router**: Handles install vs server mode
- **Environment Setup**: Loads configuration
- **Error Handling**: Graceful startup/shutdown
### **π MCP Server (`src/server.ts`)**
- **Tool Registration**: Registers all 116+ tools
- **Client Management**: Handles MCP connections
- **Error Handling**: Production-ready error responses
### **π Installer (`src/installer.tsx`)**
- **React Ink UI**: Beautiful terminal interface
- **Auto-detection**: Finds MCP clients automatically
- **Configuration**: Zero-config setup for all clients
---
## π **Security Architecture**
### **π‘οΈ API Security**
- **Environment Variables**: No hardcoded secrets
- **Input Validation**: Zod schemas for all inputs
- **Error Sanitization**: No sensitive data in logs
- **Rate Limiting**: Respects SmartLead API limits
### **π Configuration Security**
- **File Permissions**: Secure config file handling
- **API Key Validation**: Real-time verification
- **HTTPS Only**: Encrypted API communications
---
## π **Documentation Structure**
### **π User Documentation**
- **README.md**: Marketing-optimized overview
- **INSTALLATION.md**: Detailed setup guide
- **SECURITY.md**: Security best practices
### **π Developer Documentation**
- **CHANGELOG.md**: Version history
- **PROJECT_STRUCTURE.md**: This file
- **Cursor Rules**: IDE-specific guidance
---
## π― **Best Practices Implemented**
### **ποΈ Architecture Patterns**
- **Modular Design**: Separated concerns by functionality
- **Type Safety**: Comprehensive TypeScript coverage
- **Error Handling**: Consistent error patterns
- **Configuration**: Environment-based setup
### **π¦ Package Management**
- **Semantic Versioning**: Clear version strategy
- **Dependency Pinning**: Stable dependency versions
- **Build Optimization**: Efficient compilation
- **Distribution**: NPM package ready
### **π§ Development Workflow**
- **Linting**: Automated code quality checks
- **Formatting**: Consistent code style
- **Type Checking**: Zero TypeScript errors
- **Testing**: Validation scripts