Skip to main content
Glama

Terraform Registry MCP Server

by thrashr888

Terraform Registry MCP 服务器

模型上下文协议 (MCP) 服务器,提供与 Terraform Registry API 交互的工具。此服务器使 AI 代理能够查询提供商信息、资源详情和模块元数据。

安装

在光标处安装

要在Cursor中安装和使用此 MCP 服务器:

  1. 在 Cursor 中,打开设置 (⌘+,) 并导航到“MCP”选项卡。

  2. 点击“+ 添加新的 MCP 服务器”。

  3. 输入以下内容:

    • 名称:terraform-registry

    • 类型:命令

    • 命令:npx -y terraform-mcp-server

  4. 单击“添加”,然后滚动到服务器并单击“禁用”以启用该服务器。

  5. 如果需要,请重新启动 Cursor,以确保 MCP 服务器正确加载。

terraform-registry 光标的 MCP 设置

在 Claude Desktop 中安装

要在 Claude Desktop 中安装和使用此 MCP 服务器:

  1. 在 Claude Desktop 中,打开设置(⌘+,)并导航到“开发人员”选项卡。

  2. 单击窗口底部的“编辑配置”。

  3. 编辑文件( ~/Library/Application Support/Claude/claude_desktop_config.json )以添加以下代码,然后保存文件。

{ "mcpServers": { "terraform-registry": { "command": "npx", "args": ["-y", "terraform-mcp-server"] } } }
  1. 重新启动 Claude Desktop 以确保 MCP 服务器正确加载。

工具

此 MCP 服务器中提供以下工具:

核心注册表工具

工具

描述

providerDetails

获取有关 Terraform 提供商的详细信息

resourceUsage

获取 Terraform 资源和相关资源的示例用法

moduleSearch

根据查询搜索并推荐 Terraform 模块

listDataSources

列出提供商的所有可用数据源及其基本详细信息

resourceArgumentDetails

获取有关资源类型参数的全面详细信息

moduleDetails

检索 Terraform 模块的详细元数据

functionDetails

获取有关 Terraform 提供程序函数的详细信息

providerGuides

列出并查看特定于提供商的指南和文档

policySearch

在 Terraform Registry 中搜索策略库

policyDetails

获取特定策略库的详细信息

Terraform 云工具

这些工具需要 Terraform Cloud API 令牌( TFC_TOKEN ):

工具

描述

listOrganizations

列出经过身份验证的用户有权访问的所有组织

privateModuleSearch

搜索组织中的私有模块

privateModuleDetails

获取私有模块的详细信息

explorerQuery

查询 Terraform Cloud Explorer API 来分析数据

listWorkspaces

列出组织中的工作区

workspaceDetails

获取特定工作区的详细信息

lockWorkspace

锁定工作区以防止运行

unlockWorkspace

解锁工作区以允许运行

listRuns

列出工作区的运行

runDetails

获取有关特定运行的详细信息

createRun

为工作区创建新的运行

applyRun

应用已计划的运行

cancelRun

取消正在进行的运行

listWorkspaceResources

列出工作区中的资源

资源

MCP 服务器支持通过resources/*方法列出和读取以下资源 URI:

资源类型

示例 URI

描述

提供商

terraform:providers

列出所有命名空间/提供商

terraform:provider:<namespace>/<name>

获取特定提供商的详细信息

提供程序版本

terraform:provider:<namespace>/<name>/versions

列出提供商的可用版本

提供商资源

terraform:provider:<namespace>/<name>/resources

列出提供商的资源

terraform:resource:<namespace>/<name>/<resource_name>

获取特定资源类型的详细信息

提供商数据源

terraform:provider:<namespace>/<name>/dataSources

列出提供商的数据源

terraform:dataSource:<namespace>/<name>/<data_source_name>

获取特定数据源的详细信息

提供程序功能

terraform:provider:<namespace>/<name>/functions

列出提供商的功能

terraform:function:<namespace>/<name>/<function_name>

获取特定功能的详细信息

服务器还支持resources/templates/list来提供创建模板:

  • terraform:provider

  • terraform:resource

  • terraform:dataSource

提示

以下提示可用于生成上下文响应:

迅速的

描述

必需参数

migrate-clouds

生成 Terraform 代码以在云提供商之间迁移基础设施

sourceCloud

targetCloud

terraformCode

generate-resource-skeleton

帮助用户利用最佳实践快速搭建新的 Terraform 资源

resourceType

optimize-terraform-module

为改进 Terraform 代码提供可行的建议

terraformCode

migrate-provider-version

协助提供商版本升级和重大变更

providerName

currentVersion

targetVersion

terraformCode

(可选)

analyze-workspace-runs

分析最近的运行失败并为 Terraform Cloud 工作区提供故障排除指导

workspaceId

runsToAnalyze

(可选,默认值:5)

提示的已知问题

注意getPrompt功能存在一个已知问题,可能导致服务器崩溃。服务器可以正确注册提示并列出它们,但使用getPrompt方法直接发出请求可能会导致连接问题。该问题正在调查中,可能与 SDK 兼容性或实现细节有关。在问题解决之前,请使用listPrompts查看可用的提示,但避免直接调用getPrompt

运行服务器

服务器使用 stdio 传输进行 MCP 通信:

npm install npm start

使用环境变量进行配置

可以使用环境变量来配置服务器:

环境变量

描述

默认值

TERRAFORM_REGISTRY_URL

Terraform Registry API 的基本 URL

https://registry.terraform.io

DEFAULT_PROVIDER_NAMESPACE

提供商的默认命名空间

哈希公司

LOG_LEVEL

日志级别(错误、警告、信息、调试)

信息

REQUEST_TIMEOUT_MS

API 请求超时(以毫秒为单位)

10000

RATE_LIMIT_ENABLED

启用 API 请求速率限制

错误的

RATE_LIMIT_REQUESTS

时间窗口内允许的请求数

60

RATE_LIMIT_WINDOW_MS

速率限制的时间窗口(以毫秒为单位)

60000

TFC_TOKEN

用于私有注册表访问的 Terraform Cloud API 令牌(可选)

环境变量的使用示例:

# Set environment variables export LOG_LEVEL="debug" export REQUEST_TIMEOUT_MS="15000" export TFC_TOKEN="your-terraform-cloud-token" # Run the server npm start

测试

有关测试该项目的信息,请参阅TESTS.md文件。

Deploy Server
A
security – no known vulnerabilities
-
license - not tested
A
quality - confirmed to work

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

通过 MCP 将 AI 模型连接到 Terraform Registry,从而实现提供商查找、资源使用示例和模块推荐,以简化 Terraform 工作流程。

  1. 安装
    1. 在光标处安装
    2. 在 Claude Desktop 中安装
  2. 工具
    1. 核心注册表工具
    2. Terraform 云工具
  3. 资源
    1. 提示
      1. 提示的已知问题
    2. 运行服务器
      1. 使用环境变量进行配置
    3. 测试

      Related MCP Servers

      • A
        security
        -
        license
        A
        quality
        Enables AI assistants to interact with Confluence Cloud for managing spaces, pages, and content via the Model Context Protocol (MCP).
        Last updated -
        11
        15
      • -
        security
        -
        license
        -
        quality
        🌍 Terraform Model Context Protocol (MCP) Tool - An experimental CLI tool that enables AI assistants to manage and operate Terraform environments. Supports reading Terraform configurations, analyzing plans, applying configurations, and managing state with Claude Desktop integration. ⚡️
        Last updated -
        342
        MIT License
        • Apple
      • -
        security
        -
        license
        -
        quality
        Enables connections to Azure AI Agents within any MCP client, allowing users to leverage Azure AI Foundry's models and knowledge tools like Azure AI Search and Bing Web Grounding through a conversational interface.
        Last updated -
        207
        MIT License
        • Linux
        • Apple
      • A
        security
        -
        license
        A
        quality
        A powerful gateway for the Model Context Protocol (MCP) that unifies AI toolchains by federating multiple MCP servers, wrapping REST APIs as MCP tools, and supporting multiple transport methods with an admin dashboard.
        Last updated -
        1
        • Apple

      View all related MCP servers

      MCP directory API

      We provide all the information about MCP servers via our MCP API.

      curl -X GET 'https://glama.ai/api/mcp/v1/servers/thrashr888/terraform-mcp-server'

      If you have feedback or need assistance with the MCP directory API, please join our Discord server