nieuwoudt/Espen-MCP-server-d6
If you are the rightful owner of Espen-MCP-server-d6 and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Espen D6 MCP Server is a multi-tenant Model Context Protocol server that integrates Espen.ai with the D6 School Information System, providing a standardized API for educational data.
get_schools
List authorized schools
get_learners
Get learners with academic data
get_learner_marks
Get marks for specific learner
get_staff
Get school staff information
get_parents
Get parent/guardian data
get_lookup_data
Get reference data (grades, languages, etc.)
get_system_health
Check D6 integration status
๐ง Espen D6 MCP Server
Production-ready MCP (Model Context Protocol) server integrating AI models with D6 School Information System
๐ DEPLOYMENT READY - Production Status
โ LIVE DATA: Currently serving 1,270 learners, 73 staff, and 1,523 parents from D6 production API
โ 8 MCP TOOLS: All tools functional and tested
โ VERCEL READY: Deploy in 5 minutes with one command
โ D6 INTEGRATION: Successfully connected to D6 test school (Integration 1694)
|
๐ฏ Overview
This MCP server provides AI models with direct access to D6 School Information System data, enabling natural language queries about students, staff, parents, and academic records. Built with the official Vercel MCP adapter for seamless cloud deployment.
Key Features
- ๐ซ Real D6 Data - Live production data from D6 test school
- โก 8 MCP Tools - Comprehensive school data access
- ๐ Production Security - Enterprise-grade D6 API authentication
- ๐ Rich Context - Student records, staff info, parent data
- ๐ Hybrid Mode - Automatic fallback between real and mock data
- ๐ Vercel Ready - One-command deployment with official MCP adapter
๐ Table of Contents
- Quick Start
- Architecture
- API Endpoints
- Configuration
- Development
- Testing
- Deployment
- Contributing
- Sandbox Mode
๐ Quick Start
๐ฏ 5-Minute Deployment (Recommended)
Deploy to Vercel with real D6 data:
# Clone and deploy
git clone https://github.com/espen-ai/espen-d6-mcp-server.git
cd espen-d6-mcp-server
npm install
vercel --prod
Then configure in your MCP client:
{
"mcpServers": {
"espen-d6": {
"url": "https://your-domain.vercel.app/api/mcp"
}
}
}
โก๏ธ
๐ง Local Development
Start MCP server locally:
# Clone the repository
git clone https://github.com/espen-ai/espen-d6-mcp-server.git
cd espen-d6-mcp-server
# Install dependencies
npm install
# Start with sandbox data (no D6 credentials needed)
D6_SANDBOX_MODE=true npm run mcp
# Or start with real D6 data
npm run mcp
Configure in your MCP client (Claude Desktop, etc.):
{
"mcpServers": {
"espen-d6": {
"command": "npm",
"args": ["run", "mcp"],
"cwd": "/path/to/espen-d6-mcp-server",
"env": {
"D6_SANDBOX_MODE": "true"
}
}
}
}
๐ Available MCP Tools (8 Total)
Tool | Description | Live Data Status |
---|---|---|
get_schools | School information | โ 1 D6 school |
get_learners | Student data | โ 1,270 students |
get_staff | Staff information | โ 73 staff members |
get_parents | Parent data | โ 1,523 parents |
get_learner_marks | Academic marks | ๐ Pending D6 activation |
get_lookup_data | Reference data | โ Genders, grades |
get_system_health | API health status | โ Live monitoring |
get_integration_info | Integration details | โ Real D6 setup |
Prerequisites
- Node.js 18+
- PostgreSQL (or Supabase account)
- Redis (optional, for caching)
- D6 School Information System access
Installation
# Copy environment template
cp env.example .env
# Configure your environment variables
# Edit .env with your Supabase, D6, and Redis credentials
# Run database migrations
npm run db:migrate
# Start development server
npm run dev
Environment Setup
Copy env.example
to .env
and configure:
# Supabase Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-supabase-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-supabase-service-role-key
# D6 API Configuration
D6_API_BASE_URL=https://your-school.d6.co.za/api
D6_API_USERNAME=your-d6-username
D6_API_PASSWORD=your-d6-password
# Server Configuration
PORT=3000
JWT_SECRET=your-super-secret-jwt-key
๐๏ธ Architecture
graph TB
A[EspenTutor/Teacher/Parent] --> B[MCP Server]
B --> C[Fastify API]
C --> D[Auth Middleware]
C --> E[Tenant Scoping]
C --> F[Rate Limiting]
C --> G[Context Builder]
G --> H[Cache Manager]
G --> I[D6 Client]
G --> J[Supabase Client]
I --> K[D6 School System]
J --> L[Supabase Database]
H --> M[Redis Cache]
subgraph "Data Layer"
L --> N[Learners]
L --> O[Marks]
L --> P[Attendance]
L --> Q[Discipline]
L --> R[Context Cache]
end
๐ API Endpoints
Context API
GET /context/:userId
Retrieves comprehensive context for a user (learner, teacher, or parent).
Parameters:
userId
- User identifierrole
- User role (learner/teacher/parent)forceRefresh
- Skip cache (optional)
Response:
{
"success": true,
"data": {
"id": "learner-123",
"firstName": "John",
"lastName": "Doe",
"academic": {
"overallAverage": 78.5,
"subjects": [...],
"trends": {...}
},
"attendance": {...},
"discipline": {...},
"insights": {...}
},
"cached": true,
"generatedAt": "2024-01-15T10:30:00Z"
}
Sync API
POST /sync/d6
Manually trigger D6 data synchronization.
GET /sync/status
Get synchronization status and logs.
Health Check
GET /health
Server health and status information.
โ๏ธ Configuration
Cache TTL Settings
# Context cache (5 minutes)
CACHE_TTL_CONTEXT=300
# Learner data (30 minutes)
CACHE_TTL_LEARNER_DATA=1800
# Marks data (15 minutes)
CACHE_TTL_MARKS=900
Sync Configuration
# Sync interval (15 minutes)
SYNC_INTERVAL_MINUTES=15
# Retry attempts for failed requests
SYNC_RETRY_ATTEMPTS=3
# Batch size for bulk operations
SYNC_BATCH_SIZE=100
๐ป Development
Scripts
# Development with hot reload
npm run dev
# Build for production
npm run build
# Run tests
npm run test
# Run tests with coverage
npm run test:coverage
# Lint code
npm run lint
# Format code
npm run format
# Type checking
npm run type-check
Project Structure
src/
โโโ api/ # API route handlers
โโโ services/ # Business logic services
โโโ middleware/ # Express middleware
โโโ db/ # Database client and migrations
โโโ utils/ # Utility functions
โโโ types/ # TypeScript type definitions
โโโ tests/ # Test files
๐งช Testing
Running Tests
# Unit tests
npm run test
# Integration tests
npm run test:integration
# Watch mode
npm run test:watch
# Coverage report
npm run test:coverage
Test Structure
- Unit Tests - Individual function testing
- Integration Tests - API endpoint testing
- E2E Tests - Full workflow testing
๐ Deployment
Vercel Deployment
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel
# Production deployment
vercel --prod
Environment Variables
Configure these in your deployment platform:
SUPABASE_URL
SUPABASE_SERVICE_ROLE_KEY
D6_API_BASE_URL
D6_API_USERNAME
D6_API_PASSWORD
JWT_SECRET
REDIS_URL
(optional)
Database Setup
- Create Supabase project
- Run the enhanced schema from
src/db/schema.sql
- Configure Row-Level Security policies
- Set up automated backups
๐ Performance
Benchmarks
- Context API: < 200ms (cached), < 500ms (uncached)
- D6 Sync: ~1000 records/minute
- Concurrent Users: 1000+ per school
- Cache Hit Rate: > 85%
Monitoring
- Response time tracking
- Error rate monitoring
- Cache performance metrics
- Database query optimization
๐ Security
Features
- JWT-based authentication
- Row-Level Security (RLS)
- Tenant data isolation
- Rate limiting
- Input validation
- SQL injection prevention
Best Practices
- Regular security audits
- Dependency updates
- Environment variable encryption
- API key rotation
๐ API Documentation
Full API documentation is available at /docs
when running the development server.
Authentication
# Get JWT token
curl -X POST /auth/login \\
-H "Content-Type: application/json" \\
-d '{"username":"user@school.com","password":"password"}'
# Use token in requests
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \\
/context/learner-123?role=learner
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Ensure all tests pass
- Submit a pull request
Code Standards
- ESLint configuration
- Prettier formatting
- TypeScript strict mode
- 100% test coverage for critical paths
๐ License
This project is licensed under the MIT License - see the file for details.
๐โโ๏ธ Support
- Documentation: Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
๐ญ Sandbox Mode
The Espen D6 MCP Server includes a comprehensive Sandbox Mode with realistic mock data, perfect for development, testing, and demos without requiring D6 API credentials or school authorizations.
Features
โ
Realistic South African School Data - Authentic names, languages, and educational structure
โ
Complete API Coverage - All endpoints work with mock data
โ
Instant Responses - No network delays or API rate limits
โ
Offline Development - Works without internet connection
โ
Consistent Testing - Predictable data for reliable tests
โ
No Credentials Required - Start developing immediately
Mock Data Available
- ๐ซ Schools: 3 mock schools with different API access levels
- ๐จโ๐ Learners: Diverse student data across multiple grades
- ๐จโ๐ซ Staff: Teachers and administrators with subjects
- ๐ช Parents: Parent contacts with relationships
- ๐ Marks: Academic performance data across subjects
- ๐ Lookups: Genders, grades, languages, ethnic groups
Quick Start with Sandbox
# Demo the mock data
npm run demo:sandbox
# Or see it in action
node scripts/demo-sandbox.js
Enabling Sandbox Mode
Method 1: Environment Variables
export NODE_ENV=development
export D6_SANDBOX_MODE=true
npm run dev
Method 2: Code Configuration
const d6Service = D6ApiServiceHybrid.getInstance({
baseUrl: 'https://integrate.d6plus.co.za/api/v2',
username: 'any', // Not used in sandbox mode
password: 'any', // Not used in sandbox mode
enableMockData: true,
useMockDataFirst: true, // Forces sandbox mode
});
Dynamic Mode Switching
// Switch to sandbox mode
d6Service.setSandboxMode(true);
// Switch back to production (if APIs available)
d6Service.setSandboxMode(false);
// Check current mode
const info = d6Service.getClientInfo();
console.log(`Current mode: ${info.mode}`); // 'sandbox', 'production', or 'hybrid'
Sample Mock Data
The sandbox includes realistic South African educational data:
Schools:
- Greenwood Primary School (Admin+ API)
- Riverside High School (Curriculum+ API)
- Sunnydale Academy (Finance+ API)
Learners:
- Amara Ngcobo (Grade 7, Zulu)
- Liam Van Der Merwe (Grade 8, Afrikaans)
- Kgothatso Molefe (Grade 9, Setswana)
Staff:
- Patricia Mthembu (Mathematics Teacher)
- David Williams (English Teacher)
API Response Format
All sandbox responses follow the same format as production D6 APIs:
// Learners endpoint
const learners = await d6Service.getLearners(1001);
// Returns: D6Learner[] with proper field mapping
// Marks endpoint
const marks = await d6Service.getMarks(2001);
// Returns: D6Mark[] with realistic academic data
// Health check shows sandbox status
const health = await d6Service.healthCheck();
// Returns: { status: 'degraded', mock_data_available: true, ... }
Perfect For
- ๐ Rapid Prototyping - Start building immediately
- ๐งช Testing - Consistent data for unit/integration tests
- ๐ Learning - Explore D6 API structure without credentials
- ๐ฏ Demos - Show functionality without real school data
- ๐ง Development - Build features before D6 integration approval
Production vs Sandbox
Feature | Production | Sandbox |
---|---|---|
Data Source | Real D6 APIs | Mock data service |
Network Required | โ Yes | โ No |
Credentials | โ Required | โ Optional |
Rate Limits | โ Yes | โ No |
School Authorization | โ Required | โ No |
Response Time | ~200-500ms | ~1-5ms |
Data Consistency | โ ๏ธ Changes | โ Consistent |
Hybrid Fallback
The service automatically falls back to sandbox mode when:
- D6 APIs are unavailable
- Network connectivity issues
- Authentication failures
- Rate limits exceeded
// Automatic fallback sequence:
// 1. Try D6 v2 API
// 2. Try D6 v1 API
// 3. Use mock data (if enabled)
// 4. Throw error (if mock disabled)
Built with โค๏ธ by the Espen.ai team