- Replaced Express with Elysia for improved performance and type safety - Integrated Elysia middleware for rate limiting, security headers, and request validation - Refactored security utilities to work with Elysia's context and request handling - Updated token management and validation logic - Added comprehensive security headers and input sanitization - Simplified server initialization and error handling - Updated documentation with new setup and configuration details
Development Guide
This guide provides information for developers who want to contribute to or extend the Home Assistant MCP.
Project Structure
homeassistant-mcp/
├── src/
│ ├── __tests__/ # Test files
│ ├── __mocks__/ # Mock files
│ ├── api/ # API endpoints and route handlers
│ ├── config/ # Configuration management
│ ├── hass/ # Home Assistant integration
│ ├── interfaces/ # TypeScript interfaces
│ ├── mcp/ # MCP core functionality
│ ├── middleware/ # Express middleware
│ ├── routes/ # Route definitions
│ ├── security/ # Security utilities
│ ├── sse/ # Server-Sent Events handling
│ ├── tools/ # Tool implementations
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Utility functions
├── __tests__/ # Test files
├── docs/ # Documentation
├── dist/ # Compiled JavaScript
└── scripts/ # Build and utility scripts
Development Setup
-
Install dependencies:
npm install -
Set up development environment:
cp .env.example .env.development -
Start development server:
npm run dev
Code Style
We follow these coding standards:
-
TypeScript best practices
- Use strict type checking
- Avoid
anytypes - Document complex types
-
ESLint rules
- Run
npm run lintto check - Run
npm run lint:fixto auto-fix
- Run
-
Code formatting
- Use Prettier
- Run
npm run formatto format code
Testing
-
Unit tests:
npm run test -
Integration tests:
npm run test:integration -
Coverage report:
npm run test:coverage
Creating New Tools
-
Create a new file in
src/tools/:import { z } from 'zod'; import { Tool } from '../types'; export const myTool: Tool = { name: 'my_tool', description: 'Description of my tool', parameters: z.object({ // Define parameters }), execute: async (params) => { // Implement tool logic } }; -
Add to
src/tools/index.ts -
Create tests in
__tests__/tools/ -
Add documentation in
docs/tools/
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Write/update tests
- Update documentation
- Submit a pull request
Pull Request Process
- Ensure all tests pass
- Update documentation
- Update CHANGELOG.md
- Get review from maintainers
Building
-
Development build:
npm run build:dev -
Production build:
npm run build
Documentation
- Update documentation for changes
- Follow documentation structure
- Include examples
- Update type definitions
Debugging
-
Development debugging:
npm run dev:debug -
Test debugging:
npm run test:debug -
VSCode launch configurations provided
Performance
- Follow performance best practices
- Use caching where appropriate
- Implement rate limiting
- Monitor memory usage
Security
- Follow security best practices
- Validate all inputs
- Use proper authentication
- Handle errors securely
Deployment
-
Build for production:
npm run build -
Start production server:
npm start -
Docker deployment:
docker-compose up -d
Support
Need development help?
- Check documentation
- Search issues
- Create new issue
- Join discussions