terraform-mcp-server
Allows managing Terraform modules and scaffolding Terraform configurations, including searching modules, retrieving module details, listing versions, generating configuration files, and fetching backend S3 settings.
Click on "Install 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., "@terraform-mcp-serverscaffold terraform config for the vpc module"
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.
terraform-mcp-server
MCP (Model Context Protocol) server para gestionar los módulos de Terraform de la organización en GitHub.
Este server expone tools que permiten a los agentes de IA buscar, inspeccionar y scaffoldear configuraciones de Terraform usando la librería de módulos privados de la organización (repos con el nombre terraform-aws-module-*).
Funcionalidades
search_modules — Lista y filtra los módulos de Terraform disponibles en la organización
get_module — Obtiene el detalle del módulo: README, variables, outputs y última versión
list_module_versions — Lista todos los tags de versión disponibles de un módulo
scaffold_terraform — Genera una configuración completa de Terraform usando un módulo
Related MCP server: Gread
Instalación
# Clona el repositorio
git clone https://github.com/<TuOrg>/terraform-mcp-server.git
cd terraform-mcp-server
# Instala con pip
pip install -e .
# O con uv
uv pip install -e .Variables de entorno
Variable | Obligatoria | Default | Descripción |
| Sí | — | Personal access token de GitHub con scope |
| Sí |
| Nombre de la organización de GitHub — el default es un placeholder, hay que definirla |
| No |
| Prefijo de los repos de módulos |
| No |
| Versión mínima de Terraform en las configuraciones generadas (1.10+ es necesario para el locking nativo de state en S3) |
| No |
| Rol IAM que asume el provider generado — el |
Uso
Arrancar el server
# Directamente
terraform-mcp-server
# O como módulo de Python
python -m terraform_mcp_server.serverConfiguración del cliente MCP
Agrégalo a la configuración de tu cliente MCP (por ejemplo, Claude Desktop, Kiro, etc.):
{
"mcpServers": {
"terraform-mcp-server": {
"command": "terraform-mcp-server",
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}O si lo ejecutas desde el código fuente con uv:
{
"mcpServers": {
"terraform-mcp-server": {
"command": "uv",
"args": ["run", "--directory", "/path/to/terraform-mcp-server", "terraform-mcp-server"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}Referencia de tools
search_modules
Busca los módulos de Terraform disponibles en la organización.
Parámetros:
query(str, opcional): filtra los módulos por nombre de servicio
Ejemplo de respuesta:
{
"count": 2,
"modules": [
{
"name": "terraform-aws-module-vpc",
"service_name": "vpc",
"description": "Terraform module for AWS VPC",
"last_updated": "2024-01-15T10:30:00Z",
"default_branch": "main"
}
]
}get_module
Obtiene información detallada de un módulo concreto.
Parámetros:
service_name(str, obligatorio): nombre del servicio (por ejemplo, "vpc", "ec2")
list_module_versions
Lista todas las versiones disponibles (tags git) de un módulo.
Parámetros:
service_name(str, obligatorio): nombre del servicio
scaffold_terraform
Genera una configuración completa de Terraform usando un módulo.
Parámetros:
service_name(str, obligatorio): nombre del serviciovariables(dict, opcional): valores de variables para precargar
Archivos generados:
versions.tf— Bloqueterraform(required_version, required_providers)providers.tf— Configuración del provider (region +assume_roleobligatorio sobreterraform-iac+ default_tags)variables.tf— Variables comunes + propias del móduloterraform.tfvars— Valores de las variables (con placeholders)main.tf— Llamada al módulooutputs.tf— Outputs del módulodata.tf— Placeholder de data sources
El bloque provider incluye siempre
assume_role.aws_account_ides una variable obligatoria (validada a 12 dígitos) y sin default — Terraform no se ejecuta hasta que se indique la cuenta propietaria del rolterraform-iac.
get_backend_config
Obtiene la configuración del backend S3 (bucket, key, region) según team, project y environment.
El bloque devuelto va en backend.tf (campo file de la respuesta).
Parámetros:
team(str, obligatorio): nombre del equipoproject(str, obligatorio): nombre del proyectoenvironment(str, obligatorio): environment (dev, staging, prod, ...)bucket(str, opcional): bucket indicado por el usuario — tiene prioridad sobreBACKEND_CONFIGregion(str, opcional): region indicada por el usuario — tiene prioridad sobreBACKEND_CONFIG
Normalmente resuelve desde la variable de entorno BACKEND_CONFIG (JSON con backends y
environment_mapping). Si no está definida, no falla: devuelve needs_user_input con la
pregunta que el agente debe hacer, para volver a llamarla con bucket y region.
{
"needs_user_input": true,
"missing": ["bucket", "region"],
"question_for_user": "¿En qué bucket de S3 y en qué region quieres guardar el state?"
}Desarrollo
# Instala las dependencias de desarrollo
pip install -e ".[dev]"
# Ejecuta en modo desarrollo
python -m terraform_mcp_server.serverConvención de nombres de los módulos
Los módulos siguen el patrón: terraform-aws-module-{service_name}
Ejemplos:
terraform-aws-module-vpc→ service_name:vpcterraform-aws-module-ec2→ service_name:ec2terraform-aws-module-rds→ service_name:rdsterraform-aws-module-s3→ service_name:s3
Licencia
MIT
Available Tools
5 toolsget_backend_configA
Obtiene la configuración del backend S3 de un proyecto Terraform.
Devuelve el bucket, la key, la region y la configuración de locking correctos según el team, el project y el environment. Normalmente se resuelve desde la variable de entorno BACKEND_CONFIG (string JSON).
Si BACKEND_CONFIG no está definida, esta tool devuelve needs_user_input:
pregunta al usuario el bucket y la region y vuelve a llamarla pasando esos
valores en bucket y region. Nunca generes el backend comentado ni con
placeholders.
Args: team: Nombre del equipo (por ejemplo, 'platform', 'backend', 'data'). project: Nombre del proyecto (por ejemplo, 'onboarding', 'payments'). environment: Environment (por ejemplo, 'dev', 'staging', 'prod'). bucket: Bucket de state indicado por el usuario. Tiene prioridad sobre BACKEND_CONFIG. region: Region del bucket indicada por el usuario. Tiene prioridad sobre BACKEND_CONFIG.
Returns:
Objeto JSON con la configuración completa del bloque backend "s3" y el
archivo destino (backend.tf).
| Name | Required | Description | Default |
|---|---|---|---|
| team | Yes | ||
| bucket | No | ||
| region | No | ||
| project | Yes | ||
| environment | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden and succeeds by disclosing the fallback behavior, the priority of bucket/region over the environment variable, and the rule to never generate commented-out or placeholder backends. It doesn't cover potential errors but provides essential behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with a purpose sentence, a behavior paragraph, and an Args list. It is moderately detailed but each sentence adds value, and the formatting aids scanning. Slightly longer than necessary but not padded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with 5 parameters, no annotations, and an interactive workflow, the description covers purpose, all parameters, the return value (JSON with backend block and destination file), and the fallback behavior. It is complete and leaves no major gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the Args section is critical. It explains each parameter with examples (team: 'platform', project: 'onboarding') and explicitly states that bucket/region take priority over BACKEND_CONFIG, fully compensating for the schema's lack of descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with 'Obtiene la configuración del backend S3 de un proyecto Terraform', a specific verb and resource. It clearly differentiates from sibling tools like search_modules and scaffold_terraform by focusing on backend S3 configuration.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear workflow guidance: if BACKEND_CONFIG is not defined, the tool returns `needs_user_input`, prompting the agent to ask the user for bucket/region and re-call with those values. It does not explicitly name alternatives, but the context is clear and actionable.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_moduleA
Obtiene información detallada de un módulo de Terraform concreto.
Recupera el README, variables.tf, outputs.tf y el último tag de versión del módulo identificado por su nombre de servicio.
Args: service_name: Nombre del servicio (por ejemplo, 'vpc', 'ec2'). El nombre del repo se construye como 'terraform-aws-module-{service_name}'.
Returns: Objeto JSON con el detalle del módulo: readme, variables, outputs y última versión.
| Name | Required | Description | Default |
|---|---|---|---|
| service_name | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It clearly discloses the returned data (readme, variables, outputs, last version) and the repo-name construction rule. It doesn't cover error cases or authentication, but it adds significant behavioral context beyond a bare 'get'.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The text is well-structured: a lead sentence, a short bullet list of retrieved items, an Args block, and a Returns block. It is concise with no redundant content; every sentence adds value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a one-parameter read operation with an output schema, the description explains purpose, parameter format, and return summary. It is complete enough for correct selection and invocation, especially given the output schema already specifies return structure.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has only service_name with 0% description coverage. The description compensates fully by providing examples ('vpc', 'ec2') and explaining the naming pattern 'terraform-aws-module-{service_name}', which is exactly the semantic needed for correct invocation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb+resource: 'Obtiene información detallada de un módulo de Terraform concreto.' It clearly lists the retrieved artifacts (README, variables.tf, outputs.tf, version tag) and is distinct from sibling tools like search_modules or list_module_versions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies use for fetching detailed module info, but it never explicitly contrasts with alternatives like list_module_versions or search_modules. Guidance on when to use this tool vs. siblings is only implicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_module_versionsA
Lista las versiones disponibles (tags git) de un módulo de Terraform.
Devuelve todos los tags ordenados por versión semántica descendente.
Args: service_name: Nombre del servicio (por ejemplo, 'vpc', 'ec2').
Returns: Objeto JSON con la lista de versiones.
| Name | Required | Description | Default |
|---|---|---|---|
| service_name | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are present, so the description is the sole source of behavioral information. It discloses the output format (JSON object) and sorting order (semantic version descending), but omits details such as authentication requirements or behavior when no tags exist. This is adequate but not rich.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with Args/Returns sections and is relatively concise. However, the opening sentence and the 'Devuelve todos los tags' line are somewhat redundant, costing a minor efficiency point.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple 1-parameter list tool, the description provides essential information: purpose, output format, and sorting. However, it lacks usage guidance and discussion of edge cases, making it not fully complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has no descriptions, and the description adds only a brief explanation with examples ('service_name: Nombre del servicio...'). This gives some context beyond the schema title but does not fully define the valid values or how the service name maps to a module.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool lists available versions (git tags) of a Terraform module, using a specific verb and resource. It also mentions sorting by semantic version, which distinguishes it from sibling tools like get_module or search_modules.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus the sibling tools. It doesn't mention any prerequisites, alternatives, or exclusions, so an agent would have to infer usage from the function name alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
scaffold_terraformA
Genera una configuración completa de Terraform usando un módulo de .
Crea la estructura de archivos estándar: versions.tf, providers.tf, variables.tf, terraform.tfvars, main.tf, outputs.tf y data.tf.
El provider generado siempre asume el rol IAM IAC_ROLE_NAME; las credenciales
estáticas no son una opción. Rellena aws_account_id en terraform.tfvars.
Args: service_name: Nombre del servicio (por ejemplo, 'vpc', 'ec2'). variables: Dict opcional de valores para precargar en terraform.tfvars.
Returns: Dict JSON con el nombre de archivo como key y su contenido como value.
| Name | Required | Description | Default |
|---|---|---|---|
| variables | No | ||
| service_name | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description discloses important behavioral traits: the provider always assumes IAM_ROLE_NAME, static credentials are not an option, and aws_account_id is filled automatically. It also documents the return format. However, it does not mention whether existing files are overwritten or if a module must already exist.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the core purpose, followed by a compact file list, IAM role constraint, and Args/Returns sections. Every sentence adds necessary context, and there is no filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a two-parameter tool with an output schema, the description covers file structure, IAM role behavior, and return format. It lacks edge cases like overwrite behavior or module existence prerequisites, but is otherwise adequate for a scaffolding task.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, but the description compensates by explaining service_name with an example and variables as an optional dict for preloading terraform.tfvars. Both parameters are covered, though the exact structure of variables could be more detailed.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb 'Genera' and identifies the resource as a complete Terraform configuration using a module. It enumerates the standard files created, making the tool's scope clear and distinguishing it from sibling read/search tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description makes the tool's function clear but provides no explicit guidance on when to use this tool versus alternatives like search_modules or get_module. Usage is implied rather than explicitly contrasted with sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_modulesA
Busca los módulos de Terraform disponibles en la organización de GitHub.
Lista los repos que coinciden con el prefijo 'terraform-aws-module-'. Si se pasa una query, los resultados se filtran además por el nombre del servicio.
Args: query: Filtro opcional para acotar los resultados por nombre de servicio.
Returns: Lista JSON de módulos con name, service_name, description, last_updated y default_branch.
| Name | Required | Description | Default |
|---|---|---|---|
| query | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full behavioral burden. It discloses the search prefix, optional query filtering, and the exact return fields. It doesn't mention authentication, rate limits, or pagination, but it's a read-only search operation and the behavior is reasonably transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured: a one-sentence purpose, a clarification of filtering, and explicit Args/Returns sections. Every sentence serves a purpose, and it's appropriately brief for a simple tool.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool has one optional parameter, an output schema, and clear context. The description explains the prefix, query behavior, and return fields, making it complete for an agent to understand what the tool does and what it returns.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has no description for the 'query' parameter and coverage is 0%. The description explicitly explains the parameter as an optional filter to narrow results by service name, fully compensating for the schema's lack of detail.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states that the tool searches for Terraform modules in a GitHub organization, listing repositories with the prefix 'terraform-aws-module-'. This specific verb+resource combination (search/list modules) distinguishes it from siblings like get_module or list_module_versions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explains the default behavior (list all matching prefix) and how an optional query filters by service name. It implies its role as the discovery tool among siblings, though it does not explicitly mention when not to use it or direct users to an alternative.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
Each tool targets a distinct resource and action: search_modules finds modules, list_module_versions lists versions, get_module retrieves details, scaffold_terraform generates config, and get_backend_config retrieves backend setup. No two tools overlap in purpose.
All tool names follow a consistent verb_noun snake_case pattern (search_modules, list_module_versions, get_module, scaffold_terraform, get_backend_config). The convention is uniform and predictable.
With 5 tools, the server is well-scoped for its purpose of discovering, inspecting, and scaffolding Terraform modules. Each tool serves a clear function without redundancy or overload.
The surface covers the core lifecycle of module discovery and usage: search, version listing, detail retrieval, scaffolding, and backend config. Missing operations like module creation/update or plan/apply are outside the apparent scope, so the gap is minor.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Unified API to query AWS, GCP, Azure and generate Terraform/CLI execution kits for AI agents.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Git-backed platform for skills, tools, and context for AI agents
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to manage GitHub repositories, branches, issues, pull requests, releases, and actions through natural language.1185MIT
- AlicenseNot gradedqualityBmaintenanceProvides AI agents with access to source code of all public GitHub repos, with integration for docs repos and compatibility with coding agents and MCP clients.61Apache 2.0
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to interact with GitHub via natural language, supporting repository management, issue tracking, file commits, and more.
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to automate GitHub repository management, issue tracking, and commits using natural language.10Apache 2.0
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/isma-aguilera/terraform-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server