From 539894168612053306f6bcfef4771f1240d344c1 Mon Sep 17 00:00:00 2001 From: Mofei Zhu <13761509829@163.com> Date: Wed, 3 Sep 2025 11:04:57 +0300 Subject: [PATCH 1/3] fix preview style can not get token in the hosted version --- src/tools/create-token-tool/CreateTokenTool.ts | 4 ---- src/tools/list-tokens-tool/ListTokensTool.ts | 4 ---- src/tools/preview-style-tool/PreviewStyleTool.ts | 5 +++-- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/tools/create-token-tool/CreateTokenTool.ts b/src/tools/create-token-tool/CreateTokenTool.ts index a7342e8..8ecc6ba 100644 --- a/src/tools/create-token-tool/CreateTokenTool.ts +++ b/src/tools/create-token-tool/CreateTokenTool.ts @@ -20,10 +20,6 @@ export class CreateTokenTool extends MapboxApiBasedTool< input: CreateTokenInput, accessToken?: string ): Promise<{ type: 'text'; text: string }> { - if (!accessToken) { - throw new Error('MAPBOX_ACCESS_TOKEN is not set'); - } - const username = MapboxApiBasedTool.getUserNameFromToken(accessToken); this.log( diff --git a/src/tools/list-tokens-tool/ListTokensTool.ts b/src/tools/list-tokens-tool/ListTokensTool.ts index 03dd8d2..94718d6 100644 --- a/src/tools/list-tokens-tool/ListTokensTool.ts +++ b/src/tools/list-tokens-tool/ListTokensTool.ts @@ -16,10 +16,6 @@ export class ListTokensTool extends MapboxApiBasedTool< input: ListTokensInput, accessToken?: string ): Promise<{ type: 'text'; text: string }> { - if (!accessToken) { - throw new Error('MAPBOX_ACCESS_TOKEN is not set'); - } - const username = MapboxApiBasedTool.getUserNameFromToken(accessToken); this.log( diff --git a/src/tools/preview-style-tool/PreviewStyleTool.ts b/src/tools/preview-style-tool/PreviewStyleTool.ts index 20b5814..6cd27b0 100644 --- a/src/tools/preview-style-tool/PreviewStyleTool.ts +++ b/src/tools/preview-style-tool/PreviewStyleTool.ts @@ -17,9 +17,10 @@ export class PreviewStyleTool extends MapboxApiBasedTool< } protected async execute( - input: PreviewStyleInput + input: PreviewStyleInput, + accessToken?: string ): Promise<{ type: 'text'; text: string }> { - const username = MapboxApiBasedTool.getUserNameFromToken(); + const username = MapboxApiBasedTool.getUserNameFromToken(accessToken); // Get list of tokens to find a public token const listTokensTool = new ListTokensTool(); From d335f0792f86c57f38573d7cdc67ef9e4eb9c67e Mon Sep 17 00:00:00 2001 From: Mofei Zhu <13761509829@163.com> Date: Wed, 3 Sep 2025 11:08:23 +0300 Subject: [PATCH 2/3] fix preview style can not get token in the hosted version --- src/tools/list-tokens-tool/ListTokensTool.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tools/list-tokens-tool/ListTokensTool.ts b/src/tools/list-tokens-tool/ListTokensTool.ts index 94718d6..fba2300 100644 --- a/src/tools/list-tokens-tool/ListTokensTool.ts +++ b/src/tools/list-tokens-tool/ListTokensTool.ts @@ -16,6 +16,10 @@ export class ListTokensTool extends MapboxApiBasedTool< input: ListTokensInput, accessToken?: string ): Promise<{ type: 'text'; text: string }> { + if (!accessToken) { + throw new Error('Access token is required'); + } + const username = MapboxApiBasedTool.getUserNameFromToken(accessToken); this.log( From 90c23e7f887fa575df06795fa5539c2b6bc4fc25 Mon Sep 17 00:00:00 2001 From: Mofei Zhu <13761509829@163.com> Date: Wed, 3 Sep 2025 11:11:32 +0300 Subject: [PATCH 3/3] fix preview style can not get token in the hosted version --- src/tools/list-tokens-tool/ListTokensTool.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/list-tokens-tool/ListTokensTool.ts b/src/tools/list-tokens-tool/ListTokensTool.ts index fba2300..03dd8d2 100644 --- a/src/tools/list-tokens-tool/ListTokensTool.ts +++ b/src/tools/list-tokens-tool/ListTokensTool.ts @@ -17,7 +17,7 @@ export class ListTokensTool extends MapboxApiBasedTool< accessToken?: string ): Promise<{ type: 'text'; text: string }> { if (!accessToken) { - throw new Error('Access token is required'); + throw new Error('MAPBOX_ACCESS_TOKEN is not set'); } const username = MapboxApiBasedTool.getUserNameFromToken(accessToken);