feat: Add get_run_logs tool to retrieve Terraform run logs #240
+207
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a new MCP tool
get_run_logsthat enables users to fetch plan and apply logs from Terraform Cloud/Enterprise runs.Features
Changes
pkg/tools/tfe/get_run_logs.gowith main implementationpkg/tools/tfe/get_run_logs_test.gowith unit testspkg/tools/dynamic_tool.goCHANGELOG.mdwith new feature documentationTesting
PCI Review Checklist
I have documented a clear reason for, and description of, the change I am making.
Reason: The MCP server currently lacks the ability to read logs from Terraform runs. This feature adds a new tool
get_run_logsto retrieve plan and apply logs, enhancing debugging capabilities and providing better visibility into Terraform operations.If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
Revert Plan: Simple revert of the PR. The feature is additive and doesn't modify existing functionality. To revert, simply revert the commit or remove the three new files and undo the registration in dynamic_tool.go.
If applicable, I've documented the impact of any changes to security controls.
Security Impact: None. The tool is read-only and uses existing TFE client authentication. It follows the same security patterns as other read-only tools like
get_run_details. No new authentication mechanisms or security controls are introduced.Related Issues
Addresses the need for log visibility when running Terraform operations through the MCP server. This is particularly useful for debugging failed plans/applies and understanding what happened during a run.