Terraform Cloud Integration
A Model Context Protocol (MCP) server that integrates Claude with the Terraform Cloud API, allowing Claude to manage your Terraform infrastructure through natural conversation.
severity1
Tools
get_account_details
Get account details for a Terraform Cloud API token This endpoint shows information about the currently authenticated user or service account, useful for verifying identity, retrieving email address, and checking authentication status. It returns the same type of object as the Users API, but also includes an email address, which is hidden when viewing info about other users. API endpoint: GET /account/details Returns: Raw API response with account information from Terraform Cloud including user ID, username, email address, and authentication status See: docs/tools/account_tools.md for usage examples
list_workspaces
List workspaces in an organization. Retrieves a paginated list of all workspaces in a Terraform Cloud organization. Results can be filtered using a search string to find specific workspaces by name. Use this tool to discover existing workspaces, check workspace configurations, or find specific workspaces by partial name match. API endpoint: GET /organizations/{organization}/workspaces Args: organization: The name of the organization to list workspaces from page_number: The page number to return (default: 1) page_size: The number of items per page (default: 20, max: 100) search: Optional search string to filter workspaces by name Returns: Paginated list of workspaces with their configuration settings and metadata See: docs/tools/workspace_tools.md for usage examples
get_workspace_details
Get details for a specific workspace, identified either by ID or by org name and workspace name. Retrieves comprehensive information about a workspace including its configuration, VCS settings, execution mode, and other attributes. This is useful for checking workspace settings before operations or determining the current state of a workspace. The workspace can be identified either by its ID directly, or by the combination of organization name and workspace name. API endpoint: - GET /workspaces/{workspace_id} (when using workspace_id) - GET /organizations/{organization}/workspaces/{workspace_name} (when using org+name) Args: workspace_id: The ID of the workspace (format: "ws-xxxxxxxx") organization: The name of the organization (required if workspace_id not provided) workspace_name: The name of the workspace (required if workspace_id not provided) Returns: Comprehensive workspace details including settings, configuration and status See: docs/tools/workspace_tools.md for usage examples
force_unlock_workspace
Force unlock a workspace. This should be used with caution. Forces a workspace to unlock even when the normal unlock process isn't possible. This is typically needed when a run has orphaned a lock or when the user who locked the workspace is unavailable. This operation requires admin privileges on the workspace. WARNING: Forcing an unlock can be dangerous if the workspace is legitimately locked for active operations. Only use this when you are certain it's safe to unlock. API endpoint: POST /workspaces/{workspace_id}/actions/force-unlock Args: workspace_id: The ID of the workspace to force unlock (format: "ws-xxxxxxxx") Returns: The workspace with updated lock status and related metadata See: docs/tools/workspace_tools.md for usage examples
create_workspace
Create a new workspace in an organization. Creates a new Terraform Cloud workspace which serves as an isolated environment for managing infrastructure. Workspaces contain variables, state files, and run histories for a specific infrastructure configuration. API endpoint: POST /organizations/{organization}/workspaces Args: organization: The name of the organization name: The name to give the workspace params: Additional workspace parameters (optional): - description: Human-readable description of the workspace - execution_mode: How Terraform runs are executed (remote, local, agent) - terraform_version: Version of Terraform to use (default: latest) - working_directory: Subdirectory to use when running Terraform - vcs_repo: Version control repository configuration - auto_apply: Whether to automatically apply successful plans - file_triggers_enabled: Whether file changes trigger runs - trigger_prefixes: Directories that trigger runs when changed - trigger_patterns: Glob patterns that trigger runs when files match - allow_destroy_plan: Whether to allow destruction plans - auto_apply_run_trigger: Whether to auto-apply changes from run triggers Returns: The created workspace data including configuration, settings and metadata See: docs/tools/workspace_tools.md for usage examples
update_workspace
Update an existing workspace. Modifies the settings of a Terraform Cloud workspace. This can be used to change attributes like execution mode, VCS repository settings, description, or any other workspace configuration options. Only specified attributes will be updated; unspecified attributes remain unchanged. API endpoint: PATCH /organizations/{organization}/workspaces/{workspace_name} Args: organization: The name of the organization that owns the workspace workspace_name: The name of the workspace to update params: Workspace parameters to update (optional): - name: New name for the workspace (if renaming) - description: Human-readable description of the workspace - execution_mode: How Terraform runs are executed (remote, local, agent) - terraform_version: Version of Terraform to use - working_directory: Subdirectory to use when running Terraform - vcs_repo: Version control repository configuration (oauth-token-id, identifier) - auto_apply: Whether to automatically apply successful plans - file_triggers_enabled: Whether file changes trigger runs - trigger_prefixes: Directories that trigger runs when changed - trigger_patterns: Glob patterns that trigger runs when files match - allow_destroy_plan: Whether to allow destruction plans - auto_apply_run_trigger: Whether to auto-apply changes from run triggers Returns: The updated workspace with all current settings and configuration See: docs/tools/workspace_tools.md for usage examples
delete_workspace
Delete a workspace. Permanently deletes a Terraform Cloud workspace and all its resources including state versions, run history, and configuration versions. This action cannot be undone. WARNING: This is a destructive operation. For workspaces that have active resources, consider running a destroy plan first or use safe_delete_workspace instead. API endpoint: DELETE /organizations/{organization}/workspaces/{workspace_name} Args: organization: The name of the organization that owns the workspace workspace_name: The name of the workspace to delete Returns: Success message with no content (HTTP 204) if successful Error response with explanation if the workspace cannot be deleted See: docs/tools/workspace_tools.md for usage examples
safe_delete_workspace
Safely delete a workspace by first checking if it can be deleted. Initiates a safe delete operation which checks if the workspace has resources before deleting it. This is a safer alternative to delete_workspace as it prevents accidental deletion of workspaces with active infrastructure. The operation follows these steps: 1. Checks if the workspace has any resources 2. If no resources exist, deletes the workspace 3. If resources exist, returns an error indicating the workspace cannot be safely deleted API endpoint: POST /organizations/{organization}/workspaces/{workspace_name}/actions/safe-delete Args: organization: The name of the organization that owns the workspace workspace_name: The name of the workspace to delete Returns: Status of the safe delete operation including: - Success response if deletion was completed - Error with details if workspace has resources and cannot be safely deleted - List of resources that would be affected by deletion (if applicable) See: docs/tools/workspace_tools.md for usage examples
lock_workspace
Lock a workspace. Locks a workspace to prevent runs from being queued. This is useful when you want to prevent changes to infrastructure while performing maintenance or making manual adjustments. Locking a workspace does not affect currently running plans or applies. API endpoint: POST /workspaces/{workspace_id}/actions/lock Args: workspace_id: The ID of the workspace to lock (format: "ws-xxxxxxxx") reason: Optional reason for locking Returns: The workspace with updated lock status and related metadata See: docs/tools/workspace_tools.md for usage examples
unlock_workspace
Unlock a workspace. Removes the lock from a workspace, allowing runs to be queued. This enables normal operation of the workspace after it was previously locked. API endpoint: POST /workspaces/{workspace_id}/actions/unlock Args: workspace_id: The ID of the workspace to unlock (format: "ws-xxxxxxxx") Returns: The workspace with updated lock status and related metadata See: docs/tools/workspace_tools.md for usage examples
create_run
Create a run in a workspace Creates a new Terraform run to trigger infrastructure changes through Terraform Cloud, representing a single execution of plan and apply operations. The run queues in the workspace and executes based on the workspace's execution mode and settings. Use this to deploy new infrastructure, apply configuration changes, or destroy resources. API endpoint: POST /runs Args: workspace_id: The workspace ID to execute the run in (format: "ws-xxxxxxxx") params: Optional run configuration with: - message: Description of the run's purpose - is_destroy: Whether to destroy all resources managed by the workspace - auto_apply: Whether to auto-apply after a successful plan - refresh: Whether to refresh Terraform state before planning - refresh_only: Only refresh the state without planning changes - plan_only: Create a speculative plan without applying - allow_empty_apply: Allow applying when there are no changes - target_addrs: List of resource addresses to specifically target - replace_addrs: List of resource addresses to force replacement - variables: Run-specific variables that override workspace variables - terraform_version: Specific Terraform version to use for this run - save_plan: Save the plan for later execution - debugging_mode: Enable extended debug logging Returns: The created run details with ID, status, configuration information, workspace relationship, and links to associated resources See: docs/tools/run_tools.md for usage examples
list_runs_in_workspace
List runs in a workspace with filtering and pagination Retrieves run history for a specific workspace with options to filter by status, operation type, source, and other criteria. Useful for auditing changes, troubleshooting, or monitoring deployment history. API endpoint: GET /workspaces/{workspace_id}/runs Args: workspace_id: The workspace ID to list runs for (format: "ws-xxxxxxxx") page_number: Page number to fetch (default: 1) page_size: Number of results per page (default: 20) filter_operation: Filter by operation type filter_status: Filter by status filter_source: Filter by source filter_status_group: Filter by status group filter_timeframe: Filter by timeframe filter_agent_pool_names: Filter by agent pool names search_user: Search by VCS username search_commit: Search by commit SHA search_basic: Search across run ID, message, commit SHA, and username Returns: List of runs with metadata, status info, and pagination details See: docs/tools/run_tools.md for usage examples
list_runs_in_organization
List runs across all workspaces in an organization Retrieves run history across all workspaces in an organization with powerful filtering. Useful for organization-wide auditing, monitoring deployments across teams, or finding specific runs by commit or author. API endpoint: GET /organizations/{organization}/runs Args: organization: The organization name page_number: Page number to fetch (default: 1) page_size: Number of results per page (default: 20) filter_operation: Filter by operation type filter_status: Filter by status filter_source: Filter by source filter_status_group: Filter by status group filter_timeframe: Filter by timeframe filter_agent_pool_names: Filter by agent pool names filter_workspace_names: Filter by workspace names search_user: Search by VCS username search_commit: Search by commit SHA search_basic: Basic search across run attributes Returns: List of runs across workspaces with metadata and pagination details See: docs/tools/run_tools.md for usage examples
get_run_details
Get detailed information about a specific run Retrieves comprehensive information about a run including its current status, plan output, and relationship to other resources. Use to check run progress or results. API endpoint: GET /runs/{run_id} Args: run_id: The ID of the run to retrieve details for (format: "run-xxxxxxxx") Returns: Complete run details including status, plan, and relationships See: docs/tools/run_tools.md for usage examples
apply_run
Apply a run that is paused waiting for confirmation after a plan Confirms and executes the apply phase for a run that has completed planning and is waiting for approval. Use this when you've reviewed the plan output and want to apply the proposed changes to your infrastructure. API endpoint: POST /runs/{run_id}/actions/apply Args: run_id: The ID of the run to apply (format: "run-xxxxxxxx") comment: An optional comment explaining the reason for applying the run Returns: Run details with updated status information and confirmation of the apply action including timestamp information and any comment provided See: docs/tools/run_tools.md for usage examples
discard_run
Discard a run that is paused waiting for confirmation Cancels a run without applying its changes, typically used when the plan shows undesired changes or after reviewing and rejecting a plan. This action removes the run from the queue and unlocks the workspace for new runs. API endpoint: POST /runs/{run_id}/actions/discard Args: run_id: The ID of the run to discard (format: "run-xxxxxxxx") comment: An optional explanation for why the run was discarded Returns: Run status update with discarded state information, timestamp of the discard action, and user information See: docs/tools/run_tools.md for usage examples
cancel_run
Cancel a run that is currently planning or applying Gracefully stops an in-progress run during planning or applying phases. Use this when you need to stop a run that's taking too long, consuming too many resources, or needs to be stopped for any reason. The operation attempts to cleanly terminate the run by sending an interrupt signal. API endpoint: POST /runs/{run_id}/actions/cancel Args: run_id: The ID of the run to cancel (format: "run-xxxxxxxx") comment: An optional explanation for why the run was canceled Returns: Run status update with canceled state, timestamp of cancellation, and any provided comment in the response metadata See: docs/tools/run_tools.md for usage examples
force_cancel_run
Forcefully cancel a run immediately Immediately terminates a run that hasn't responded to a normal cancel request. Use this as a last resort when a run is stuck and not responding to regular cancellation. This action bypasses the graceful shutdown process and forces the workspace to be unlocked. API endpoint: POST /runs/{run_id}/actions/force-cancel Args: run_id: The ID of the run to force cancel (format: "run-xxxxxxxx") comment: An optional explanation for why the run was force canceled Returns: Run status update confirming forced cancellation with timestamp, user information, and workspace unlock status See: docs/tools/run_tools.md for usage examples
force_execute_run
Forcefully execute a run by canceling all prior runs Prioritizes a specific run by canceling other queued runs to unlock the workspace, equivalent to clicking "Run this plan now" in the UI. Use this when a run is stuck in the pending queue but needs immediate execution due to urgency or priority over other queued runs. API endpoint: POST /runs/{run_id}/actions/force-execute Args: run_id: The ID of the run to execute (format: "run-xxxxxxxx") Returns: Status update confirming the run has been promoted to active status, with information about which runs were canceled to allow execution See: docs/tools/run_tools.md for usage examples
get_organization_details
Get details for a specific organization Retrieves comprehensive information about an organization including settings, email contact info, and configuration defaults. API endpoint: GET /organizations/{organization} Args: organization: The organization name to retrieve details for (required) Returns: Organization details including name, email, settings and configuration See: docs/tools/organization_tools.md for usage examples
get_organization_entitlements
Show entitlement set for organization features Retrieves information about available features and capabilities based on the organization's subscription tier. API endpoint: GET /organizations/{organization}/entitlement-set Args: organization: The organization name to retrieve entitlements for (required) Returns: Entitlement set details including feature limits and subscription information See: docs/tools/organization_tools.md for usage examples
list_organizations
List organizations with filtering options Retrieves a paginated list of organizations the current user has access to, with options to search by name or email address. API endpoint: GET /organizations Args: page_number: Page number to fetch (default: 1) page_size: Number of results per page (default: 20) query: Search query to filter by name and email query_email: Search query to filter by email only query_name: Search query to filter by name only Returns: List of organizations with metadata and pagination information See: docs/tools/organization_tools.md for usage examples
create_organization
Create a new organization in Terraform Cloud Creates a new organization with the given name and email, allowing workspaces and teams to be created within it. This is the first step in setting up a new environment in Terraform Cloud. API endpoint: POST /organizations Args: name: The name of the organization (required) email: Admin email address (required) params: Additional organization settings: - collaborator_auth_policy: Authentication policy (password or two_factor_mandatory) - session_timeout: Session timeout after inactivity in minutes - session_remember: Session total expiration time in minutes - cost_estimation_enabled: Whether to enable cost estimation for workspaces - default_execution_mode: Default workspace execution mode (remote, local, agent) - aggregated_commit_status_enabled: Whether to aggregate VCS status updates - speculative_plan_management_enabled: Whether to auto-cancel unused speculative plans - assessments_enforced: Whether to enforce health assessments for all workspaces - allow_force_delete_workspaces: Whether to allow deleting workspaces with resources - default_agent_pool_id: Default agent pool ID (required when using agent mode) Returns: The created organization details including ID and created timestamp See: docs/tools/organization_tools.md for usage examples
update_organization
Update an existing organization in Terraform Cloud Modifies organization settings such as email contact, authentication policy, or other configuration options. Only specified attributes will be updated. API endpoint: PATCH /organizations/{organization} Args: organization: The name of the organization to update (required) params: Organization parameters to update: - email: Admin email address for the organization - collaborator_auth_policy: Authentication policy (password or two_factor_mandatory) - session_timeout: Session timeout after inactivity in minutes - session_remember: Session total expiration time in minutes - cost_estimation_enabled: Whether to enable cost estimation for workspaces - default_execution_mode: Default workspace execution mode (remote, local, agent) - aggregated_commit_status_enabled: Whether to aggregate VCS status updates - speculative_plan_management_enabled: Whether to auto-cancel unused speculative plans - assessments_enforced: Whether to enforce health assessments for all workspaces - allow_force_delete_workspaces: Whether to allow deleting workspaces with resources Returns: The updated organization with all current settings See: docs/tools/organization_tools.md for usage examples
delete_organization
Delete an organization from Terraform Cloud Permanently removes an organization including all its workspaces, teams, and resources. This action cannot be undone. Organization names are globally unique and cannot be recreated with the same name later. API endpoint: DELETE /organizations/{organization} Args: organization: The name of the organization to delete (required) Returns: Success confirmation (HTTP 204 No Content) or error details See: docs/tools/organization_tools.md for usage examples
README
Terraform Cloud MCP Server
A Model Context Protocol (MCP) server that integrates AI assistants with the Terraform Cloud API, allowing you to manage your infrastructure through natural conversation. Built with Pydantic models and structured around domain-specific modules, this server is compatible with any MCP-supporting platform including Claude, Claude Code CLI, Claude Desktop, Cursor, Copilot Studio, and others.
Features
- Account Management: Get account details for authenticated users or service accounts.
- Workspace Management: Create, read, update, delete, lock/unlock workspaces.
- Run Management: Create runs, list runs, get run details, apply/discard/cancel runs.
- Plan Management: Retrieve plan details and JSON execution output with advanced HTTP redirect handling.
- Apply Management: Get apply details and recover from failed state uploads.
- Organization Management: List, create, update, delete organizations, and view organization entitlements.
- Future Features: Variables management, state versions, and more.
Quick Start
Prerequisites
- Python 3.12+
- MCP (includes FastMCP and development tools)
uv
package manager (recommended) orpip
- Terraform Cloud API token
Installation
# 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
# Install package
uv pip install .
Adding to Claude Environments
Adding to Claude Code CLI
# Add to Claude Code with your Terraform Cloud token
claude mcp add -e TFC_TOKEN=YOUR_TF_TOKEN -s user terraform-cloud-mcp -- "terraform-cloud-mcp"
Adding to Claude Desktop
Create a claude_desktop_config.json
configuration file:
- mac: ~/Library/Application Support/Claude/claude_desktop_config.json
- win: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"terraform-cloud-mcp": {
"command": "/path/to/uv", # Get this by running: `which uv`
"args": [
"--directory",
"/path/to/your/terraform-cloud-mcp", # Full path to this project
"run",
"terraform-cloud-mcp"
],
"env": {
"TFC_TOKEN": "my token..." # replace with actual token
}
}
}
}
Replace your_terraform_cloud_token
with your actual Terraform Cloud API token.
Other MCP-Compatible Platforms
For other platforms (like Cursor, Copilot Studio, or Glama), follow their platform-specific instructions for adding an MCP server. Most platforms require:
- The server path or command to start the server.
- Environment variables for the Terraform Cloud API token.
- Configuration to auto-start the server when needed.
Available Tools
Account Tools
get_account_details()
: Gets account information for the authenticated user or service account.
Workspace Management Tools
List & Search
list_workspaces(organization, page_number, page_size, search)
: List and filter workspaces.get_workspace_details(workspace_id, organization, workspace_name)
: Get detailed information about a specific workspace.
Create & Update
create_workspace(organization, name, params)
: Create a new workspace with optional parameters.update_workspace(organization, workspace_name, params)
: Update an existing workspace's configuration.
Delete
delete_workspace(organization, workspace_name)
: Delete a workspace and all its content.safe_delete_workspace(organization, workspace_name)
: Delete only if the workspace isn't managing any resources.
Lock & Unlock
lock_workspace(workspace_id, reason)
: Lock a workspace to prevent runs.unlock_workspace(workspace_id)
: Unlock a workspace to allow runs.force_unlock_workspace(workspace_id)
: Force unlock a workspace locked by another user.
<!-- Future implementation: Data Retention
set_data_retention_policy(workspace_id, days)
: Set a data retention policy.get_data_retention_policy(workspace_id)
: Get the current data retention policy.delete_data_retention_policy(workspace_id)
: Delete the data retention policy. -->
Run Management Tools
create_run(workspace_id, params)
: Create and queue a Terraform run in a workspace using its ID.list_runs_in_workspace(workspace_id, ...)
: List and filter runs in a specific workspace using its ID.list_runs_in_organization(organization, ...)
: List and filter runs across an entire organization.get_run_details(run_id)
: Get detailed information about a specific run.apply_run(run_id, comment)
: Apply a run waiting for confirmation.discard_run(run_id, comment)
: Discard a run waiting for confirmation.cancel_run(run_id, comment)
: Cancel a run currently planning or applying.force_cancel_run(run_id, comment)
: Forcefully cancel a run immediately.force_execute_run(run_id)
: Forcefully execute a pending run by canceling prior runs.
Plan Management Tools
get_plan_details(plan_id)
: Get detailed information about a specific plan.get_plan_json_output(plan_id)
: Retrieve the JSON execution plan for a specific plan with proper redirect handling.get_run_plan_json_output(run_id)
: Retrieve the JSON execution plan from a run with proper redirect handling.
Apply Management Tools
get_apply_details(apply_id)
: Get detailed information about a specific apply.get_errored_state(apply_id)
: Retrieve the errored state from a failed apply for recovery.
Organization Management Tools
get_organization_details(organization)
: Get detailed information about a specific organization.get_organization_entitlements(organization)
: Show entitlement set for organization features.list_organizations(page_number, page_size, query, query_email, query_name)
: List and filter organizations.create_organization(name, email, params)
: Create a new organization with optional parameters.update_organization(organization, params)
: Update an existing organization's settings.delete_organization(organization)
: Delete an organization and all its content.
Development Guide
For detailed development guidance including code standards, Pydantic patterns, and contribution workflows, see our Development Documentation.
Quick Development Setup
# 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
Basic Development Commands
# Run the server in development mode
mcp dev terraform_cloud_mcp/server.py
# Run tests and quality checks
uv run -m mypy .
uv run -m ruff check .
uv run -m black .
For detailed information on code organization, architecture, development workflows, and code quality guidelines, refer to docs/DEVELOPMENT.md.
Documentation
The codebase includes comprehensive documentation:
- Code Comments: Focused on explaining the "why" behind implementation decisions
- Docstrings: All public functions and classes include detailed docstrings
- Example Files: The
docs/
directory contains detailed examples for each domain:docs/DEVELOPMENT.md
: Development standards and coding guidelinesdocs/CONTRIBUTING.md
: Guidelines for contributing to the projectdocs/models/
: Usage examples for all model typesdocs/tools/
: Detailed usage examples for each tooldocs/conversations/
: Sample conversation flows with the API
Troubleshooting
- Check server logs (debug logging is enabled by default)
- Use the MCP Inspector (http://localhost:5173) for debugging
- Debug logging is already enabled in
server.py
:import logging logging.basicConfig(level=logging.DEBUG)
Contributing
Contributions are welcome! Please open an issue or pull request if you'd like to contribute to this project.
See our Contributing Guide for detailed instructions on how to get started, code quality standards, and the pull request process.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
AIO-MCP Server
🚀 All-in-one MCP server with AI search, RAG, and multi-service integrations (GitLab/Jira/Confluence/YouTube) for AI-enhanced development workflows. Folk from
React MCP
react-mcp integrates with Claude Desktop, enabling the creation and modification of React apps based on user prompts
Atlassian Integration
Model Context Protocol (MCP) server for Atlassian Cloud products (Confluence and Jira). This integration is designed specifically for Atlassian Cloud instances and does not support Atlassian Server or Data Center deployments.

Any OpenAI Compatible API Integrations
Integrate Claude with Any OpenAI SDK Compatible Chat Completion API - OpenAI, Perplexity, Groq, xAI, PyroPrompts and more.
Exa MCP
A Model Context Protocol server that enables AI assistants like Claude to perform real-time web searches using the Exa AI Search API in a safe and controlled manner.
MySQL Server
Allows AI assistants to list tables, read data, and execute SQL queries through a controlled interface, making database exploration and analysis safer and more structured.