@mapbox/mcp-server 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +100 -14
  2. package/dist/commonjs/cli.d.ts.map +1 -1
  3. package/dist/commonjs/cli.js +5 -2
  4. package/dist/commonjs/cli.js.map +1 -1
  5. package/dist/commonjs/resources/resourceRegistry.d.ts +1 -2
  6. package/dist/commonjs/resources/resourceRegistry.d.ts.map +1 -1
  7. package/dist/commonjs/resources/resourceRegistry.js +0 -2
  8. package/dist/commonjs/resources/resourceRegistry.js.map +1 -1
  9. package/dist/commonjs/resources/ui-apps/mapAppHtml.d.ts +3 -3
  10. package/dist/commonjs/resources/ui-apps/mapAppHtml.d.ts.map +1 -1
  11. package/dist/commonjs/resources/ui-apps/mapAppHtml.js +18 -4
  12. package/dist/commonjs/resources/ui-apps/mapAppHtml.js.map +1 -1
  13. package/dist/commonjs/tools/directions-tool/DirectionsTool.d.ts +16 -0
  14. package/dist/commonjs/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
  15. package/dist/commonjs/tools/directions-tool/DirectionsTool.js +105 -1
  16. package/dist/commonjs/tools/directions-tool/DirectionsTool.js.map +1 -1
  17. package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.d.ts.map +1 -1
  18. package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.input.schema.js +1 -1
  19. package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.input.schema.js.map +1 -1
  20. package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.js +7 -3
  21. package/dist/commonjs/tools/place-details-tool/PlaceDetailsTool.js.map +1 -1
  22. package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.d.ts.map +1 -1
  23. package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.js +2 -0
  24. package/dist/commonjs/tools/search-and-geocode-tool/SearchAndGeocodeTool.js.map +1 -1
  25. package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
  26. package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.input.schema.d.ts +3 -3
  27. package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.input.schema.d.ts.map +1 -1
  28. package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.input.schema.js +16 -2
  29. package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.input.schema.js.map +1 -1
  30. package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.js +15 -4
  31. package/dist/commonjs/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
  32. package/dist/commonjs/utils/index.d.ts +2 -0
  33. package/dist/commonjs/utils/index.d.ts.map +1 -1
  34. package/dist/commonjs/utils/index.js +8 -1
  35. package/dist/commonjs/utils/index.js.map +1 -1
  36. package/dist/commonjs/utils/redactToken.d.ts +3 -0
  37. package/dist/commonjs/utils/redactToken.d.ts.map +1 -0
  38. package/dist/commonjs/utils/redactToken.js +55 -0
  39. package/dist/commonjs/utils/redactToken.js.map +1 -0
  40. package/dist/commonjs/utils/redactingSpanExporter.d.ts +24 -0
  41. package/dist/commonjs/utils/redactingSpanExporter.d.ts.map +1 -0
  42. package/dist/commonjs/utils/redactingSpanExporter.js +97 -0
  43. package/dist/commonjs/utils/redactingSpanExporter.js.map +1 -0
  44. package/dist/commonjs/utils/tracing.d.ts.map +1 -1
  45. package/dist/commonjs/utils/tracing.js +4 -1
  46. package/dist/commonjs/utils/tracing.js.map +1 -1
  47. package/dist/commonjs/utils/urlSafety.d.ts +23 -7
  48. package/dist/commonjs/utils/urlSafety.d.ts.map +1 -1
  49. package/dist/commonjs/utils/urlSafety.js +84 -66
  50. package/dist/commonjs/utils/urlSafety.js.map +1 -1
  51. package/dist/commonjs/version.json +3 -3
  52. package/dist/esm/cli.d.ts.map +1 -1
  53. package/dist/esm/cli.js +5 -2
  54. package/dist/esm/cli.js.map +1 -1
  55. package/dist/esm/resources/resourceRegistry.d.ts +1 -2
  56. package/dist/esm/resources/resourceRegistry.d.ts.map +1 -1
  57. package/dist/esm/resources/resourceRegistry.js +0 -2
  58. package/dist/esm/resources/resourceRegistry.js.map +1 -1
  59. package/dist/esm/resources/ui-apps/mapAppHtml.d.ts +3 -3
  60. package/dist/esm/resources/ui-apps/mapAppHtml.d.ts.map +1 -1
  61. package/dist/esm/resources/ui-apps/mapAppHtml.js +18 -4
  62. package/dist/esm/resources/ui-apps/mapAppHtml.js.map +1 -1
  63. package/dist/esm/tools/directions-tool/DirectionsTool.d.ts +16 -0
  64. package/dist/esm/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
  65. package/dist/esm/tools/directions-tool/DirectionsTool.js +105 -1
  66. package/dist/esm/tools/directions-tool/DirectionsTool.js.map +1 -1
  67. package/dist/esm/tools/place-details-tool/PlaceDetailsTool.d.ts.map +1 -1
  68. package/dist/esm/tools/place-details-tool/PlaceDetailsTool.input.schema.js +1 -1
  69. package/dist/esm/tools/place-details-tool/PlaceDetailsTool.input.schema.js.map +1 -1
  70. package/dist/esm/tools/place-details-tool/PlaceDetailsTool.js +7 -3
  71. package/dist/esm/tools/place-details-tool/PlaceDetailsTool.js.map +1 -1
  72. package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.d.ts.map +1 -1
  73. package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.js +2 -0
  74. package/dist/esm/tools/search-and-geocode-tool/SearchAndGeocodeTool.js.map +1 -1
  75. package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
  76. package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.input.schema.d.ts +3 -3
  77. package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.input.schema.d.ts.map +1 -1
  78. package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.input.schema.js +17 -3
  79. package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.input.schema.js.map +1 -1
  80. package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.js +15 -4
  81. package/dist/esm/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
  82. package/dist/esm/utils/index.d.ts +2 -0
  83. package/dist/esm/utils/index.d.ts.map +1 -1
  84. package/dist/esm/utils/index.js +5 -0
  85. package/dist/esm/utils/index.js.map +1 -1
  86. package/dist/esm/utils/redactToken.d.ts +3 -0
  87. package/dist/esm/utils/redactToken.d.ts.map +1 -0
  88. package/dist/esm/utils/redactToken.js +52 -0
  89. package/dist/esm/utils/redactToken.js.map +1 -0
  90. package/dist/esm/utils/redactingSpanExporter.d.ts +24 -0
  91. package/dist/esm/utils/redactingSpanExporter.d.ts.map +1 -0
  92. package/dist/esm/utils/redactingSpanExporter.js +93 -0
  93. package/dist/esm/utils/redactingSpanExporter.js.map +1 -0
  94. package/dist/esm/utils/tracing.d.ts.map +1 -1
  95. package/dist/esm/utils/tracing.js +4 -1
  96. package/dist/esm/utils/tracing.js.map +1 -1
  97. package/dist/esm/utils/urlSafety.d.ts +23 -7
  98. package/dist/esm/utils/urlSafety.d.ts.map +1 -1
  99. package/dist/esm/utils/urlSafety.js +80 -66
  100. package/dist/esm/utils/urlSafety.js.map +1 -1
  101. package/dist/esm/version.json +3 -3
  102. package/package.json +2 -1
  103. package/dist/commonjs/resources/ui-apps/StaticMapUIResource.d.ts +0 -15
  104. package/dist/commonjs/resources/ui-apps/StaticMapUIResource.d.ts.map +0 -1
  105. package/dist/commonjs/resources/ui-apps/StaticMapUIResource.js +0 -262
  106. package/dist/commonjs/resources/ui-apps/StaticMapUIResource.js.map +0 -1
  107. package/dist/esm/resources/ui-apps/StaticMapUIResource.d.ts +0 -15
  108. package/dist/esm/resources/ui-apps/StaticMapUIResource.d.ts.map +0 -1
  109. package/dist/esm/resources/ui-apps/StaticMapUIResource.js +0 -258
  110. package/dist/esm/resources/ui-apps/StaticMapUIResource.js.map +0 -1
