---
description: Use this rule when we need to commit, push and deploy changes
globs:
alwaysApply: false
---
# MCP Task Manager Deployment Rules
## Project Context
- **Project Type**: MCP (Model Context Protocol) Server
- **Backend**: Directus API integration
- **Deployment**: Railway.app at https://mcptaskedwork-production.up.railway.app/mcp-rpc
- **Config**: railway.json (config-as-code)
## Deployment Process
### Automatic Deployment Triggers
- Push to main branch triggers Railway deployment
- Railway uses railway.json for build/deploy configuration
- Build command: `npm run build`
- Start command: `node dist/index.js`
### Pre-Deployment Checklist
1. **TypeScript Compilation**: Ensure `npm run build` succeeds
2. **Dependencies**: Verify all packages in package.json are installed
3. **Environment**: Railway auto-detects Node.js environment
4. **Health Check**: Server responds at /health endpoint
### Post-Deployment Verification
1. **MCP Server**: Test tools are accessible via Railway URL
2. **Directus Connection**: Verify API integration works
3. **Multi-User Support**: Ensure token-based auth functions
4. **Working Directory Detection**: Test project context detection
## Development Workflow
### Code Changes ā Automated Deployment
1. **Local Development**:
- Make changes to src/ files
- Test with `npm run dev`
- Run `npm run build` to verify compilation
2. **Pre-Deployment Validation**:
- Verify TypeScript compilation succeeds
- Check all dependencies are installed
- Ensure no linting errors
- Validate MCP tool functionality
3. **User Confirmation & Auto-Deploy**:
- **ALWAYS** ask user for deployment confirmation after code changes
- Present summary of changes made
- If user confirms deployment, automatically execute git workflow:
```bash
git add .
git commit -m "Auto-deploy: [brief description of changes]"
git push origin main
```
- **NEVER** deploy without explicit user confirmation
- Railway automatically triggers deployment on push
## CRITICAL DEPLOYMENT AUTOMATION RULES
### Auto-Deployment Workflow (MANDATORY)
When any code changes are made that require deployment:
1. **Change Detection**: After modifying any files in src/, docs/, or configuration
2. **Pre-Flight Checks**:
- Run `npm run build` to verify compilation
- Check for linting errors
- Validate all dependencies are installed
3. **User Confirmation Dialog**:
- Present summary of all changes made
- List affected files and functionality
- Ask explicit confirmation: "Deploy these changes to Railway?"
- **WAIT** for user confirmation before proceeding
4. **Automatic Git Workflow** (only after user confirms):
```bash
git add .
git commit -m "Auto-deploy: [brief description of changes]"
git push origin main
```
5. **Railway Auto-Deployment**:
- Railway detects push to main branch
- Builds using railway.json configuration
- Deploys to https://mcptaskedwork-production.up.railway.app/mcp-rpc
6. **Post-Deployment Monitoring**:
- Monitor Railway dashboard for deployment status
- Check logs for any errors
- Verify MCP tools functionality
- Report deployment success/failure to user
### Git Workflow Automation Commands
```bash
# Standard deployment workflow
git add .
git commit -m "Auto-deploy: [description]"
git push origin main
# Emergency hotfix workflow
git add .
git commit -m "Hotfix: [critical issue description]"
git push origin main
# Feature deployment workflow
git add .
git commit -m "Feature: [new feature description]"
git push origin main
```
4. **Monitor Deployment**:
- Check Railway dashboard for build/deploy status
- Monitor logs for any errors
- Test MCP tools in Cursor
- Notify user of deployment success/failure
### When Promoting Updates
1. **Verify Local Build**: Run `npm run build` successfully
2. **Update Documentation**: Update USER_GUIDE.md if needed
3. **Test Core Functions**: Ensure all 6 MCP tools work
4. **Deploy**: Push to trigger Railway deployment
5. **User Communication**: Update users if .cursor/mcp.json changes needed
## File Structure Awareness
- **src/**: Source TypeScript files
- **dist/**: Compiled JavaScript (auto-generated)
- **docs/**: Documentation files
- **railway.json**: Deployment configuration
- **.cursor/**: Cursor-specific configuration
## Railway Configuration
- **Builder**: NIXPACKS (auto-detects Node.js)
- **Build**: `npm run build` compiles TypeScript
- **Start**: `node dist/index.js` runs MCP server
- **Health**: `/health` endpoint for monitoring
- **Restart**: On failure with max 3 retries
## MCP Integration Points
- **URL**: https://mcptaskedwork-production.up.railway.app/mcp-rpc
- **Protocol**: Model Context Protocol over HTTP
- **Authentication**: Token-based via headers
- **Tools**: create_task, list_tasks, search_tasks, update_task, get_task, help
## User Configuration Required
Users need this in their .cursor/mcp.json:
```json
{
"mcpServers": {
"tasked-dot-work": {
"url": "https://mcptaskedwork-production.up.railway.app/mcp-rpc",
"headers": {
"Content-Type": "application/json",
"token": "user-directus-token"
}
}
}
}
```
## Emergency Procedures
- **Server Down**: Check Railway logs and redeploy if needed
- **Build Failures**: Review TypeScript errors in Railway console
- **API Issues**: Verify Directus instance and user tokens
- **Performance**: Monitor Railway metrics for resource usage
## Automation Triggers
### When to Trigger Deployment Confirmation
- **Source Code Changes**: Any modifications to src/ directory files
- **Configuration Changes**: Updates to railway.json, package.json, tsconfig.json
- **Documentation Updates**: Changes to USER_GUIDE.md or API documentation
- **Dependency Updates**: New packages or version changes in package.json
- **Tool Modifications**: Updates to MCP tools or functionality
- **Schema Changes**: Directus schema modifications or API changes
### Automatic Railway Triggers
- **Auto-deploy**: Main branch commits
- **Auto-restart**: Server failures (max 3 retries)
- **Auto-build**: TypeScript compilation on deploy
- **Auto-detect**: Node.js environment and dependencies
### Deployment Confirmation Messages Examples
```
š Ready to deploy MCP Task Manager changes?
Changes made:
- Updated create_task tool with natural language parsing
- Enhanced working directory detection
- Added help tool with comprehensive documentation
Files modified:
- src/tools/task-tools.ts
- src/utils/context.ts
- src/tools/help-tool.ts
- docs/USER_GUIDE.md
Deploy to Railway? (y/N)
```
**After commit and push the client needs to wait for 2 minutes.**
### Post-Deployment Success Message
```
ā
Deployment successful!
š MCP Server: https://mcptaskedwork-production.up.railway.app/mcp-rpc
š Railway Dashboard: [link to deployment]
š User Guide: Updated with latest changes
Next steps:
- Test MCP tools in Cursor
- Verify Directus connectivity
- Update user configurations if needed
```