Contributing to Memory Graph MCP
May 8, 2025 · View on GitHub
Thank you for your interest in contributing to the Memory Graph MCP! This document provides guidelines and instructions for contributing to the project.
Table of Contents
- Getting Started
- Development Environment
- Code Structure
- Making Changes
- Testing
- Pull Requests
- Coding Standards
- Documentation
Getting Started
Prerequisites
- Node.js 18 or higher
- npm 7 or higher
- Git
- SQLite (for development and testing)
- MariaDB (optional, for MariaDB storage testing)
Repository Setup
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/memory-graph.git cd memory-graph - Add the original repository as an upstream remote:
git remote add upstream https://github.com/aaronsb/memory-graph.git - Install dependencies:
npm install - Build the project:
npm run build
Development Environment
Running Locally
# Start in development mode (with watch)
npm run dev
# Start with specific storage type
STORAGE_TYPE=sqlite npm run dev
# Start with HTTP transport
TRANSPORT_TYPE=HTTP PORT=3000 npm run dev
Docker Development
For Docker-based development:
# Build local image
./scripts/build-local.sh
# Run with Docker
./scripts/run-local.sh
Code Structure
The codebase is structured as follows:
memory-graph/
├── src/
│ ├── graph/ # Knowledge graph implementation
│ │ ├── MemoryGraph.ts
│ │ ├── MemoryGraph.test.ts
│ │ ├── MermaidGenerator.ts
│ │ └── MermaidGenerator.test.ts
│ ├── storage/ # Storage backends
│ │ ├── MemoryStorage.ts
│ │ ├── JsonMemoryStorage.ts
│ │ ├── SqliteMemoryStorage.ts
│ │ ├── MariaDbMemoryStorage.ts
│ │ ├── DatabaseStorage.ts
│ │ └── StorageFactory.ts
│ ├── tools/ # MCP tool implementations
│ │ ├── memoryTools.ts
│ │ └── memoryTools.test.ts
│ ├── types/ # TypeScript type definitions
│ │ ├── graph.ts
│ │ └── mcp.ts
│ └── index.ts # Main server entry
├── scripts/ # Utility scripts
├── docs/ # Documentation
└── tests/ # Additional tests
For more details on the architecture, see the Architecture Documentation.
Making Changes
Branch Strategy
main: Stable release branchfeature/*: Feature development branchesbugfix/*: Bug fix branches
Workflow
-
Sync your fork with the upstream repository:
git fetch upstream git checkout main git merge upstream/main git push origin main -
Create a new branch for your changes:
git checkout -b feature/your-feature-name -
Make your changes and commit them:
git add . git commit -m "feat: add your feature description" -
Push your changes to your fork:
git push origin feature/your-feature-name -
Create a pull request from your branch to the main repository.
Commit Messages
Follow the Conventional Commits format:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoring without functionality changesperf: Performance improvementstest: Adding or modifying testsbuild: Build system or dependency changesci: CI configuration changes
Examples:
feat(storage): add MariaDB storage backend
fix(tools): correct error handling in recall_memories tool
docs: update README with new features
Testing
Running Tests
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
Writing Tests
- Place test files alongside the code they test, with
.test.tssuffix - Use descriptive test names that explain what's being tested
- Write both unit tests and integration tests
- Test edge cases and error conditions
Example test:
import { MemoryGraph } from './MemoryGraph';
describe('MemoryGraph', () => {
let graph: MemoryGraph;
beforeEach(async () => {
// Setup test graph
graph = new MemoryGraph({
storageDir: './.test_data',
storageType: 'json'
});
await graph.initialize();
});
afterEach(async () => {
// Cleanup
// ...
});
test('should store and retrieve memory', async () => {
// Test implementation
const memory = await graph.storeMemory({
content: 'Test memory'
});
expect(memory).toBeDefined();
expect(memory.content).toBe('Test memory');
// More assertions...
});
});
Pull Requests
PR Checklist
Before submitting a pull request, ensure:
- All tests pass
- Code follows project's coding standards
- New features are properly tested
- Documentation is updated
- Changes are backward compatible (or clearly documented if not)
- The PR has a clear title and description following the commit format
Review Process
- All PRs require at least one review
- Address all review comments
- Ensure CI checks pass
- Squash fixup commits before merging
Coding Standards
TypeScript Guidelines
- Use TypeScript's strict mode
- Prefer interfaces over types for object shapes
- Use async/await for asynchronous code
- Document public APIs with JSDoc comments
- Use meaningful variable and function names
Code Style
The project uses ESLint and Prettier for code style:
# Check code style
npm run lint
# Fix code style issues
npm run lint:fix
Key style guidelines:
- Use 2 spaces for indentation
- Use single quotes for strings
- Use semicolons
- Maximum line length of 100 characters
- Trailing commas in multiline objects and arrays
Documentation
Documentation Guidelines
- Keep documentation up-to-date with code changes
- Write clear, concise documentation
- Use examples to illustrate usage
- Document both API usage and implementation details
- Use Markdown for all documentation
Documentation Structure
README.md: Project overview and quick startdocs/guides/: User guides and tutorialsdocs/concepts/: Core concepts explanationdocs/reference/: API and tool referencedocs/development/: Developer documentation
When adding a new feature, consider:
- Updating relevant guides
- Adding/updating API documentation
- Providing examples of how to use the feature
- Explaining design decisions and trade-offs
Thank you for contributing to the Memory Graph MCP project!