serialdev-mcp
v1.2.8
Published
MCP server for SerialDev prompt session management
Maintainers
Readme
MCP System
A Model Context Protocol (MCP) system built with Next.js 14, Vercel Functions, and Firebase, featuring Google authentication, API key management, and lease management.
Features
- Google Authentication: Secure user login with Google OAuth
- API Key Authentication: Secure API key generation and management
- Lease Management: Project-based lease acquisition and release
- Prompt Sessions: Track and manage AI prompt sessions
- Web Dashboard: Modern UI for managing API keys and projects
- Automated Cleanup: Cron jobs for expired lease and session cleanup
- Firebase Integration: Firestore for data persistence and user authentication
Architecture
``` /app /api /mcp/v1 # MCP API endpoints /auth # API key management /cron # Cleanup jobs /page.tsx # Dashboard (protected) /components /auth # Authentication components /dashboard # Dashboard UI components /lib /domain # Business logic services /middleware # Authentication middleware firebase-admin.ts # Firebase Admin SDK firebase-client.ts # Firebase Client SDK auth-context.tsx # Authentication context api-key.ts # API key utilities ```
API Endpoints
MCP Endpoints (require API key authentication)
POST /api/mcp/v1/create-prompt-session- Create prompt session and journal promptPOST /api/mcp/v1/complete-prompt-session- Complete session and optionally journal responsePOST /api/mcp/v1/abort-prompt-session- Abort session and journal abort event
Management Endpoints (require user authentication)
GET/POST /api/auth/api-keys- Manage API keysPATCH/DELETE /api/auth/api-keys/[keyId]- Update/delete API keyGET/POST /api/auth/projects- Manage projects
Cron Jobs
/api/cron/sweep-expired- Clean up expired leases and sessions (every 2 minutes)/api/cron/cleanup-journal- Clean up old journal entries (daily at 2 AM)
Setup
1. Firebase Setup
Create Firebase Project
- Go to Firebase Console
- Create a new project
- Enable Firestore Database
- Enable Authentication with Google provider
Get Firebase Configuration
- Go to Project Settings → General
- Copy the Firebase config object (for client-side)
- Go to Project Settings → Service Accounts
- Generate new private key (for server-side)
Configure Google Authentication
- Go to Authentication → Sign-in method
- Enable Google provider
- Add your domain to authorized domains
2. Environment Variables
```bash cp .env.example .env.local
Fill in all Firebase credentials and secrets
```
Required Environment Variables:
FIREBASE_PROJECT_ID- Your Firebase project IDFIREBASE_CLIENT_EMAIL- Service account emailFIREBASE_PRIVATE_KEY- Service account private keyNEXT_PUBLIC_FIREBASE_API_KEY- Firebase web API keyNEXT_PUBLIC_FIREBASE_AUTH_DOMAIN- Firebase auth domainNEXT_PUBLIC_FIREBASE_PROJECT_ID- Firebase project ID (public)NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET- Firebase storage bucketNEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID- Firebase messaging sender IDNEXT_PUBLIC_FIREBASE_APP_ID- Firebase app IDAPI_KEY_SALT- Random string for API key hashingCRON_SECRET- Secret for cron job authentication
3. Install Dependencies
```bash npm install ```
4. Development
```bash npm run dev ```
Visit http://localhost:3000 and sign in with Google to access the dashboard.
5. Deploy to Vercel
- Connect your repository to Vercel
- Add all environment variables in Vercel dashboard
- Deploy
Usage
Accessing the Dashboard
- Visit your deployed URL or
http://localhost:3000 - Click "Continue with Google" to sign in
- Access the dashboard to manage API keys and projects
Creating API Keys
- In the dashboard, go to the API Keys section
- Click "Create API Key"
- Enter a name for your key
- Save the generated key (shown only once)
Creating Projects
- In the dashboard, go to the Projects section
- Click "Create Project"
- Enter project name and description
- Configure lease policies as needed
Using the API
```bash
Acquire a lease
curl -X POST https://your-domain.com/api/mcp/v1/acquire-lease
-H "X-API-Key: sk_live_your_api_key"
-H "Content-Type: application/json"
-d '{"projectId": "your-project-id"}'
Create a prompt session (projectId optional when key is scoped to exactly one project)
curl -X POST https://your-domain.com/api/mcp/v1/create-prompt-session
-H "X-API-Key: sk_live_your_api_key"
-H "Content-Type: application/json"
-d '{"promptText": "Hello, world!"}'
```
Data Models
Users
- Google OAuth profile information
- API keys and projects ownership
Projects
- Lease policies (TTL, grace periods)
- Status tracking
- User ownership
API Keys
- Secure hash storage
- Scope and project restrictions
- Usage tracking
- User ownership
Leases
- Holder information
- Expiration management
- Status transitions
Prompt Sessions
- Session lifecycle tracking
- Actor attribution
- LLM metadata
Security
- Google OAuth for user authentication
- API keys are hashed using SHA-256
- User-based data isolation
- Cron endpoints protected with bearer tokens
- All MCP endpoints require valid API key authentication
- Client-side route protection
Testing
Setup Sample Data
```bash npm run setup-sample-data ```
Test API Endpoints
```bash npm run test-api ```
License
MIT
