You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/tools/preview-style-tool/PreviewStyleTool.schema.ts
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,11 @@ import { z } from 'zod';
2
2
3
3
exportconstPreviewStyleSchema=z.object({
4
4
styleId: z.string().describe('Style ID to preview'),
5
+
accessToken: z
6
+
.string()
7
+
.describe(
8
+
'Mapbox public access token (required, must start with pk.* and have styles:read permission). Secret tokens (sk.*) cannot be used as they cannot be exposed in browser URLs. Please use an existing public token or get one from list_tokens_tool or create one with create_token_tool with styles:read permission.'
thrownewError('Failed to retrieve public tokens');
33
-
}
34
-
35
-
// Extract tokens from the response
36
-
constfirstContent=tokensResult.content[0];
37
-
if(firstContent.type!=='text'){
38
-
thrownewError('Unexpected response format from list tokens');
39
-
}
40
-
consttokensData=JSON.parse(firstContent.text);
41
-
constpublicTokens=tokensData.tokens;
42
-
43
-
if(!publicTokens||publicTokens.length===0){
20
+
// Validate that the provided token is a public token
21
+
if(!input.accessToken.startsWith('pk.')){
44
22
thrownewError(
45
-
'No public tokens found. Please create a public token first.'
23
+
'Invalid access token. Only public tokens (starting with pk.*) are allowed for preview URLs. Secret tokens (sk.*) cannot be used as they cannot be exposed in browser URLs.'
0 commit comments