Skip to main content

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.

ToolCategoryDescription
terraform_executeExecutionExecute whitelisted Terraform commands (init, validate, plan, apply, destroy) inside validated working directories
terraform_doc_searchSemantic SearchQuery Neo4j HNSW vector indexes for Terraform provider resource schemas, data sources, and best practices
ingest_terraform_docsIngestionParse, 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​

CommandBehaviorAuto-Approve Flag
initInitializes the working directory and downloads provider pluginsNo
validateValidates HCL syntax and internal resource consistencyNo
planGenerates an execution plan previewing resource additions, changes, and deletionsNo
applyApplies the planned infrastructure changesYes (-auto-approve)
destroyDestroys managed infrastructure in the working directoryYes (-auto-approve)

Parameters​

ParameterTypeRequiredDefaultDescription
commandstringYes—Terraform subcommand (init, plan, validate, apply, destroy)
working_directorystringYes—Absolute path to the directory containing .tf files
variablesdict[str, str]NoNoneKey-value pairs passed as -var arguments (max 100 keys)
aws_regionstringNoNoneOptional AWS region override (AWS_DEFAULT_REGION)
strip_ansibooleanNoTrueStrip ANSI escape sequences from stdout/stderr
timeoutintegerNo300Command 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
}
}
}

Performs semantic similarity search over ingested Terraform documentation using Neo4j HNSW vector indexes and cosine similarity scoring.

Parameters​

ParameterTypeRequiredDefaultDescription
querystringYes—Natural language or resource schema search query (1–1000 characters)
top_kintegerNo5Maximum number of chunks to return (1–50)
similarity_thresholdfloatNo0.7Minimum cosine similarity score (0.0–1.0)
node_typeslist[str]NoNoneFilter by document node type: resource, data_source, best_practice

Indexed node types​

Node TypeNeo4j HNSW IndexContents
resourcedocchunk_resource_embedding_hnswProvider resource arguments, nested blocks, and attribute exports
data_sourcedocchunk_datasource_embedding_hnswProvider data source lookup schemas and filter blocks
best_practicedocchunk_bestpractice_embedding_hnswArchitecture 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​

ParameterTypeRequiredDefaultDescription
filter_typeslist[str]Yes—Document types to ingest: resource, data_source, terraform, best_practice, readme
filter_serviceslist[str]NoNoneOptional cloud service filter (for example, ["EC2", "S3", "VPC"])
scan_dirslist[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
}
}