Contributing to MCP ADR Analysis Server
Thank you for your interest in contributing! This document provides comprehensive guidelines tailored to our TypeScript/Node.js MCP server architecture.
Prerequisitesβ
- Node.js β₯20.0.0
- npm β₯9.0.0
- Git with pre-commit hooks enabled
- Editor with EditorConfig, ESLint, and Prettier support
Development Setupβ
# Clone and setup
git clone https://github.com/tosin2013/mcp-adr-analysis-server.git
cd mcp-adr-analysis-server
npm install
# Verify setup works
npm run typecheck
npm run lint
npm run test
# Start development
npm run dev
Code Standardsβ
TypeScript Guidelinesβ
- Use strict TypeScript configuration (already configured with
strict: true
) - Prefer explicit types over
any
(ESLint will warn aboutany
usage) - Document complex types and interfaces with JSDoc comments
- Follow existing import patterns (ESM modules with
.js
extensions in imports) - Use the established error types (
McpAdrError
) for consistent error handling
Formatting and Lintingβ
Our automated toolchain ensures consistency:
# Before committing, run:
npm run lint:fix # Auto-fix ESLint issues
npm run format # Format with Prettier
npm run typecheck # Verify TypeScript compilation
# Or run all checks together:
npm run prepublishOnly
Pre-commit hooks automatically:
- Format code with Prettier
- Run ESLint with auto-fix
- Validate TypeScript compilation
Testing Requirementsβ
- Maintain β₯85% coverage threshold (enforced by Jest)
- Write unit tests for new utilities in
src/utils/
- Add integration tests for new tools in
src/tools/
- Use descriptive test names following the pattern:
should [expected behavior] when [condition]
- Test files should mirror source structure:
src/utils/file.ts
βtests/utils/file.test.ts
File Structure and Architectureβ
src/
βββ tools/ # MCP tools (main functionality)
βββ utils/ # Reusable utilities
βββ types/ # TypeScript type definitions
βββ prompts/ # MCP prompts
βββ templates/ # Code generation templates
βββ config/ # Configuration management
Follow these patterns when adding new code:
- Tools: Implement MCP protocol handlers in
src/tools/
- Utilities: Place reusable logic in
src/utils/
and export throughindex.ts
- Types: Define interfaces in
src/types/
with proper JSDoc documentation - Tests: Mirror source structure in
tests/
directory
Commit Standardsβ
We use conventional commits with automated validation:
- Format:
type(scope): description
- Types:
feat
,fix
,docs
,style
,refactor
,test
,chore
- Examples:
feat(tools): add new ADR analysis tool
fix(utils): resolve caching issue in file operations
docs(contributing): update setup instructions
Architecture Patternsβ
Tool Developmentβ
When creating new MCP tools in src/tools/
:
- Error Handling: Use
McpAdrError
for consistent error reporting - Caching: Leverage the existing cache system (
src/utils/cache.ts
) - Validation: Use Zod schemas for input validation
- Logging: Use the enhanced logging utility (
src/utils/enhanced-logging.ts
)
Example tool structure:
import { McpAdrError } from '../types/index.js';
import { logger } from '../utils/enhanced-logging.js';
export async function myNewTool(args: MyToolArgs): Promise<MyToolResult> {
try {
logger.info('Starting tool operation', { args });
// Implementation
return result;
} catch (error) {
throw McpAdrError.fromError(error, 'MY_TOOL_ERROR');
}
}
Utility Functionsβ
For reusable logic in src/utils/
:
- Export Pattern: Always export through
src/utils/index.ts
- Documentation: Include comprehensive JSDoc comments
- Testing: Write corresponding unit tests
- Type Safety: Use strict TypeScript with proper return types
Pull Request Processβ
- Create Feature Branch:
git checkout -b feature/description
- Implement Changes: Follow our coding standards above
- Run Full Test Suite:
npm test
(includes coverage verification) - Update Documentation: Add/update relevant docs if needed
- Submit PR: Use our PR template with clear description
- CI Verification: Ensure all automated checks pass
PR Review Guidelinesβ
Reviewers focus on:
- Functionality: Does it work as intended?
- Architecture: Does it follow established patterns?
- Testing: Is coverage maintained and are edge cases covered?
- Security: Any potential security implications?
- MCP Compliance: Does it properly implement MCP protocol standards?
Note: Style and formatting are automated, so reviews focus on substance over syntax.
Quality Gatesβ
All contributions must pass:
- β
TypeScript compilation (
npm run typecheck
) - β
ESLint rules (
npm run lint
) - β
Test suite with β₯85% coverage (
npm run test:coverage
) - β
Build process (
npm run build
) - β Pre-commit hooks execution
Getting Helpβ
- Architecture Questions: Review existing ADRs in
././adrs/
- Tool Development: Examine existing tools in
src/tools/
- Testing Patterns: Check
tests/
for examples - MCP Protocol: Refer to @modelcontextprotocol/sdk documentation
Code of Conductβ
Please read and follow our Code of Conduct.
This guide is maintained to reflect our current toolchain and practices. When in doubt, follow the automated toolingβit embodies our agreed-upon standards.