This guide covers development setup, testing procedures, contributing guidelines, and code standards for Network Capture MCP.
For basic setup requirements, see Getting Started Guide.
Additional development requirements:
- Git - For version control
- Text editor/IDE - VS Code recommended
- Fork and clone the repository:
git clone https://github.com/your-username/network-capture-mcp
cd network-capture-mcp
npm install- Verify development setup:
npm test
npm run lintThis project uses tsx to run TypeScript directly without a build step:
- Faster development - No compilation wait time
- Simpler workflow - Edit TypeScript, run immediately
- Auto-reload - Use
npm run devfor automatic restarts - Direct execution - TypeScript files run natively
# Run in development mode with auto-reload
npm run dev
# Run directly with tsx (no build required)
npm start
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch
# Run tests with UI
npm run test:ui
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix- Edit TypeScript files in
src/ - Run with tsx:
npm startornpm run dev - No build step needed - tsx handles TypeScript compilation on-the-fly
- Test changes:
npm test - Lint code:
npm run lint
src/
├── cli/ # Command-line interface
├── config/ # Configuration management
├── proxy/ # Mockttp proxy implementation
├── storage/ # SQLite database operations
├── tools/ # MCP tool implementations
├── types/ # TypeScript type definitions
└── index.ts # Main entry point
scripts/
├── dev-db-validator.ts # Database validation tools
├── mcp-tool-tester.ts # MCP tool testing utilities
├── generate-certs.js # SSL certificate generation
└── test-protocol-filter.ts # Protocol filtering tests
docs/ # Documentation
tests/ # Test files
certs/ # SSL certificates (auto-generated)
Network Capture MCP includes comprehensive testing tools:
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch
# Run tests with UI
npm run test:ui# Validate database and MCP tools
npm run dev-validate
# Test database functionality
npm run validate-db:all
# Test MCP tool functionality
npm run test-mcp-tools
# Test protocol filtering
npm run test-protocol-filter# Start server and test with curl
npm start
curl --proxy http://localhost:8080 https://httpbin.org/get
# Test with your AI agent
# Ask: "Show me all traffic from the last 5 minutes"- Write tests for new features - 100% test coverage goal
- Test both success and error cases - Include edge cases
- Use descriptive test names - Clear intent and expectations
- Mock external dependencies - Isolate units under test
- Test MCP tool integration - Verify tool responses and parameters
- Individual functions and classes
- Database operations and queries
- Configuration parsing and validation
- Error handling and edge cases
- MCP tool functionality end-to-end
- Proxy server operations with real traffic
- Database storage and retrieval workflows
- SSL certificate handling and validation
- Memory usage under load
- Database query performance with large datasets
- Proxy throughput and latency measurements
- Concurrent connection handling
- Strict TypeScript configuration enabled
- Explicit types for all public APIs
- Interface definitions for complex objects
- Generic types where appropriate
- Proper error handling with typed exceptions
- ESLint for code linting
- Prettier for code formatting (if configured)
- Consistent naming conventions:
camelCasefor variables and functionsPascalCasefor classes and interfacesUPPER_SNAKE_CASEfor constants
- Clear function names that describe their purpose
- Comprehensive comments for complex logic
- Single responsibility - One main concept per file
- Logical grouping - Related functionality together
- Clear imports - Explicit import statements
- Export organization - Clear public API boundaries
// ✅ Good - Specific error types
class ProxyStartError extends Error {
constructor(port: number, cause?: Error) {
super(`Failed to start proxy on port ${port}`);
this.name = 'ProxyStartError';
this.cause = cause;
}
}
// ✅ Good - Proper error propagation
async function startProxy(config: ProxyConfig): Promise<void> {
try {
await mockttpServer.start(config.port);
} catch (error) {
throw new ProxyStartError(config.port, error);
}
}- Fork the repository on GitHub
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes with tests
- Run validation:
npm run dev-validate - Commit with conventional format:
git commit -m "feat: your feature" - Push and create PR:
git push origin feature/your-feature
- Check existing issues - Look for related work
- Discuss major changes - Open an issue for discussion
- Read the code - Understand existing patterns
- Run tests - Ensure everything works
- Follow code standards - Use existing patterns
- Write tests - Cover new functionality
- Update documentation - Keep docs current
- Test thoroughly - Manual and automated testing
Use conventional commits format:
# Feature additions
git commit -m "feat: add WebSocket message filtering"
# Bug fixes
git commit -m "fix: resolve database connection timeout"
# Documentation updates
git commit -m "docs: update API reference examples"
# Performance improvements
git commit -m "perf: optimize database query performance"
# Refactoring
git commit -m "refactor: simplify proxy configuration logic"- Create descriptive PR title - Clear summary of changes
- Provide detailed description - What, why, and how
- Link related issues - Reference issue numbers
- Include test results - Show validation passing
- Request appropriate reviewers - Tag maintainers
## Description
Brief description of changes and motivation.
## Changes Made
- List of specific changes
- New features or fixes
- Breaking changes (if any)
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
- [ ] Performance impact assessed
## Documentation
- [ ] Code comments updated
- [ ] API documentation updated
- [ ] User documentation updated (if needed)
## Checklist
- [ ] Code follows project standards
- [ ] Tests cover new functionality
- [ ] No breaking changes (or properly documented)
- [ ] Performance impact is acceptable- Fix issues and improve reliability
- Handle edge cases better
- Improve error messages and debugging
- Performance optimizations
- New analysis tools and export formats
- Enhanced filtering and search capabilities
- Additional MCP tools for traffic analysis
- Performance monitoring improvements
- Improve guides and examples
- Add tutorials for specific use cases
- Update API documentation with examples
- Create video tutorials or demos
- Add more test cases and validation
- Improve test coverage in specific areas
- Performance benchmarking and regression tests
- Integration testing with different applications
- CI/CD improvements and automation
- Development tooling enhancements
- Build process optimizations
- Dependency management and security updates
- Semantic versioning (semver) - MAJOR.MINOR.PATCH
- Conventional commits drive version bumps
- Automated changelog generation
- Git tags for releases
- Update version in package.json
- Generate changelog from commits
- Create release tag with git
- Publish to npm (if applicable)
- Update documentation for new version
# Enable debug logging
DEBUG=netcap:* npm start
# Run with specific configuration for testing
npm start -- --port 9090 --db-path ./debug-traffic.db --no-auto-start
# Use development validation tools
npm run dev-validate
npm run test-mcp-tools# Monitor memory usage
node --inspect src/index.ts
# Profile database operations
npm run validate-db:performance
# Test with high load
npm run test:load# TypeScript compilation errors
npx tsc --noEmit && npm run lint:fix
# Reset development database
rm traffic.db* && npm start
# Regenerate development certificates
npm run generate-certsFor general setup and runtime issues, see Troubleshooting Guide.
- Getting Started - Basic setup and usage
- Configuration - Configuration options
- API Reference - MCP tools documentation
- Architecture - Technical architecture details
- Troubleshooting - Common issues and solutions