@@ -1,15 +0,0 @@
1
- import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
2
- import type { ReadResourceResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
3
- import { BaseResource } from '../BaseResource.js';
4
- /**
5
- * Serves UI App HTML for Static Map Preview
6
- * Implements MCP Apps pattern with ui:// scheme
7
- */
8
- export declare class StaticMapUIResource extends BaseResource {
9
- readonly name = "Static Map Preview UI";
10
- readonly uri = "ui://mapbox/static-map/index.html";
11
- readonly description = "Interactive UI for previewing static map images (MCP Apps)";
12
- readonly mimeType = "text/html;profile=mcp-app";
13
- read(_uri: string, _extra?: RequestHandlerExtra<ServerRequest, ServerNotification>): Promise<ReadResourceResult>;
14
- }
15
- //# sourceMappingURL=StaticMapUIResource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StaticMapUIResource.d.ts","sourceRoot":"","sources":["../../../../src/resources/ui-apps/StaticMapUIResource.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACd,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;IACnD,QAAQ,CAAC,IAAI,2BAA2B;IACxC,QAAQ,CAAC,GAAG,uCAAuC;IACnD,QAAQ,CAAC,WAAW,gEAC2C;IAC/D,QAAQ,CAAC,QAAQ,+BAAsB;IAEjC,IAAI,CAER,IAAI,EAAE,MAAM,EAEZ,MAAM,CAAC,EAAE,mBAAmB,CAAC,aAAa,EAAE,kBAAkB,CAAC,GAC9D,OAAO,CAAC,kBAAkB,CAAC;CAgP/B"}
@@ -1,258 +0,0 @@
1
- // Copyright (c) Mapbox, Inc.
2
- // Licensed under the MIT License.
3
- import { RESOURCE_MIME_TYPE } from '@modelcontextprotocol/ext-apps/server';
4
- import { BaseResource } from '../BaseResource.js';
5
- /**
6
- * Serves UI App HTML for Static Map Preview
7
- * Implements MCP Apps pattern with ui:// scheme
8
- */
9
- export class StaticMapUIResource extends BaseResource {
10
- name = 'Static Map Preview UI';
11
- uri = 'ui://mapbox/static-map/index.html';
12
- description = 'Interactive UI for previewing static map images (MCP Apps)';
13
- mimeType = RESOURCE_MIME_TYPE;
14
- async read(
15
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
- _uri,
17
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
18
- _extra) {
19
- // Generate HTML for static map visualization with MCP Apps protocol support
20
- const html = `<!DOCTYPE html>
21
- <html>
22
- <head>
23
- <meta charset="UTF-8">
24
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
25
- <title>Static Map Preview</title>
26
- <style>
27
- * { margin: 0; padding: 0; box-sizing: border-box; }
28
- body {
29
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
30
- background: #000;
31
- }
32
- #toolbar {
33
- display: none;
34
- align-items: center;
35
- justify-content: flex-end;
36
- padding: 6px 10px;
37
- background: rgba(0, 0, 0, 0.7);
38
- gap: 8px;
39
- }
40
- #toolbar.visible { display: flex; }
41
- #fullscreen-btn {
42
- background: rgba(255, 255, 255, 0.15);
43
- border: 1px solid rgba(255, 255, 255, 0.3);
44
- color: #fff;
45
- padding: 4px 12px;
46
- border-radius: 4px;
47
- cursor: pointer;
48
- font-size: 12px;
49
- }
50
- #fullscreen-btn:hover { background: rgba(255, 255, 255, 0.25); }
51
- #image-container {
52
- position: relative;
53
- }
54
- #preview-image {
55
- display: none;
56
- max-width: 100%;
57
- width: 100%;
58
- cursor: zoom-in;
59
- }
60
- #preview-image.zoomed {
61
- cursor: zoom-out;
62
- max-width: none;
63
- width: auto;
64
- }
65
- #loading {
66
- padding: 20px;
67
- color: #fff;
68
- font-size: 16px;
69
- }
70
- #error {
71
- padding: 20px;
72
- color: #ff6b6b;
73
- text-align: center;
74
- }
75
- </style>
76
- </head>
77
- <body>
78
- <div id="toolbar">
79
- <button id="fullscreen-btn">⛶ Fullscreen</button>
80
- </div>
81
- <div id="image-container">
82
- <div id="loading">Loading static map preview...</div>
83
- <img id="preview-image" alt="Static Map Preview">
84
- <div id="error" style="display:none"></div>
85
- </div>
86
-
87
- <script type="module">
88
- const image = document.getElementById('preview-image');
89
- const loading = document.getElementById('loading');
90
- const errorDiv = document.getElementById('error');
91
- const toolbar = document.getElementById('toolbar');
92
- const fullscreenBtn = document.getElementById('fullscreen-btn');
93
-
94
- let isZoomed = false;
95
- let currentDisplayMode = 'inline';
96
- let canFullscreen = false;
97
-
98
- image.addEventListener('click', () => {
99
- isZoomed = !isZoomed;
100
- image.classList.toggle('zoomed', isZoomed);
101
- });
102
-
103
- let messageId = 0;
104
- const pendingRequests = new Map();
105
-
106
- function sendRequest(method, params = {}) {
107
- const id = ++messageId;
108
- window.parent.postMessage({ jsonrpc: '2.0', id, method, params }, '*');
109
- return new Promise((resolve, reject) => {
110
- pendingRequests.set(id, { resolve, reject });
111
- });
112
- }
113
-
114
- function sendNotification(method, params = {}) {
115
- window.parent.postMessage({ jsonrpc: '2.0', method, params }, '*');
116
- }
117
-
118
- function requestSizeToFit() {
119
- if (currentDisplayMode !== 'inline') return;
120
- // Use requestAnimationFrame to measure after layout so we get the
121
- // actual rendered height (constrained by max-width:100%), not natural px
122
- requestAnimationFrame(() => {
123
- const toolbarHeight = canFullscreen ? toolbar.offsetHeight : 0;
124
- sendNotification('ui/notifications/size-changed', {
125
- height: Math.round(image.getBoundingClientRect().height) + toolbarHeight
126
- });
127
- });
128
- }
129
-
130
- function updateFullscreenButton() {
131
- fullscreenBtn.textContent =
132
- currentDisplayMode === 'fullscreen' ? '⊟ Exit Fullscreen' : '⛶ Fullscreen';
133
- }
134
-
135
- async function toggleFullscreen() {
136
- const newMode = currentDisplayMode === 'fullscreen' ? 'inline' : 'fullscreen';
137
- try {
138
- const result = await sendRequest('ui/request-display-mode', { mode: newMode });
139
- currentDisplayMode = result?.mode ?? newMode;
140
- updateFullscreenButton();
141
- if (currentDisplayMode === 'inline') requestSizeToFit();
142
- } catch (e) {
143
- console.error('Failed to change display mode:', e);
144
- }
145
- }
146
-
147
- fullscreenBtn.addEventListener('click', toggleFullscreen);
148
-
149
- window.addEventListener('message', (event) => {
150
- const message = event.data;
151
- if (!message || typeof message !== 'object') return;
152
-
153
- if (message.id !== undefined && pendingRequests.has(message.id)) {
154
- const { resolve, reject } = pendingRequests.get(message.id);
155
- pendingRequests.delete(message.id);
156
- if (message.error) reject(new Error(message.error.message));
157
- else resolve(message.result);
158
- return;
159
- }
160
-
161
- if (message.method === 'ui/notifications/tool-result') {
162
- if (message.params) handleToolResult(message.params);
163
- }
164
-
165
- if (message.method === 'ui/notifications/host-context-changed') {
166
- const ctx = message.params;
167
- if (ctx?.displayMode) {
168
- currentDisplayMode = ctx.displayMode;
169
- updateFullscreenButton();
170
- if (currentDisplayMode === 'inline' && image.style.display !== 'none') {
171
- requestSizeToFit();
172
- }
173
- }
174
- }
175
- });
176
-
177
- async function handleToolResult(result) {
178
- const textContent = result.content?.find(c => c.type === 'text');
179
- if (!textContent?.text) {
180
- loading.style.display = 'none';
181
- errorDiv.textContent = 'No URL found in tool result';
182
- errorDiv.style.display = 'block';
183
- return;
184
- }
185
-
186
- const url = textContent.text;
187
- if (!url.includes('api.mapbox.com/styles/') || !url.includes('/static/')) {
188
- loading.style.display = 'none';
189
- errorDiv.textContent = 'Unsupported URL format';
190
- errorDiv.style.display = 'block';
191
- return;
192
- }
193
-
194
- loading.textContent = 'Fetching map from Mapbox...';
195
- try {
196
- const response = await fetch(url);
197
- if (!response.ok) throw new Error('HTTP ' + response.status);
198
- const blob = await response.blob();
199
- const blobUrl = URL.createObjectURL(blob);
200
-
201
- image.onload = () => {
202
- loading.style.display = 'none';
203
- image.style.display = 'block';
204
- if (canFullscreen) toolbar.classList.add('visible');
205
- requestSizeToFit();
206
- };
207
- image.src = blobUrl;
208
- } catch (error) {
209
- loading.style.display = 'none';
210
- errorDiv.textContent = 'Failed to load image: ' + error.message;
211
- errorDiv.style.display = 'block';
212
- }
213
- }
214
-
215
- async function init() {
216
- try {
217
- const result = await sendRequest('ui/initialize', {
218
- protocolVersion: '2026-01-26',
219
- appCapabilities: {},
220
- appInfo: { name: 'Static Map Preview', version: '1.0.0' }
221
- });
222
-
223
- sendNotification('ui/notifications/initialized', {});
224
-
225
- const hostContext = result?.hostContext;
226
- currentDisplayMode = hostContext?.displayMode ?? 'inline';
227
- canFullscreen = hostContext?.availableDisplayModes?.includes('fullscreen') ?? false;
228
- } catch (error) {
229
- console.error('Failed to connect to MCP host:', error);
230
- loading.textContent = 'Failed to connect: ' + error.message;
231
- loading.style.color = '#cc0000';
232
- }
233
- }
234
-
235
- init();
236
- </script>
237
- </body>
238
- </html>`;
239
- return {
240
- contents: [
241
- {
242
- uri: this.uri,
243
- mimeType: RESOURCE_MIME_TYPE,
244
- text: html,
245
- _meta: {
246
- ui: {
247
- csp: {
248
- connectDomains: ['https://api.mapbox.com'],
249
- resourceDomains: ['https://api.mapbox.com']
250
- }
251
- }
252
- }
253
- }
254
- ]
255
- };
256
- }
257
- }
258
- //# sourceMappingURL=StaticMapUIResource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StaticMapUIResource.js","sourceRoot":"","sources":["../../../../src/resources/ui-apps/StaticMapUIResource.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kCAAkC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IAC1C,IAAI,GAAG,uBAAuB,CAAC;IAC/B,GAAG,GAAG,mCAAmC,CAAC;IAC1C,WAAW,GAClB,4DAA4D,CAAC;IACtD,QAAQ,GAAG,kBAAkB,CAAC;IAEvC,KAAK,CAAC,IAAI;IACR,6DAA6D;IAC7D,IAAY;IACZ,6DAA6D;IAC7D,MAA+D;QAE/D,4EAA4E;QAC5E,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0NT,CAAC;QAEL,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,QAAQ,EAAE,kBAAkB;oBAC5B,IAAI,EAAE,IAAI;oBACV,KAAK,EAAE;wBACL,EAAE,EAAE;4BACF,GAAG,EAAE;gCACH,cAAc,EAAE,CAAC,wBAAwB,CAAC;gCAC1C,eAAe,EAAE,CAAC,wBAAwB,CAAC;6BAC5C;yBACF;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF"}