Skip to content

[Official SDK Migration] Make the official go-sdk server the default - #582

Open
Shweta-Deshpande wants to merge 4 commits into
mainfrom
TFECO-13108
Open

Shweta-Deshpande wants to merge 4 commits into
mainfrom
TFECO-13108

Conversation

@Shweta-Deshpande

Copy link
Copy Markdown
Collaborator

What

The server now runs on the official MCP Go SDK by default, for both stdio and
streamable HTTP. The old mark3labs server is still there as a fallback.

Why

This is the "Default server to the new SDK implementation" step of the SDK
migration. It has to land before the mark3labs code can be removed.

Changes

  • New mcpofficial.Enabled(). The SDK server is used unless
    TF_X_OFFICIAL_SDK_ENABLED is set to false. Unset, empty or misspelled
    values keep the SDK server, so a typo can't silently pick the old one.
  • Stdio and HTTP both use it. On HTTP the SDK server answers on /mcp. The old
    /mcp/official path still works as an alias.
  • The SDK server reports the name terraform-mcp-server, same as the old one.
  • Tools that need a Terraform token are hidden from tools/list when the
    request has no token, same as the old server. Calling one still returns the
    normal "no token" error.
  • e2e, hcpt and workflows now test the SDK server by default, with the old
    server as the second matrix entry. Makefile: test-e2e-legacy replaces
    test-e2e-official-public-registry.
  • Added an env var row in the README.

Rollback

Set TF_X_OFFICIAL_SDK_ENABLED=false and restart. The server logs a warning
at startup when the fallback is active. The fallback is temporary.

What users may notice

  • Tool responses that used a JSON:API envelope are now flat JSON.
  • Hand-written HTTP clients must send Accept: application/json, text/event-stream.
  • list_stacks with no match returns an empty list, not an error.

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

Comment thread .github/workflows/hcpt_test.yml Outdated
- name: Start server
env:
ENABLE_TF_OPERATIONS: true
TF_MCP_ENDPOINT: http://localhost:8080/mcp

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nitpick: The test step still references the removed matrix.endpoint, so both jobs end up connecting to http://localhost:8080 instead of /mcp. It also doesn't receive TF_X_OFFICIAL_SDK_ENABLED, which causes officialEndpoint() to classify the legacy matrix entry as official.

Could we set both environment variables on the Run tests against HCPT step?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah good catch. Done.

Comment thread e2e/cors_e2e_test.go Outdated
Comment on lines 61 to 62
// CORS checks use the legacy endpoint because the raw initializer is
// currently compatible with that endpoint only.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The CORS test now runs against the official SDK, but its direct HTTP requests are missing the required Accept header. This makes the server return HTTP 400 and is causing CI to fail.

Could we add Accept: application/json, text/event-stream to both the initialization request and the follow-up tool request?

Inside initializeMCPSession, near line 262, add the header after Content-Type:

req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json, text/event-stream")

then, inside testCORSMode, near line 173, add the same header:

req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json, text/event-stream")

Also the outdated comment about using only the legacy endpoint should also be updated to something:
// Run the CORS checks against the server selected for this test run.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done. Also added checks to read JSON payload of a response that is either plain JSON (mark3labs) or a single SSE message with a "data:" line (go-sdk)

This branch has not been deployed

No deployments
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