@glance-mcp/server 1.0.0 → 1.1.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.
package/package.json CHANGED
@@ -1,13 +1,31 @@
1
1
  {
2
2
  "name": "@glance-mcp/server",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "MCP server for Glance — capture what a web page looks like and does",
5
5
  "type": "module",
6
- "bin": { "glance-mcp": "./src/index.mjs" },
6
+ "bin": {
7
+ "glance-mcp": "src/index.mjs"
8
+ },
7
9
  "main": "./src/index.mjs",
8
- "files": ["src"],
9
- "engines": { "node": ">=18" },
10
+ "files": [
11
+ "src"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
10
16
  "license": "MIT",
11
17
  "homepage": "https://glance.tools",
12
- "keywords": ["mcp", "mcp-server", "glance", "screenshot", "web-capture", "model-context-protocol", "claude", "cursor", "web-scraping", "headless-chrome", "llm-tools"]
18
+ "keywords": [
19
+ "mcp",
20
+ "mcp-server",
21
+ "glance",
22
+ "screenshot",
23
+ "web-capture",
24
+ "model-context-protocol",
25
+ "claude",
26
+ "cursor",
27
+ "web-scraping",
28
+ "headless-chrome",
29
+ "llm-tools"
30
+ ]
13
31
  }
package/src/api.mjs CHANGED
@@ -39,6 +39,17 @@ export function createApiClient({ apiKey, apiUrl } = {}) {
39
39
  return json.result;
40
40
  }
41
41
 
42
+ async function fetchImage(imageUrl) {
43
+ const headers = {};
44
+ if (key) headers['Authorization'] = `Bearer ${key}`;
45
+
46
+ const res = await fetch(imageUrl, { headers });
47
+ if (!res.ok) {
48
+ throw new Error(`Failed to fetch image: HTTP ${res.status}`);
49
+ }
50
+ return Buffer.from(await res.arrayBuffer());
51
+ }
52
+
42
53
  return {
43
54
  get apiKey() { return key; },
44
55
 
@@ -50,5 +61,6 @@ export function createApiClient({ apiKey, apiUrl } = {}) {
50
61
  result(job) { return rpc('result', { job }); },
51
62
  usage() { return rpc('usage'); },
52
63
  feedback(message){ return rpc('feedback', { message }); },
64
+ fetchImage,
53
65
  };
54
66
  }
package/src/tools.mjs CHANGED
@@ -208,13 +208,15 @@ async function handleGlance(args, api) {
208
208
 
209
209
  if (res.status === 'done') {
210
210
  const lines = [`Capture complete for ${args.url}`, ''];
211
+ const screenshotEntries = [];
211
212
 
212
213
  if (res.artifacts) {
213
214
  const { meta, ...urlArtifacts } = res.artifacts;
214
215
 
215
- // Screenshot and file URLs
216
216
  for (const [key, value] of Object.entries(urlArtifacts)) {
217
- if (typeof value === 'string') {
217
+ if (typeof value === 'string' && value.endsWith('.png')) {
218
+ screenshotEntries.push([key, value]);
219
+ } else if (typeof value === 'string') {
218
220
  lines.push(`${key}: ${value}`);
219
221
  }
220
222
  }
@@ -231,7 +233,20 @@ async function handleGlance(args, api) {
231
233
  lines.push(`Usage: ${res.usage.used} used, ${res.usage.remaining} remaining`);
232
234
  }
233
235
 
234
- return textResult(lines.join('\n'));
236
+ const content = [{ type: 'text', text: lines.join('\n') }];
237
+
238
+ // Fetch screenshots and return as inline image blocks
239
+ for (const [key, url] of screenshotEntries) {
240
+ try {
241
+ const buf = await api.fetchImage(url);
242
+ content.push({ type: 'image', data: buf.toString('base64'), mimeType: 'image/png' });
243
+ } catch {
244
+ // If fetch fails, include the URL as text instead
245
+ content.push({ type: 'text', text: `${key}: ${url} (image fetch failed)` });
246
+ }
247
+ }
248
+
249
+ return { content };
235
250
  }
236
251
 
237
252
  if (res.status === 'failed') {