Skip to content

Latest commit

Β 

History

34 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

eWeLink MCP Server - Integrated Solution

A complete multitenant eWeLink MCP (Model Context Protocol) server with integrated frontend and backend in a single Node.js/TypeScript application.

πŸ—οΈ Architecture

This is a single integrated solution that combines:

  • Backend API - Node.js/TypeScript with Express
  • Frontend UI - Vanilla JavaScript with modern CSS (served by backend)
  • Database - SQLite with Prisma ORM
  • Authentication - JWT-based with role-based access control

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation & Setup

# Clone the repository
git clone https://github.com/big-mas/ewelinkMCP.git
cd ewelinkMCP/integrated-app

# Install dependencies
npm install

# Setup database and demo data
npm run setup

# Start the application
npm run dev

The application will be available at http://localhost:3000

πŸ” Demo Credentials

Global Admin

  • Email: admin@ewelinkMCP.local
  • Password: admin123
  • Access: Complete system administration

Tenant Admin (Demo Company)

  • Email: admin@demo.company.com
  • Password: demo123
  • Access: Tenant management and OAuth configuration

Tenant Admin (Acme Corporation)

  • Email: admin@acme.corp.com
  • Password: acme123
  • Access: Tenant management and OAuth configuration

πŸ“ Project Structure

integrated-app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app.ts                 # Main application entry point
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── index.html         # Frontend application
β”‚   β”œβ”€β”€ routes/                # API routes
β”‚   β”‚   β”œβ”€β”€ globalAdmin.ts     # Global admin endpoints
β”‚   β”‚   β”œβ”€β”€ tenantAdmin.ts     # Tenant admin endpoints
β”‚   β”‚   β”œβ”€β”€ oauth.ts           # OAuth integration
β”‚   β”‚   └── enhancedMcp.ts     # MCP endpoints
β”‚   β”œβ”€β”€ services/              # Business logic
β”‚   β”‚   β”œβ”€β”€ globalAdminService.ts
β”‚   β”‚   β”œβ”€β”€ tenantAdminService.ts
β”‚   β”‚   └── ewelinkService.ts
β”‚   β”œβ”€β”€ middleware/            # Express middleware
β”‚   β”‚   β”œβ”€β”€ auth.ts            # Authentication
β”‚   β”‚   β”œβ”€β”€ audit.ts           # Audit logging
β”‚   β”‚   └── validation.ts      # Request validation
β”‚   β”œβ”€β”€ utils/                 # Utilities
β”‚   β”‚   β”œβ”€β”€ encryption.ts      # Password hashing
β”‚   β”‚   └── config.ts          # Configuration
β”‚   └── scripts/               # Database scripts
β”‚       └── createCompleteDemoData.ts
β”œβ”€β”€ prisma/
β”‚   └── schema.prisma          # Database schema
β”œβ”€β”€ package.json               # Dependencies and scripts
β”œβ”€β”€ tsconfig.json              # TypeScript configuration
└── .env                       # Environment variables

🎯 Features

Multi-Role Authentication

  • Global Admin: System-wide administration
  • Tenant Admin: Tenant-specific management
  • Tenant User: Device control and MCP access

Professional UI

  • Modern responsive design
  • Role-based dashboards
  • Real-time data display
  • Professional styling with CSS Grid/Flexbox

OAuth Integration

  • Unique callback URLs per tenant
  • eWeLink OAuth app configuration
  • Secure credential management

MCP Support

  • Model Context Protocol 2025-06-18 compliance
  • Unique endpoints per user per tenant
  • AI assistant integration ready

Security

  • JWT authentication
  • Password hashing with bcrypt
  • Role-based access control
  • Audit logging
  • CORS protection
  • Helmet security headers

πŸ› οΈ Development

Available Scripts

# Development with hot reload
npm run dev

# Build for production
npm run build

# Start production server
npm start

# Run tests
npm test

# Database operations
npm run prisma:generate    # Generate Prisma client
npm run prisma:migrate     # Run migrations
npm run prisma:studio      # Open Prisma Studio

# Setup with demo data
npm run setup              # Complete setup with demo data
npm run seed               # Create demo data only

Environment Variables

Create a .env file:

DATABASE_URL="file:./prisma/dev.db"
JWT_SECRET="your-super-secret-jwt-key-here"
FRONTEND_URL="http://localhost:3000"
EWELINK_CLIENT_ID="your-ewelink-client-id"
EWELINK_CLIENT_SECRET="your-ewelink-client-secret"

🌐 Deployment

Production Build

# Build the application
npm run build

# Start production server
NODE_ENV=production npm start

Docker Deployment (Optional)

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]

πŸ“š API Documentation

Authentication Endpoints

  • POST /api/global-admin/login - Global admin login
  • POST /api/tenant-admin/login - Tenant admin login

Global Admin Endpoints

  • GET /api/global-admin/tenants - List all tenants
  • POST /api/global-admin/tenants - Create tenant
  • PUT /api/global-admin/tenants/:id/pause - Pause tenant
  • PUT /api/global-admin/tenants/:id/resume - Resume tenant
  • GET /api/global-admin/users - List all users

Tenant Admin Endpoints

  • GET /api/tenant-admin/users - List tenant users
  • POST /api/tenant-admin/oauth-config - Save OAuth configuration
  • POST /api/tenant-admin/oauth-test - Test OAuth connection

MCP Endpoints

  • GET /api/enhanced-mcp/discover - Discover user's MCP endpoint
  • POST /mcp/:tenantId/:userId - User-specific MCP endpoint

πŸ”§ Configuration

eWeLink Integration

  1. Create an OAuth app at eWeLink Developer Console
  2. Use the tenant-specific callback URL provided in the admin interface
  3. Configure Client ID and Client Secret in the tenant admin dashboard

MCP Integration

Each user gets a unique MCP endpoint:

https://your-domain.com/mcp/{tenantId}/{userId}

Use this URL in AI assistants like Claude, ChatGPT, or custom applications.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

MIT License - see LICENSE file for details

πŸ†˜ Support

For issues and questions:

  • Create an issue on GitHub
  • Check the documentation
  • Review the demo credentials and setup instructions

Built with ❀️ using Node.js, TypeScript, and modern web technologies

About

eWeLink MCP Server - TypeScript implementation for Claude integration with eWeLink smart home devices

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages