Tools reference
The Terraform MCP Server exposes 3 core tools covering sandboxed Terraform CLI execution, vector similarity search across provider documentation, and multi-format documentation ingestion.
| Tool | Category | Description |
|---|---|---|
terraform_execute | Execution | Execute whitelisted Terraform commands (init, validate, plan, apply, destroy) inside validated working directories |
terraform_doc_search | Semantic Search | Query Neo4j HNSW vector indexes for Terraform provider resource schemas, data sources, and best practices |
ingest_terraform_docs | Ingestion | Parse, chunk, embed, and store Terraform provider documentation into Neo4j |
1. terraform_execute
Runs whitelisted Terraform CLI commands with directory traversal protection, variable injection scanning, timeout enforcement, and ANSI output sanitization.
Supported subcommands
| Command | Behavior | Auto-Approve Flag |
|---|---|---|
init | Initializes the working directory and downloads provider plugins | No |
validate | Validates HCL syntax and internal resource consistency | No |
plan | Generates an execution plan previewing resource additions, changes, and deletions | No |
apply | Applies the planned infrastructure changes | Yes (-auto-approve) |
destroy | Destroys managed infrastructure in the working directory | Yes (-auto-approve) |
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
command | string | Yes | — | Terraform subcommand (init, plan, validate, apply, destroy) |
working_directory | string | Yes | — | Absolute path to the directory containing .tf files |
variables | dict[str, str] | No | None | Key-value pairs passed as -var arguments (max 100 keys) |
aws_region | string | No | None | Optional AWS region override (AWS_DEFAULT_REGION) |
strip_ansi | boolean | No | True | Strip ANSI escape sequences from stdout/stderr |
timeout | integer | No | 300 | Command execution timeout in seconds (1–1800) |
Response structure
{
"success": true,
"data": {
"command": "terraform plan",
"status": "success",
"result": {
"return_code": 0,
"stdout": "Terraform will perform the following actions...",
"stderr": "",
"execution_time": 2.45
},
"metadata": {
"terraform_version": "1.9.5",
"aws_region": "us-west-2",
"variables_count": 2,
"security_checks_passed": true
}
}
}
2. terraform_doc_search
Performs semantic similarity search over ingested Terraform documentation using Neo4j HNSW vector indexes and cosine similarity scoring.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query | string | Yes | — | Natural language or resource schema search query (1–1000 characters) |
top_k | integer | No | 5 | Maximum number of chunks to return (1–50) |
similarity_threshold | float | No | 0.7 | Minimum cosine similarity score (0.0–1.0) |
node_types | list[str] | No | None | Filter by document node type: resource, data_source, best_practice |
Indexed node types
| Node Type | Neo4j HNSW Index | Contents |
|---|---|---|
resource | docchunk_resource_embedding_hnsw | Provider resource arguments, nested blocks, and attribute exports |
data_source | docchunk_datasource_embedding_hnsw | Provider data source lookup schemas and filter blocks |
best_practice | docchunk_bestpractice_embedding_hnsw | Architecture patterns, state management guidelines, and security baselines |
Response structure
{
"success": true,
"data": {
"query": "AWS S3 bucket server-side encryption configuration",
"results_count": 3,
"results": [
{
"content": "resource \"aws_s3_bucket_server_side_encryption_configuration\" \"example\" {...}",
"similarity_score": 0.91,
"node_type": "resource",
"id": "docchunk_s3_sse_001"
}
],
"search_parameters": {
"top_k": 5,
"similarity_threshold": 0.7
}
}
}
3. ingest_terraform_docs
Ingests Markdown, HTML, or PDF Terraform provider documentation into the Neo4j knowledge graph with semantic chunking and vector embedding generation.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
filter_types | list[str] | Yes | — | Document types to ingest: resource, data_source, terraform, best_practice, readme |
filter_services | list[str] | No | None | Optional cloud service filter (for example, ["EC2", "S3", "VPC"]) |
scan_dirs | list[str] | No | ["docs/"] | Local filesystem directories to scan for documentation files |
Response structure
{
"success": true,
"data": {
"ingestion_summary": {
"total_documents": 150,
"successful": 148,
"failed": 2,
"skipped": 0
},
"types_processed": ["resource", "data_source"],
"chunks_created": 1250,
"embeddings_generated": 1250
}
}