# CodePilot MCP - Intelligent Automation Platform
# GitHub Copilot Instructions
You are working on CodePilot MCP, an intelligent automation platform built on the Model Context Protocol (MCP). This project orchestrates workflows across GitHub, Notion, Google Calendar, and Slack using AI-powered agents.
## Architecture Overview
- **MCP Server** (`src/index.ts`): Main server with tool registration and workflow orchestration
- **Services** (`src/services/`): Integration modules for GitHub, Notion, Calendar, Slack, Auth, Memory
- **Agents** (`src/agents/`): AI-powered agents for planning, reasoning, execution, and evaluation
- **Webhook Service** (`src/services/webhook/`): Handles incoming webhooks from external services
- **Dashboard** (`dashboard/`): Next.js frontend for monitoring and management
- **Slack Bot** (`src/services/slack/`): Interactive Slack integration
## Key Technologies
- **TypeScript**: Primary language with strict typing
- **Zod**: Runtime validation and type inference
- **Express**: Webhook handling and API endpoints
- **MongoDB**: Document storage for workflows and memory
- **Next.js**: React-based dashboard frontend
- **Slack Bolt**: Slack app framework
- **OpenAI**: LLM integration for reasoning agent
## Code Patterns
### Service Pattern
Each integration follows a consistent service pattern:
```typescript
export class ServiceName {
async performAction(params: ValidatedParams): Promise<Result> {
// Implementation with proper error handling and logging
}
}
```
### Validation Pattern
All inputs are validated using Zod schemas:
```typescript
export const ActionSchema = z.object({
// Define schema
});
export type ActionParams = z.infer<typeof ActionSchema>;
```
### Agent Pattern
Agents follow a consistent interface:
```typescript
export class AgentName {
async process(input: AgentInput): Promise<AgentOutput> {
// Agent-specific logic
}
}
```
## Development Guidelines
1. **Type Safety**: Use TypeScript strictly, avoid `any` types
2. **Validation**: Validate all inputs with Zod schemas
3. **Error Handling**: Use proper error boundaries and logging
4. **Testing**: Write tests for new features and critical paths
5. **Documentation**: Update README and inline comments
6. **Security**: Validate webhooks, sanitize inputs, use environment variables
## Common Operations
### Adding New Tool
1. Create service method
2. Add Zod validation schema
3. Register tool in MCP server
4. Add to agents if needed
5. Update documentation
### Adding New Webhook
1. Add endpoint in webhook service
2. Handle signature verification
3. Route to appropriate service
4. Add Slack notifications if needed
5. Test with real webhooks
### Adding Dashboard Component
1. Create component in appropriate directory
2. Use TypeScript and Tailwind CSS
3. Integrate with API client
4. Add to main dashboard layout
5. Test responsive design
## Environment Setup
The project uses environment variables for configuration. Check `.env.example` for required variables.
## Deployment
The project supports multiple deployment options:
- Local development with `npm run dev`
- Docker with included Dockerfile
- Google Cloud Run with cloudrun.yaml
- Manual deployment with build scripts
Remember to maintain high code quality, comprehensive error handling, and clear documentation when making changes.