Thank you for your interest in contributing to PyWellen MCP! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Workflow
- Coding Standards
- Testing
- Documentation
- Pull Request Process
- Release Process
This project adheres to a code of conduct that emphasizes:
- Respect: Treat all contributors with respect and professionalism
- Inclusivity: Welcome contributions from people of all backgrounds
- Collaboration: Work together constructively
- Quality: Maintain high standards for code and documentation
- Python 3.10 or later
- Git
- Basic understanding of MCP (Model Context Protocol)
- Familiarity with waveform file formats (VCD, FST, GHW)
-
Fork and clone the repository:
git clone https://github.com/YOUR_USERNAME/pywellen-mcp.git cd pywellen-mcp -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install in development mode:
pip install -e ".[dev]" -
Verify installation:
pytest python -m pywellen_mcp.server --version
pywellen-mcp/
├── src/pywellen_mcp/ # Source code
│ ├── server.py # MCP server
│ ├── session.py # Session management
│ └── tools_*.py # Tool implementations
├── tests/ # Test suite
│ └── unit/ # Unit tests
├── scripts/ # Utility scripts
├── docs/ # Documentation (RST format)
└── .github/workflows/ # CI/CD pipelines
Create a feature branch from master:
git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fixBranch naming conventions:
feature/- New featuresfix/- Bug fixesdocs/- Documentation updatesrefactor/- Code refactoringtest/- Test improvements
- Write clear, concise code following our coding standards
- Add tests for new functionality
- Update documentation as needed
- Keep commits atomic and well-described
Run the full test suite:
# All tests
pytest
# With coverage
pytest --cov=pywellen_mcp --cov-report=html
# Specific test file
pytest tests/unit/test_tools_signal.py
# Specific test function
pytest tests/unit/test_tools_signal.py::test_signal_get_valueWrite clear commit messages:
git add .
git commit -m "feat: add support for LXT2 waveform format"Commit message format:
feat:- New featurefix:- Bug fixdocs:- Documentationtest:- Testingrefactor:- Code refactoringperf:- Performance improvementchore:- Maintenance tasks
git push origin feature/your-feature-nameThen create a Pull Request on GitHub.
- PEP 8: Follow Python style guide
- Black: Use Black formatter (line length: 88)
- Type Hints: Include type annotations for all functions
- Docstrings: Use Google-style docstrings
Example:
from typing import Optional, List
from pywellen_mcp.session import SessionManager
async def signal_get_value(
session_manager: SessionManager,
session_id: str,
signal_path: str,
time: str,
format: str = "int"
) -> dict:
"""Get the value of a signal at a specific time.
Args:
session_manager: The session manager instance
session_id: Unique session identifier
signal_path: Full hierarchical path to signal
time: Time value as string
format: Value format (int, hex, bin, signed)
Returns:
Dictionary containing signal value and metadata
Raises:
ValueError: If session_id or signal_path is invalid
KeyError: If signal not found in hierarchy
"""
# Implementation
pass- One tool per function: Each MCP tool is a standalone async function
- Session parameter: Pass
session_manageras first parameter - Error handling: Use structured error responses
- Type safety: Use
typingmodule for complex types
Return structured errors:
return {
"error": "SESSION_NOT_FOUND",
"message": f"Session {session_id} not found",
"context": {
"session_id": session_id,
"active_sessions": list(session_manager.sessions.keys())
}
}Common error codes:
FILE_NOT_FOUND- Waveform file not foundSESSION_NOT_FOUND- Invalid session IDINVALID_PATH- Invalid signal/scope pathPARSE_ERROR- Waveform parsing errorINVALID_TIME- Invalid time valueINVALID_FORMAT- Invalid format specifier
- Unit tests: Test individual functions in isolation
- Mocking: Use
unittest.mockfor external dependencies - Fixtures: Use pytest fixtures for common test data
- Coverage: Aim for 80%+ code coverage
Example test:
import pytest
from unittest.mock import Mock, MagicMock
from pywellen_mcp.session import SessionManager
from pywellen_mcp.tools_signal import signal_get_value
@pytest.fixture
def session_manager():
"""Create a mock session manager."""
manager = Mock(spec=SessionManager)
session = MagicMock()
session.waveform = MagicMock()
session.hierarchy = MagicMock()
manager.get_session.return_value = session
return manager
@pytest.mark.asyncio
async def test_signal_get_value_success(session_manager):
"""Test successful signal value retrieval."""
# Setup
session = session_manager.get_session.return_value
session.waveform.get_signal_value.return_value = 42
# Execute
result = await signal_get_value(
session_manager=session_manager,
session_id="test-session",
signal_path="top.clk",
time="100"
)
# Assert
assert result["value"] == 42
assert result["signal_path"] == "top.clk"
assert result["time"] == "100"-
Unit Tests (
tests/unit/):- Test individual functions
- Use mocks for dependencies
- Fast execution (<1s)
-
Integration Tests (future):
- Test with real waveform files
- Test tool interactions
- Slower execution (seconds)
-
Performance Tests (
scripts/benchmark.py):- Measure operation performance
- Track performance regressions
- Generate reports
# All tests
pytest
# Specific category
pytest tests/unit/
# With coverage
pytest --cov=pywellen_mcp --cov-report=html
# Parallel execution
pytest -n auto
# Verbose output
pytest -v
# Stop on first failure
pytest -x- reStructuredText: Use
.rstfiles indocs/ - Sphinx: Built with Sphinx documentation generator
- API Docs: Auto-generated from docstrings
- Examples: Include practical examples
# Install documentation dependencies
pip install -e ".[docs]"
# Build HTML documentation
cd docs
make html
# View documentation
open _build/html/index.html # On macOS
# or
xdg-open _build/html/index.html # On Linuxdocs/
├── index.rst # Main documentation index
├── getting_started.rst # Installation and quick start
├── api_reference.rst # Complete API documentation
├── best_practices.rst # Usage recommendations
├── deployment.rst # Production deployment
└── contributing.rst # This guide
- Clear: Use simple, direct language
- Examples: Include code examples
- Complete: Cover all parameters and return values
- Updated: Keep in sync with code changes
- Tests pass: Ensure all tests pass locally
- Coverage: Maintain or improve code coverage
- Documentation: Update relevant documentation
- Commits: Clean up commit history (squash if needed)
- Changelog: Add entry to CHANGELOG.md (if applicable)
Include:
- Summary: Brief description of changes
- Motivation: Why is this change needed?
- Testing: How was this tested?
- Breaking Changes: Any backwards incompatible changes?
- Screenshots: If UI/output changes
Template:
## Summary
Brief description of what this PR does
## Motivation
Why is this change needed? What problem does it solve?
## Changes
- Change 1
- Change 2
- Change 3
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass (if applicable)
- [ ] Manual testing performed
## Breaking Changes
None / Description of breaking changes
## Checklist
- [ ] Code follows project style guidelines
- [ ] Tests added/updated
- [ ] Documentation updated
- [ ] CHANGELOG.md updated (if needed)- Automated checks: CI/CD pipeline must pass
- Code review: At least one maintainer approval
- Testing: Reviewer may test manually
- Discussion: Address feedback and comments
- Merge: Maintainer will merge when ready
- Delete your feature branch
- Monitor for any issues
- Respond to follow-up questions
We use Semantic Versioning:
- Major (1.0.0): Breaking changes
- Minor (0.1.0): New features, backwards compatible
- Patch (0.0.1): Bug fixes
- Update version in
pyproject.toml - Update CHANGELOG.md
- Run full test suite
- Build documentation
- Create release tag:
v1.0.0 - Push tag to trigger CI/CD
- Verify PyPI publication
- Create GitHub release with notes
Include:
- New features
- Bug fixes
- Breaking changes
- Deprecations
- Contributors
- Documentation: Read the full documentation
- Discussions: Ask in GitHub Discussions
- Issues: Report bugs in GitHub Issues
- Email: Contact maintainers directly
Your contributions make PyWellen MCP better for everyone. We appreciate your time and effort!
Happy Contributing! 🎉