A Model Context Protocol (MCP) server that provides tools for interacting with the Terraform Registry API. This server enables AI agents to query provider information, resource details, module metadata, and generate example configurations.
Looks up Terraform provider details by name, returning the latest version and version count.
Input:
{
"provider": "aws",
"namespace": "hashicorp"
}
Output:
{
"content": [
{
"type": "text",
"text": "Provider hashicorp/aws: latest version is 5.0.0 (out of 150 versions)."
}
]
}
Gets example usage of a Terraform resource and related resources.
Input:
{
"provider": "aws",
"resource": "aws_instance"
}
Output:
{
"content": [
{
"type": "text",
"text": "Example usage for aws_instance:\n```terraform\n[example code]\n```\nRelated resources: aws_vpc, aws_subnet"
}
]
}
Searches for and recommends Terraform modules based on a query.
Input:
{
"query": "vpc",
"provider": "aws"
}
Output:
{
"content": [
{
"type": "text",
"text": "Recommended modules for \"vpc\":\n1. terraform-aws-modules/vpc (aws) - AWS VPC Terraform module\n..."
}
]
}
Retrieves available data source identifiers for a given Terraform provider.
Input:
{
"provider": "aws",
"namespace": "hashicorp"
}
Output:
{
"content": [{
"type": "text",
"text": {
"data_sources": ["aws_ami", "aws_instance", "aws_vpc", ...]
}
}]
}
Retrieves full schema details of a provider, including resource and data source schemas.
Input:
{
"provider": "aws",
"namespace": "hashicorp"
}
Output:
{
"content": [{
"type": "text",
"text": {
"provider_schema": {
"provider_schemas": { ... },
"resource_schemas": { ... },
"data_source_schemas": { ... }
}
}
}]
}
Fetches details about a specific resource type's arguments.
Input:
{
"provider": "aws",
"namespace": "hashicorp",
"resource": "aws_instance"
}
Output:
{
"content": [{
"type": "text",
"text": {
"arguments": [
{
"name": "ami",
"type": "string",
"description": "AMI ID to use for the instance.",
"required": true
},
...
]
}
}]
}
Retrieves detailed metadata for a Terraform module.
Input:
{
"namespace": "terraform-aws-modules",
"module": "vpc",
"provider": "aws"
}
Output:
{
"content": [{
"type": "text",
"text": {
"versions": ["5.0.0", "4.0.0", ...],
"inputs": [
{
"name": "region",
"description": "AWS region to deploy into.",
"default": "us-east-1"
},
...
],
"outputs": [
{
"name": "vpc_id",
"description": "ID of the VPC created."
},
...
],
"dependencies": []
}
}]
}
Generates a minimal Terraform configuration for a given provider and resource.
Input:
{
"provider": "aws",
"namespace": "hashicorp",
"resource": "aws_instance"
}
Output:
{
"content": [
{
"type": "text",
"text": {
"example_configuration": "resource \"aws_instance\" \"example\" {\n ami = \"example\"\n instance_type = \"example\"\n}\n"
}
}
]
}
The server runs using stdio transport for MCP communication:
npm install
npm start
The server is built using TypeScript and uses the MCP SDK for server implementation. It makes HTTP requests to the Terraform Registry API to fetch data.
To add new tools:
- Define the input interface
- Add the tool to the tools array
- Implement the tool handler in the switch statement
- Update this README with the new tool's documentation