Skip to content

Conversation

gautambaghel
Copy link
Member

No description provided.

@gautambaghel gautambaghel requested review from Copilot and mukeshjc July 2, 2025 02:00
Copilot

This comment was marked as outdated.

@gautambaghel gautambaghel requested a review from Copilot July 2, 2025 02:08
Copy link
Contributor

@Copilot 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 refactors Terraform MCP server resources and renames HTTP transport configuration flags/env variables to fix #101.

  • Adds two new resources: Terraform Style Guide and Module Development Guide endpoints.
  • Renames flags and environment variables from host/port/MODE to transport-host/transport-port/TRANSPORT_MODE.
  • Updates e2e tests and documentation to use the new names.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/hashicorp/tfregistry/resources.go Implements style guide and module dev guide resources
e2e/e2e_test.go Updates Docker run flags for HTTP transport in end-to-end tests
cmd/terraform-mcp-server/main.go Renames flag retrieval and log messages
cmd/terraform-mcp-server/init.go Updates CLI flags for transport-host/transport-port
README.md Updates environment variable names and CLI usage examples
Comments suppressed due to low confidence (3)

cmd/terraform-mcp-server/main.go:68

  • The error message refers to "streamableHTTP port" while the flag is named --transport-port. Update the log text to use "transport port" for consistency.
				stdlog.Fatal("Failed to get streamableHTTP port:", err)

e2e/e2e_test.go:22

  • The test suite doesn’t validate the new /terraform/style-guide and /terraform/module-development endpoints. Add end-to-end tests for those routes to ensure correct behavior.
func TestE2E(t *testing.T) {

pkg/hashicorp/tfregistry/resources.go:18

  • The original provider resource registrations were removed, which disables the official and partner provider endpoints. Consider re-adding or migrating them to ensure existing provider functionality remains available.
func RegisterResources(hcServer *server.MCPServer, registryClient *http.Client, logger *log.Logger) {

Comment on lines +82 to 101
for _, u := range urls {
resp, err := httpClient.Get(u.URL)
if err != nil {
return nil, logAndReturnError(logger, fmt.Sprintf("Provider Resource: error with provider template handler %s/%s provider version %s details", namespace, name, versionNumber), err)
return nil, logAndReturnError(logger, fmt.Sprintf("Error fetching %s markdown", u.Name), err)
}
resourceContents[i] = mcp.TextResourceContents{
MIMEType: "text/markdown",
URI: providerVersionUri,
Text: fmt.Sprintf("# %s Provider \n\n %s", provider["name"], providerDocs),
if resp.StatusCode != http.StatusOK {
resp.Body.Close()
return nil, logAndReturnError(logger, fmt.Sprintf("Non-200 response fetching %s markdown", u.Name), fmt.Errorf("status: %s", resp.Status))
}
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, logAndReturnError(logger, fmt.Sprintf("Error reading %s markdown", u.Name), err)
}
contents = append(contents, mcp.TextResourceContents{
MIMEType: "text/markdown",
URI: fmt.Sprintf("%s/%s", resourceURI, u.Name),
Text: string(body),
})
}
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

Fetching each markdown file sequentially can increase latency. Consider performing HTTP GETs in parallel or caching responses to improve performance.

Copilot uses AI. Check for mistakes.

@gautambaghel gautambaghel merged commit 7efd187 into main Jul 3, 2025
31 checks passed
@gautambaghel gautambaghel deleted the fix/resources branch July 3, 2025 02:49
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.

2 participants