mcp-terraform-ls
An MCP server that wraps terraform-ls to provide Terraform language intelligence as MCP tools, enabling AI assistants to understand and navigate Terraform codebases.
README
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/releases
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>.tgz
Or 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>.tgz
Replace <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 link
Usage 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 |
|---|---|
terraform_hover |
Get documentation/type info for a symbol at a position |
terraform_definition |
Go to definition of a symbol |
terraform_references |
Find all references to a symbol |
terraform_completion |
Get completions at a position |
terraform_diagnostics |
Get diagnostics (errors/warnings) for a file |
terraform_document_symbols |
List all symbols in a file |
terraform_format |
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 mode
License
MIT
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.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.