Contributing to Terraform Cloud MCP
June 7, 2025 ยท View on GitHub
Thank you for your interest in contributing to the Terraform Cloud MCP project! This document provides guidelines and instructions for contributing to this project.
Getting Started
- Fork the repository on GitHub
- Clone your forked repository locally
- Set up the development environment as described in the Development Guide
Development Environment
# Clone the repository
git clone https://github.com/severity1/terraform-cloud-mcp.git
cd terraform-cloud-mcp
# Create virtual environment and activate it
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in development mode with development dependencies
uv pip install -e .
uv pip install black mypy pydantic ruff
Code Quality Standards
Before submitting your contribution, please ensure your code meets our quality standards:
-
Type Checking: Use proper type hints everywhere
uv run -m mypy . -
Linting: Ensure code follows our style guidelines
uv run -m ruff check . -
Formatting: Format code with Black
uv run -m black . -
Tests: Add tests for new functionality
uv run -m unittest discover tests
Contribution Guidelines
Pull Request Process
- Create a feature branch for your changes
- Make your changes following the code style guidelines in the Development Guide
- Add or update tests to verify your changes
- Update documentation, including:
- Function docstrings
- Example files in the appropriate
docs/subdirectory - README.md if adding new features or changing APIs
- Run all quality checks to ensure your code meets our standards
- Commit your changes with a clear, descriptive commit message
- Push your branch and create a pull request
Commit Messages
Write clear, descriptive commit messages that explain why the change was made, not just what changed. For example:
Fix workspace creation validation for execution mode
The workspace creation API was not properly validating the execution
mode and defaulting to 'local' instead of 'remote', causing confusion
for users. This fix ensures defaults match API documentation.
Extending the Server
To add new functionality to the MCP server:
-
Add model classes in the
terraform_cloud_mcp/modelsdirectory:- Define enums for constrained choices
- Create request models inheriting from
APIRequest - Create a
*Paramsmodel for function parameters - For examples, see:
account.pyfor simple request modelsworkspaces.pyfor comprehensive models with paramscost_estimates.pyfor models with enums and status tracking
-
Add tool functions in the
terraform_cloud_mcp/toolsdirectory:- Accept typed
paramsobjects instead of**kwargs - Use the
@handle_api_errorsdecorator - Use utility functions from
utils/payload.pyfor JSON:API payloads - Use utility functions from
utils/request.pyfor parameters - Return
APIResponsetype - For examples, see:
account.pyfor simple GET operationsworkspaces.pyfor full CRUD operationscost_estimates.pyfor specialized retrieval operations
- Accept typed
-
Register new tools in
terraform_cloud_mcp/server.py:- Add import statements at the top
- Use
mcp.tool()(module_name.function_name)to register each function - Group related tools together with comments
-
Follow the Pydantic pattern for parameter validation and error handling
-
Ensure all functions include proper type hints and docstrings
-
Update documentation in the appropriate places (following reference-based documentation approach):
- Add model documentation to
docs/models/(e.g.,cost_estimate.md) with model structure, validation rules, and references to actual implementations - Add tool reference documentation to
docs/tools/(e.g.,cost_estimate.md) following the established format:- Overview section explaining the tool's purpose
- API Reference section with links to Terraform Cloud API documentation
- Tools Reference section with function signatures, parameters, return values, and references to actual implementations
- Notes section for important usage information
- Common Error Scenarios section in table format
- Add conversation examples to
docs/conversations/(e.g.,cost-estimate-conversation.md) showing real-world usage patterns with the API - Update
docs/README.mdto include new functionality - Update
README.mdto include new functionality - Update
docs/CONTRIBUTING.md(this file) to reflect new patterns or processes - Update
docs/DEVELOPMENT.mdto include new development standards or patterns
- Add model documentation to
-
Update existing integration files:
- Add exports to
models/__init__.py - Add imports to
tools/__init__.py
- Add exports to
-
Update
CLAUDE.mdfiles to document new functionality:- Update main
CLAUDE.mdif adding major new components - Update
docs/CLAUDE.mdwith changes to documentation structure or standards - Update component-specific CLAUDE.md files as needed:
terraform_cloud_mcp/api/CLAUDE.mdfor API client changesterraform_cloud_mcp/models/CLAUDE.mdfor model patternsterraform_cloud_mcp/tools/CLAUDE.mdfor tool implementation patternsterraform_cloud_mcp/utils/CLAUDE.mdfor utility function patterns
- These files should include:
- New patterns introduced
- Additional examples for AI assistance
- Component-specific guidelines
- These files are critical for AI-assisted development and should document any non-obvious patterns
- Update main
Release Process
If you are a maintainer with release permissions, follow these steps for releasing a new version:
-
Update version number in:
pyproject.tomlREADME.mdbadges- Create release notes
-
Run quality checks:
uv run -m mypy .uv run -m ruff check .uv run -m black --check .uv run -m unittest discover tests
-
Commit changes with clear message
-
Tag the release with the version number:
git tag v0.x.y
-
Push changes and tags:
git push origin main --tags
Questions?
If you have any questions or need help, please open an issue on GitHub and we'll be happy to assist you.
Thank you for contributing!