We welcome contributions to ModelContextKit! This document provides guidelines for contributing to the project.
- 🐛 Bug Reports: Report issues you encounter
- 💡 Feature Requests: Suggest new features or improvements
- 🔧 Code Contributions: Submit bug fixes or new features
- 📚 Documentation: Improve documentation and examples
- 🧪 Testing: Add tests or improve test coverage
- 🎨 Templates: Create new backend templates
- Python 3.8 or higher
- Git
- Basic knowledge of the Model Context Protocol (MCP)
-
Fork and Clone
git clone https://github.com/YOUR_USERNAME/modelcontextkit.git cd modelcontextkit -
Create Virtual Environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Development Dependencies
pip install -e . pip install -r requirements-dev.txt -
Run Tests
python -m pytest tests/ -v
-
Validate Code Generation
# Test that generated servers are syntactically correct python -c " import subprocess result = subprocess.run(['python', '-m', 'modelctx.cli', 'create', 'test_server', '--backend', 'filesystem', '--no-install'], capture_output=True) print('Generator test:', 'PASSED' if result.returncode == 0 else 'FAILED') "
feature/description- for new featuresfix/description- for bug fixesdocs/description- for documentation updatestest/description- for test improvements
We follow Python best practices:
- PEP 8 style guide
- Type hints for function signatures
- Docstrings for all public functions and classes
- Line length: 88 characters (Black formatter)
Before submitting, ensure your code passes:
# Format code
black modelctx/
# Sort imports
isort modelctx/
# Lint code
flake8 modelctx/
# Type checking
mypy modelctx/
# Run tests
pytest tests/ -v- Unit Tests: Test individual functions and classes
- Integration Tests: Test backend generation end-to-end
- Syntax Validation: Ensure generated code compiles
- MCP Compliance: Verify generated servers follow MCP spec
def test_backend_generation():
"""Test that backend generates syntactically correct code."""
# Arrange
backend = FilesystemBackend(config)
# Act
generated_code = backend.generate_server_code()
# Assert
# Test that code compiles
compile(generated_code, '<string>', 'exec')
# Test that required functions are present
assert 'async def list_tools()' in generated_code
assert 'async def call_tool(' in generated_code- Code Generation: All backends must generate valid Python
- Template Rendering: Templates must render without errors
- MCP Schema: Generated schemas must be valid
- Configuration: Config validation and error handling
To add a new backend type:
-
Create Backend Class
# modelctx/backends/your_backend.py from modelctx.backends.base import BaseBackend class YourBackend(BaseBackend): @classmethod def get_backend_type(cls) -> str: return "your_backend" def get_tools(self) -> List[Dict[str, Any]]: # Define your tools pass
-
Register Backend
# modelctx/backends/__init__.py from .your_backend import YourBackend BACKENDS = { # ... existing backends "your_backend": YourBackend, }
-
Create Templates
- Add templates in
modelctx/templates/your_backend/ - Include
.env.jinja2for environment variables
- Add templates in
-
Add Tests
def test_your_backend_generation(): """Test your backend generates valid code.""" # Test implementation
-
Update Documentation
- Add backend to README.md
- Document tools and configuration options
- Clear Examples: Provide working code examples
- Configuration Details: Document all configuration options
- Error Scenarios: Explain common issues and solutions
- MCP Context: Explain how features relate to MCP protocol
- Code Comments: Explain complex logic
- Docstrings: API documentation
- README Updates: Feature descriptions
- Wiki Pages: Detailed guides and tutorials
- Search existing issues to avoid duplicates
- Test with latest version to ensure bug still exists
- Minimal reproduction case if possible
**Bug Description**
Clear description of the bug
**Steps to Reproduce**
1. Run command: `modelctx create ...`
2. Observe error: ...
**Expected Behavior**
What should have happened
**Actual Behavior**
What actually happened
**Environment**
- OS: [e.g., Ubuntu 20.04]
- Python: [e.g., 3.9.0]
- ModelContextKit: [e.g., 0.1.2]
**Generated Code** (if applicable)
```python
# Include problematic generated codeError Output
# Include full error traceback
## 💡 Feature Requests
### Feature Request Template
```markdown
**Feature Description**
Clear description of the proposed feature
**Use Case**
Why is this feature needed?
**Proposed Solution**
How should this feature work?
**Alternatives Considered**
Other approaches you considered
**Additional Context**
Any other relevant information
- Create Issue: Discuss feature/fix before implementing
- Follow Standards: Ensure code follows project standards
- Add Tests: Include tests for new functionality
- Update Docs: Update relevant documentation
- Test Generation: Verify generated code still works
- Tests Pass: All existing tests continue to pass
- New Tests: Added tests for new functionality
- Code Quality: Passes linting and formatting checks
- Generated Code Works: New changes don't break code generation
- Documentation Updated: README, docstrings, etc. updated
- Backwards Compatible: Changes don't break existing functionality
**Description**
Brief description of changes
**Type of Change**
- [ ] Bug fix (non-breaking change)
- [ ] New feature (non-breaking change)
- [ ] Breaking change (fix/feature causing existing functionality to change)
- [ ] Documentation update
**Testing**
- [ ] Tests pass locally
- [ ] Generated code compiles
- [ ] Manual testing completed
**Checklist**
- [ ] Code follows project style guidelines
- [ ] Self-review of code completed
- [ ] Documentation updated
- [ ] Tests added/updatedContributors will be recognized in:
- GitHub Contributors: Automatic recognition
- Release Notes: Major contributions highlighted
- Website: Contributors page (if applicable)
- Discussions: Use GitHub Discussions for questions
- Issues: Create issues for bugs and feature requests
- Website: Visit modelcontextkit.com
Current focus areas:
- Code Quality: Ensuring generated code is always syntactically correct
- New Backends: Adding support for more integration types
- Testing: Improving test coverage and reliability
- Documentation: Better examples and guides
- Performance: Optimizing generation speed
- Security: Enhanced security features in generated code
Since ModelContextKit generates code, we have special requirements:
- Generated Code Must Compile: All generated Python must be syntactically correct
- MCP Compliance: Generated servers must follow MCP protocol exactly
- Error Handling: Generated code must handle errors gracefully
- Type Safety: Use proper type hints in generated code
- Security: Generated code must include input validation
When creating or modifying templates:
- Use Jinja2 Best Practices: Proper escaping and formatting
- Validate Output: Test that templates render correctly
- Handle Edge Cases: Templates should work with various configurations
- Maintain Indentation: Ensure generated Python has correct indentation
- Include Comments: Generated code should be well-commented
Thank you for contributing to ModelContextKit! 🙏