Skip to content

Deedeo/terraform-mcp-server-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. Prerequisites
  2. Installation Steps
  3. Configuration
  4. Verification
  5. Usage

Prerequisites

Before you begin, ensure you have the following installed:

  1. Windows Subsystem for Linux (WSL)

  2. Docker Desktop

  3. Visual Studio Code

    • With the following extensions installed:
      • GitHub Copilot
      • GitHub Copilot Chat
      • Model Context Protocol (MCP)

Installation Steps

  1. Pull the Terraform MCP Server Image

    docker pull hashicorp/terraform-mcp-server

    Terraform MCP Server Image

  2. Enable GitHub Copilot and MCP

    • Open VS Code Settings
    • Verify GitHub Copilot is activated
    • Enable MCP extension

    GitHub Copilot Agent Enabled MCP Extension Enabled

Configuration

  1. 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.

Verification

  1. Start the MCP Server

    • Look for the start icon in VS Code Start MCP Server
  2. Verify Docker Container

    • Run the following command to check if the Terraform MCP container is running:
    docker ps

    Confirm MCP  Server container is up

  3. Check Available Functions

    • Click the tools icon in the GitHub Copilot chat section Tools Icon
    • You should see the list of available Terraform MCP functions MCP Functions

Usage

When using GitHub Copilot with the Terraform MCP server:

  1. 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
      

    Example Prompt

  2. 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

Additional Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages