Skip to content

Persist last-used workspace selection across MCP session reconnects #18

@akornenvironmental

Description

@akornenvironmental

The problem

The Render MCP server holds workspace selection in session-only memory. Every time the MCP client reconnects (a common occurrence in Claude Code: /login, /compact, fresh session resume, MCP server restart), the selection is lost and tools that need a workspace fail with no workspace set.

This is related to but distinct from #16 (which is about discoverability of the select_workspace tool). This issue is about persistence after the tool has been used: even when the LLM correctly calls select_workspace, the selection vanishes the next time the MCP client connects, and the LLM has to be prompted again to find and re-call select_workspace.

Reproduction (Claude Code)

  1. Open a session in Claude Code, call any Render tool — it fails with no workspace set
  2. Call list_workspaces, then select_workspace(ownerID=...) — works
  3. /login, /compact, or quit and resume the session (claude --continue)
  4. Call any Render tool — fails again with no workspace set

For users with one workspace, the auto-select-on-list behavior masks the issue partially, but tools that need a workspace before list_workspaces is called still fail. For users with multiple workspaces, every reconnect requires re-prompting.

Proposed fix

Persist the last-used workspace to a small per-user state file (e.g. ~/.render-mcp/state.json) keyed by the API key (or its hash). On connect, hydrate the in-memory workspace from that file. On select_workspace, write it back.

Alternative, lower-risk: persist on the server side keyed by API key. The MCP server already authenticates with the bearer token; treat the API key as the principal and store last-selected workspace per-key in Render's backend. This avoids client-side state files entirely and makes the selection follow the API key wherever it's used.

Why this matters

In long-running Claude Code sessions (which is the dominant use case), this causes constant friction. Users either:

  • Get prompted to "pick a workspace" multiple times per session
  • Have the LLM silently fail Render tools and burn turns figuring out why
  • End up writing brittle SessionStart hooks to pre-call list_workspaces

Persisting the selection is the right fix and would close most of the workspace-related papercuts at once.

Environment

  • Claude Code (Sonnet 4.6 / Opus 4.7)
  • Render MCP server (hosted at mcp.render.com/mcp)
  • HTTP transport with Bearer auth
  • Single workspace (tea-d3tp...)

Happy to test a fix on the hosted endpoint if you want a guinea pig.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions