Token导航 LogoToken导航TokenDH.com
Fcp Terraform logo
运维云端未说明官方级别未说明来源级核验

Fcp Terraform

MCP Server

fcp-terraform是一个通过意图级命令生成Terraform HCL配置的MCP服务器,允许LLM通过描述基础设施意图来构建Terraform配置,并将其渲染为有效的HCL。

工具数

4

提示词数

0

GitHub Stars

0

资源数

0
基础设施即代码Go云端部署

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

os-tack

提供方

os-tack

最后核验

2026/5/17 20:23

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

fcp地形

MCP服务器,用于通过意图级命令生成Terraform HCL。

它的作用

fcp-terraform允许LLM通过描述基础设施意图(资源、数据源、变量、输出)来构建terraform配置,并将其呈现为有效的HCL。LLM不编写原始HCL语法,而是发送以下操作 add resource aws_instance web ami:"ami-0c55b159" instance_type:t2.micro fcp-terraform管理语义模型、依赖图和序列化。建立在 FCP 框架。

使用HashiCorp的Go编写 hclwrite 用于原生HCL AST生成的库——无需字符串连接或模板呈现。

快速示例

terraform_session('new "Main Infrastructure"')

terraform([
  'add resource aws_instance web ami:"ami-0c55b159" instance_type:t2.micro',
  'add resource aws_s3_bucket assets bucket:"my-assets"',
  'add variable region default:"us-east-1" type:string',
  'add output instance_ip value:"aws_instance.web.public_ip"',
])

terraform_query('plan')

plan 查询产生:

variable "region" {
  type    = string
  default = "us-east-1"
}

resource "aws_instance" "web" {
  ami           = "ami-0c55b159"
  instance_type = "t2.micro"
}

resource "aws_s3_bucket" "assets" {
  bucket = "my-assets"
}

output "instance_ip" {
  value = aws_instance.web.public_ip
}

可用的MCP工具

工具目的
terraform(ops)批量突变——添加、设置、删除、连接、嵌套、标签、样式
terraform_query(q)检查配置——映射、列表、描述、计划、图表、验证、查找
terraform_session(action)生命周期——新建、打开、保存、检查点、撤消、重做
terraform_help()完整参考卡

动词引用

动词语法
add resourceadd resource TYPE LABEL [key:value...]
add provideradd provider PROVIDER [region:R] [key:value...]
add variableadd variable NAME [type:T] [default:V] [description:D]
add outputadd output NAME value:EXPR [description:D]
add dataadd data TYPE LABEL [key:value...]
add moduleadd module LABEL source:PATH [key:value...]
connectconnect SRC -> TGT [label:TEXT]
setset LABEL key:value [key:value...]
nestnest LABEL BLOCK_TYPE[/CHILD_TYPE] [key:value...]
removeremove LABELremove @SELECTOR
labellabel OLD_LABEL "new_label"
stylestyle LABEL tags:"Key=Val,Key2=Val2"

选择器

@type:aws_instance      All resources of a given type
@provider:aws            All blocks from a given provider
@kind:resource           All blocks of kind (resource, variable, output, data)
@tag:KEY or @tag:KEY=VAL Blocks matching a tag
@all                     All blocks

安装

去安装

go install github.com/os-tack/fcp-terraform/cmd/fcp-terraform@latest

GitHub 发布

从下载预构建的二进制文件 发布 并把 fcp-terraform 在你的路上。

MCP客户端配置

{
  "mcpServers": {
    "fcp-terraform": {
      "command": "fcp-terraform"
    }
  }
}

建筑

cmd/fcp-terraform/main.go     MCP server — 4 tools, stdio transport
        │
internal/terraform/            Domain layer
  ├── model.go                 Semantic model (blocks, attributes, connections)
  ├── adapter.go               FCP adapter (dispatch ops → handlers)
  ├── handlers.go              Verb handlers (add, set, remove, nest, etc.)
  ├── queries.go               Query dispatcher (plan, graph, describe, etc.)
  ├── selectors.go             @type, @provider, @kind, @tag, @all
  ├── values.go                Attribute type inference, hclwrite value generation
  ├── verb_specs.go            Verb specifications and reference card sections
  ├── block_ref.go             Terraform reference detection
  └── index.go                 Label index for O(1) lookups
        │
internal/fcpcore/              Shared FCP framework (Go port)
  ├── tokenizer.go             DSL tokenizer
  ├── parsed_op.go             Operation parser
  ├── verb_registry.go         Verb spec registry + reference card generator
  ├── event_log.go             Event sourcing (undo/redo)
  ├── session.go               Session lifecycle (new, open, save, checkpoint)
  └── formatter.go             Response formatter

HCL代使用HashiCorp的 hclwrite 用于本地AST操作的软件包。从资源类型前缀自动检测提供程序(aws_, google_, azurerm_).

示例:AWS生产Web堆栈

一个真实的部署,显示操作是如何组合的。此示例创建了一个包含子网、EC2、RDS、S3、IAM和安全组的VPC,总共13个资源。

terraform_session('new "Acme Corp Web Stack"')

# Provider + Variables
terraform([
  'add provider aws region:us-east-1',
  'add variable environment type:string default:"production" description:"Deployment environment"',
  'add variable project_name type:string default:"acme-web" description:"Project name"',
  'add variable vpc_cidr type:string default:"10.0.0.0/16" description:"VPC CIDR block"',
  'add variable instance_type type:string default:"t3.medium" description:"EC2 instance type"',
  'add variable db_instance_class type:string default:"db.t3.medium" description:"RDS instance class"',
])

# Networking
terraform([
  'add resource aws_vpc main cidr_block:var.vpc_cidr enable_dns_support:true enable_dns_hostnames:true',
  'add resource aws_subnet public_a vpc_id:aws_vpc.main.id cidr_block:"10.0.1.0/24" map_public_ip_on_launch:true',
  'add resource aws_subnet public_b vpc_id:aws_vpc.main.id cidr_block:"10.0.2.0/24" map_public_ip_on_launch:true',
  'add resource aws_internet_gateway igw vpc_id:aws_vpc.main.id',
  'add resource aws_route_table public vpc_id:aws_vpc.main.id',
])

# Nested blocks for route table and security groups
terraform([
  'nest public route cidr_block:"0.0.0.0/0" gateway_id:aws_internet_gateway.igw.id',
  'add resource aws_security_group web name:"${var.project_name}-web-sg" vpc_id:aws_vpc.main.id',
  'nest web ingress from_port:80 to_port:80 protocol:"tcp"',
  'nest web ingress from_port:443 to_port:443 protocol:"tcp"',
  'nest web egress from_port:0 to_port:0 protocol:"-1"',
])

# Compute + Database
terraform([
  'add resource aws_instance webserver ami:"ami-0c55b159" instance_type:var.instance_type subnet_id:aws_subnet.public_a.id',
  'nest webserver root_block_device volume_size:20 volume_type:"gp3"',
  'add resource aws_db_subnet_group dbsubnet name:"${var.project_name}-db-subnet"',
  'set dbsubnet subnet_ids:"[aws_subnet.public_a.id,aws_subnet.public_b.id]"',
  'add resource aws_db_instance rds engine:"postgresql" instance_class:var.db_instance_class allocated_storage:20',
  'add resource aws_s3_bucket assets bucket:"${var.project_name}-assets-${var.environment}"',
])

# Outputs
terraform([
  'add output vpc_id value:aws_vpc.main.id',
  'add output web_ip value:aws_instance.webserver.public_ip',
  'add output db_endpoint value:aws_db_instance.rds.endpoint',
])

# Tags (all resources at once)
terraform([
  'style main tags:"Name=${var.project_name}-vpc,Environment=${var.environment}"',
  'style public_a tags:"Name=${var.project_name}-public-a,Environment=${var.environment}"',
  'style public_b tags:"Name=${var.project_name}-public-b,Environment=${var.environment}"',
  'style igw tags:"Name=${var.project_name}-igw,Environment=${var.environment}"',
  'style webserver tags:"Name=${var.project_name}-web,Environment=${var.environment}"',
  'style rds tags:"Name=${var.project_name}-db,Environment=${var.environment}"',
  'style assets tags:"Name=${var.project_name}-assets,Environment=${var.environment}"',
])

# Day-2 modifications
terraform([
  'label webserver app_server',                         # Rename
  'set instance_type default:"t3.large"',               # Change default
  'remove assets',                                       # Replace S3 bucket
  'add resource aws_s3_bucket static_assets bucket:"${var.project_name}-static-${var.environment}"',
])

terraform_query('plan')  # Export final HCL

发展

go test ./...                        # Run all tests
go build ./cmd/fcp-terraform         # Build binary

许可证

麻省理工学院

目录标签

目录标签

基础设施即代码Go云端部署Terraform本地部署HCL生成LLM集成自动化配置

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

session

工具数量(toolCount,工具数)

4

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明session部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP