-
Notifications
You must be signed in to change notification settings - Fork 96
Fixing port & host name, should fix #101, Fixing/chaning resources implementation #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this 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
totransport-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) {
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), | ||
}) | ||
} |
Copilot
AI
Jul 2, 2025
There was a problem hiding this comment.
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.
No description provided.