Skip to content

Conversation

@ankitpro
Copy link

Description

This PR adds a new MCP tool get_run_logs that enables users to fetch plan and apply logs from Terraform Cloud/Enterprise runs.

Features

  • Retrieve plan logs, apply logs, or both from a run
  • Optional metadata including run status, timestamps, and version info
  • Proper error handling for runs without available logs
  • Read-only, non-destructive operation

Changes

  • Added pkg/tools/tfe/get_run_logs.go with main implementation
  • Added pkg/tools/tfe/get_run_logs_test.go with unit tests
  • Registered new tool in pkg/tools/dynamic_tool.go
  • Updated CHANGELOG.md with new feature documentation

Testing

  • ✅ All unit tests pass
  • ✅ New tool test passes
  • ✅ No linter errors

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_logs to 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.

@ankitpro ankitpro requested a review from a team as a code owner December 12, 2025 06:09
@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Dec 12, 2025

CLA assistant check
All committers have signed the CLA.

This commit adds a new MCP tool 'get_run_logs' that enables users to fetch
plan and apply logs from Terraform Cloud/Enterprise runs.

Features:
- Retrieve plan logs, apply logs, or both from a run
- Optional metadata including run status, timestamps, and version info
- Proper error handling for runs without available logs
- Read-only, non-destructive operation

Changes:
- Added pkg/tools/tfe/get_run_logs.go with main implementation
- Added pkg/tools/tfe/get_run_logs_test.go with unit tests
- Registered new tool in pkg/tools/dynamic_tool.go
- Updated CHANGELOG.md with new feature documentation

The tool uses the go-tfe library's Plans.Logs() and Applies.Logs() methods
to fetch log data and returns it in a structured JSON format.
@ankitpro ankitpro force-pushed the feature/add-get-run-logs-tool branch from e76eced to b565683 Compare December 12, 2025 06:15
@jrhouston jrhouston requested a review from Copilot January 5, 2026 16:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new MCP tool get_run_logs that enables users to retrieve plan and apply logs from Terraform Cloud/Enterprise runs, enhancing debugging capabilities for Terraform operations.

Key changes:

  • New read-only tool for fetching Terraform run logs (plan, apply, or both)
  • Optional metadata support including run status, timestamps, and version information
  • Comprehensive unit tests for the new functionality

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/tools/tfe/get_run_logs.go Core implementation of the get_run_logs tool with plan/apply log fetching logic
pkg/tools/tfe/get_run_logs_test.go Unit tests verifying tool creation, annotations, and schema properties
pkg/tools/dynamic_tool.go Registration of the new get_run_logs tool in the dynamic tool registry
CHANGELOG.md Documentation of the new get_run_logs feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant