fix(cloud): preserve posthog-local MCP server across session refresh#2318
Draft
VojtechBartos wants to merge 1 commit into
Draft
fix(cloud): preserve posthog-local MCP server across session refresh#2318VojtechBartos wants to merge 1 commit into
VojtechBartos wants to merge 1 commit into
Conversation
The cloud agent-server's pre-prompt TTL refresh calls refresh_session with only the external MCP servers from the request. refreshSession then rebuilt options.mcpServers from that set alone, dropping the in-process posthog-local server installed at createSession time. Once dropped, mcp__posthog-local__git_signed_commit no longer existed and the model fell back to plain `git commit` — which the cloud PreToolUse guard blocks. Stash the local-tools MCP server on Session and re-merge it during refresh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The cloud agent-server's pre-prompt TTL refresh calls
refresh_sessionwith only the external MCP servers from the request.ClaudeAcpAgent.refreshSessionthen rebuiltoptions.mcpServersfrom that set alone — dropping the in-processposthog-localMCP server installed at session creation.Once dropped,
mcp__posthog-local__git_signed_commitno longer existed and the model fell back to plaingit commit— which the cloud PreToolUse guard blocks.The fix stashes the local-tools MCP server instance on
Sessionat creation time and re-merges it duringrefreshSession, so the rebuilt query keeps the same in-process server (handler still resolves the GH token lazily, per #2313).Repro
Observed in a cloud task ("add vojta to posthog readme and create a PR"):
mcp__posthog-local__git_signed_commit— 0 matches,total_deferred_tools: 20.Error: No such tool available: mcp__posthog-local__git_signed_commit.git commit, which is blocked by the cloud PreToolUse guard / sandbox git shim.Test plan
pnpm --filter agent typecheck— cleanpnpm --filter agent test— all 446 tests passclaude-agent.refresh.test.ts:re-attaches the in-process posthog-local MCP serveromits posthog-local when none was registered at session creationgit_signed_commitremains callable after a pre-prompt TTL refresh.