mcp-terraform-ls
Integrates with Terraform language intelligence, enabling AI assistants to navigate, understand, and manipulate Terraform codebases through tools like hover, definition, references, completion, diagnostics, document symbols, and formatting.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-terraform-lsshow diagnostics for main.tf"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-terraform-ls
An MCP (Model Context Protocol) server that wraps terraform-ls, exposing Terraform language intelligence as MCP tools. This enables AI assistants like Claude Code to understand and navigate Terraform codebases.
Prerequisites
Node.js >= 20
terraform-ls installed
Install terraform-ls:
# macOS
brew install hashicorp/tap/terraform-ls
# Or download from https://github.com/hashicorp/terraform-ls/releasesRelated MCP server: MCP SysOperator
Installation
From GitHub Releases
Download the latest .tgz package from the releases page and install it globally:
npm install -g https://github.com/alexsavio/mcp-terraform-ls/releases/latest/download/mcp-terraform-ls-<version>.tgzOr download the tarball first and install locally:
# Download
curl -LO https://github.com/alexsavio/mcp-terraform-ls/releases/latest/download/mcp-terraform-ls-<version>.tgz
# Install globally
npm install -g mcp-terraform-ls-<version>.tgzReplace <version> with the actual version number (e.g., 2026.3.0).
From source
git clone https://github.com/alexsavio/mcp-terraform-ls.git
cd mcp-terraform-ls
npm install
npm run build
npm linkUsage with Claude Code
Add to your project's .mcp.json:
{
"mcpServers": {
"terraform": {
"command": "npx",
"args": ["-y", "mcp-terraform-ls"]
}
}
}If you installed from a GitHub Release, you can reference the binary directly:
{
"mcpServers": {
"terraform": {
"command": "mcp-terraform-ls"
}
}
}Optionally set the TERRAFORM_LS_PATH environment variable if terraform-ls is not on your PATH.
Available Tools
Tool | Description |
| Get documentation/type info for a symbol at a position |
| Go to definition of a symbol |
| Find all references to a symbol |
| Get completions at a position |
| Get diagnostics (errors/warnings) for a file |
| List all symbols in a file |
| Format a Terraform file |
Tool Parameters
Position-based tools (hover, definition, references, completion):
file— absolute path to the.tffileline— line number (1-based)character— column number (1-based)
File-based tools (diagnostics, document_symbols, format):
file— absolute path to the.tffile
How It Works
This server acts as a bridge between MCP (used by AI assistants) and LSP (used by terraform-ls):
Receives MCP tool calls from the AI assistant
Manages a terraform-ls subprocess via stdio
Translates MCP requests into LSP JSON-RPC calls
Returns formatted results back through MCP
The LSP client lazily initializes terraform-ls on the first tool call, using the file's directory as the workspace root.
Development
npm install
npm run build
npm run dev # watch modeLicense
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.
MCP server for AI dialogue using various LLM models via AceDataCloud
Related MCP Servers
- AlicenseBqualityCmaintenanceAn MCP server that supercharges AI assistants with powerful tools for software development, enabling research, planning, code generation, and project scaffolding through natural language interaction.1141 npm103MIT
- AlicenseCqualityNot gradedmaintenanceAn MCP server for Infrastructure as Code that enables AI assistants to manage cloud resources through Ansible and Terraform operations. It supports executing playbooks, managing AWS services, and running Terraform commands with optional LocalStack integration.18-
- AlicenseNot gradedqualityCmaintenanceA secure, containerized MCP server that enables AI assistants to manage Terraform infrastructure using integrated Language Server Protocol (LSP) tools. It facilitates safe operations like initialization, validation, and planning while providing context-aware code completion and documentation.10MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for managing Terraform infrastructure as code, enabling initialization, planning, applying, destroying, validating, and showing state of Terraform configurations.1MIT