Deedeo/terraform-mcp-server-setup
If you are the rightful owner of terraform-mcp-server-setup and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Model Context Protocol (MCP) server is a tool designed to facilitate the integration and management of various model-based applications, enhancing productivity and collaboration.
Getting Started with Terraform MCP Server Using GitHub Copilot
This guide will help you set up and use the Terraform Model Context Protocol (MCP) server with GitHub Copilot.
Table of Contents
Prerequisites
Before you begin, ensure you have the following installed:
-
Windows Subsystem for Linux (WSL)
- Required for running Linux-based containers on Windows
- Official WSL Installation Guide
-
Docker Desktop
- Required for running the Terraform MCP server container
- Download Docker Desktop
-
Visual Studio Code
- With the following extensions installed:
- GitHub Copilot
- GitHub Copilot Chat
- Model Context Protocol (MCP)
- With the following extensions installed:
Installation Steps
-
Pull the Terraform MCP Server Image
docker pull hashicorp/terraform-mcp-server
-
Enable GitHub Copilot and MCP
- Open VS Code Settings
- Verify GitHub Copilot is activated
- Enable MCP extension
Configuration
-
Create MCP Configuration File
- Create a new file at
.vscode/mcp.json
in your project root - Add the following configuration:
{ "servers": { "terraform": { "command": "docker", "args": [ "run", "-i", "--rm", "hashicorp/terraform-mcp-server" ] } } }
Note: This configuration activates MCP specifically for this project. For other use cases, refer to the official Terraform MCP documentation.
- Create a new file at
Verification
-
Start the MCP Server
- Look for the start icon in VS Code
- Look for the start icon in VS Code
-
Verify Docker Container
- Run the following command to check if the Terraform MCP container is running:
docker ps
-
Check Available Functions
- Click the tools icon in the GitHub Copilot chat section
- You should see the list of available Terraform MCP functions
- Click the tools icon in the GitHub Copilot chat section
Usage
When using GitHub Copilot with the Terraform MCP server:
-
Writing Prompts
- Be specific in your requirements
- Include relevant details about providers and resources
- Example prompt:
Using azure terraform provider, create a terraform template to provision a windows vm on azure
-
Best Practices
- Always specify the provider you want to use
- Include resource requirements clearly
- Review and validate generated configurations
- Test in a non-production environment first