# Contributing to Second Brain MCP Server
Thank you for your interest in contributing to the Second Brain MCP Server! This document provides guidelines and instructions for contributing.
## Development Setup
1. Fork and clone the repository
2. Install dependencies:
```bash
pnpm install
```
3. Build the project:
```bash
pnpm run build
```
4. Run tests:
```bash
pnpm run test
```
## Development Workflow
1. Create a new branch from `master`:
```bash
git checkout -b feature/your-feature-name
```
2. Make your changes and ensure tests pass:
```bash
pnpm run test
pnpm run build
```
3. Commit your changes using conventional commits (see below)
4. Push your branch and create a pull request
## Conventional Commits
This project uses [Conventional Commits](https://www.conventionalcommits.org/) for automated versioning and changelog generation.
### Commit Message Format
```
<type>(<scope>): <subject>
<body>
<footer>
```
### Types
- `feat`: A new feature (triggers minor version bump)
- `fix`: A bug fix (triggers patch version bump)
- `docs`: Documentation only changes
- `style`: Code style changes (formatting, semicolons, etc.)
- `refactor`: Code changes that neither fix bugs nor add features
- `perf`: Performance improvements
- `test`: Adding or updating tests
- `build`: Changes to build system or dependencies
- `ci`: Changes to CI configuration
- `chore`: Other changes that don't modify src or test files
### Breaking Changes
To indicate a breaking change (triggers major version bump), add `BREAKING CHANGE:` in the commit footer or add `!` after the type:
```
feat!: remove deprecated API endpoint
BREAKING CHANGE: The /old-endpoint API has been removed. Use /new-endpoint instead.
```
### Examples
```bash
# Feature
git commit -m "feat: add solution recall system for past problem-solving sessions"
# Bug fix
git commit -m "fix: correct metadata caching for large note collections"
# Documentation
git commit -m "docs: update installation instructions for Claude Code"
# Breaking change
git commit -m "feat!: change capture_session_note parameter structure
BREAKING CHANGE: The 'commands' parameter now requires timestamp field."
```
### Scope (Optional)
You can add a scope to provide additional context:
```bash
git commit -m "feat(search): add fuzzy matching for note queries"
git commit -m "fix(storage): handle race condition in concurrent writes"
```
## Pull Request Guidelines
1. **Title**: Use conventional commit format for PR titles
2. **Description**: Provide clear description of changes
3. **Tests**: Add tests for new features or bug fixes
4. **Documentation**: Update README.md if adding new features
5. **Breaking Changes**: Clearly document any breaking changes
### PR Checklist
Before submitting, ensure:
- [ ] Tests pass locally (`pnpm run test`)
- [ ] Build succeeds (`pnpm run build`)
- [ ] Code follows existing style
- [ ] Commit messages follow conventional commits format
- [ ] Documentation is updated if needed
- [ ] Breaking changes are documented
## Running Tests Locally
```bash
# Run all tests
pnpm run test
# Run tests in watch mode
pnpm run test:watch
# Run tests with coverage
pnpm run test:coverage
```
## Code Style
- Use TypeScript for all new code
- Follow existing code patterns
- Use meaningful variable and function names
- Add comments for complex logic
- Keep functions focused and small
## Project Structure
```
src/
├── index.ts # MCP server entry point
├── types/ # TypeScript type definitions
│ └── session.ts
└── services/ # Core functionality
├── storage.ts # File operations
├── noteFormatter.ts # Markdown generation
├── patternDetector.ts
├── complexityAnalyzer.ts
├── learningTracker.ts
├── descriptionGenerator.ts
├── searchEngine.ts
├── sessionSimilarity.ts
├── todoTracker.ts
├── obsidianExporter.ts
└── reportGenerator.ts
```
## Adding a New Tool
1. Define the tool in `ListToolsRequestSchema` handler
2. Add tool execution logic in `CallToolRequestSchema` handler
3. Create service module in `src/services/` if needed
4. Add tests for the new functionality
5. Update README.md with tool documentation
## Reporting Issues
When reporting issues, please include:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Environment details (OS, Node version, Claude Code version)
- Error messages or logs if applicable
## Questions?
If you have questions about contributing, feel free to:
- Open an issue with the "question" label
- Check existing issues for similar questions
- Review the README.md for usage documentation
## License
By contributing, you agree that your contributions will be licensed under the MIT License.