Repository navigation
Conversation
li-xiu-qi
requested review from
MelodyVAR,
Uking-xxx,
ZouR-Ma and
liuedcson
as code owners
October 24, 2026 06:48
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.
Fixes #146
Problem
When two Step processes simultaneously save OAuth tokens for different MCP servers, both read the full
.credentials.json, modify their own keys, and overwrite the file. If both processes read the same stale snapshot before writing, the later writer overwrites the earlier writer's keys, causing entries that belonged to other servers to disappear from the file. The correct behavior requires that when one process saves its own key, all keys already written by other processes must also be preserved.Changes
saveTokenscall sites inpackages/coding-agent/src/step/mcp-oauth.tsinto a singlesaveCredentialTokensimplementation.proper-lockfiledependency. Token saves acquire the lock asynchronously with a 30-second bounded wait and a 60-second stale window, so slow writes do not block the UI and a live lock cannot be stolen during that wait. Lock acquisition failure still fails closed without writing. The same lock covers logout, preventing deletion and save from overwriting each other.randomUUIDto the temporary file used when publishing.credentials.jsonto eliminate collision, and clean up that file on write or rename failure while preserving the original error.Behavior and compatibility
saveTokensnow returns a Promise, which the MCP SDK already awaits.logoutMcpServerkeeps its synchronous signature, while the JSON data format, configuration keys, and persisted credential shape are unchanged.rename. No data migration is required.Validation
packages/coding-agent/test/step-mcp-oauth.test.tsandpackages/coding-agent/test/fixtures/mcp-oauth-save-tokens-child.ts. A deliberate file barrier forces two real operating system processes to read the identical stale snapshot before writing, verifying that tokens for both target servers survive the race.packages/coding-agentusing:NODE_ENV=development npx -y pnpm@9.15.9 exec vitest --run test/step-mcp-oauth.test.tsCI=true NODE_ENV=development npx -y pnpm@9.15.9 run checkran from the repository root: passed.ab638295536ab0a78a35b4d24e163f91fe1ef95b.Limitations
None.