Skip to content

Commit 6dc5a41

Browse files
chore: sync from internal
1 parent f0988d1 commit 6dc5a41

4 files changed

Lines changed: 42 additions & 6 deletions

File tree

packages/mcp-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@phantom/mcp-server",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "MCP Server for Phantom Wallet",
55
"repository": {
66
"type": "git",

packages/mcp-server/src/server.test.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ describe("PhantomMCPServer", () => {
419419
expect(toolHandler).toHaveBeenCalledTimes(1);
420420
});
421421

422-
it("does not retry mutating tools after a successful token refresh", async () => {
422+
it("does not retry mutating tools after a successful token refresh and asks the caller to retry", async () => {
423423
const toolHandler = jest.fn().mockRejectedValue({ response: { status: 401 } });
424424
mockGetTool.mockReturnValue({
425425
name: "mock_tool",
@@ -438,8 +438,25 @@ describe("PhantomMCPServer", () => {
438438
const parsed = JSON.parse(result.content[0].text);
439439

440440
expect(mockSessionManagerInstance.tryRefreshSession).toHaveBeenCalledTimes(1);
441-
expect(mockSessionManagerInstance.resetSession).toHaveBeenCalledTimes(1);
441+
expect(mockSessionManagerInstance.resetSession).not.toHaveBeenCalled();
442442
expect(toolHandler).toHaveBeenCalledTimes(1);
443-
expect(parsed.code).toBe("AUTH_EXPIRED");
443+
expect(result).toEqual({
444+
content: [
445+
{
446+
type: "text",
447+
text: JSON.stringify(
448+
{
449+
error:
450+
"Session token was refreshed successfully. Retry the same request now; re-authentication is not required.",
451+
code: "SESSION_REFRESHED_RETRY_REQUIRED",
452+
},
453+
null,
454+
2,
455+
),
456+
},
457+
],
458+
isError: true,
459+
});
460+
expect(parsed.code).toBe("SESSION_REFRESHED_RETRY_REQUIRED");
444461
});
445462
});

packages/mcp-server/src/server.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,26 @@ export class PhantomMCPServer {
307307
this.logger.warn(`Tool retry also returned 401 — resetting session`);
308308
}
309309
} else if (refreshed) {
310-
this.logger.warn(`Token refreshed but ${toolName} is not safe to replay automatically — resetting session`);
310+
this.logger.info(
311+
`Token refreshed but ${toolName} is not safe to replay automatically — asking caller to retry`,
312+
);
313+
return {
314+
content: [
315+
{
316+
type: "text" as const,
317+
text: JSON.stringify(
318+
{
319+
error:
320+
"Session token was refreshed successfully. Retry the same request now; re-authentication is not required.",
321+
code: "SESSION_REFRESHED_RETRY_REQUIRED",
322+
},
323+
null,
324+
2,
325+
),
326+
},
327+
],
328+
isError: true,
329+
};
311330
}
312331

313332
this.logger.warn(`Token refresh failed or retry 401'd — resetting session`);

packages/phantom-openclaw-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@phantom/phantom-openclaw-plugin",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Phantom Embedded Wallet — sign transactions, transfer tokens, and swap on Solana and Ethereum. Powered by Phantom.",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)