marble-headed-mcp 0.1.2 → 0.1.4

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 (2) hide show
  1. package/dist/index.js +34 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import path from 'path';
4
4
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
5
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
6
6
  import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
7
- const DEFAULT_BASE_URL = 'http://localhost:4000/api/headed';
7
+ const DEFAULT_BASE_URL = 'http://localhost:4000';
8
8
  function resolveBaseUrl() {
9
9
  const base = process.env.HEADED_SERVER_BASE_URL || DEFAULT_BASE_URL;
10
10
  return base.replace(/\/+$/, '');
@@ -12,6 +12,9 @@ function resolveBaseUrl() {
12
12
  function buildUrl(pathname) {
13
13
  return `${resolveBaseUrl()}${pathname}`;
14
14
  }
15
+ function buildHeadedUrl(pathname) {
16
+ return buildUrl(`/api/headed${pathname}`);
17
+ }
15
18
  async function postJson(pathname, payload) {
16
19
  const response = await fetch(buildUrl(pathname), {
17
20
  method: 'POST',
@@ -33,6 +36,27 @@ async function getText(pathname) {
33
36
  const text = await response.text();
34
37
  return { status: response.status, ok: response.ok, text };
35
38
  }
39
+ async function postHeadedJson(pathname, payload) {
40
+ const response = await fetch(buildHeadedUrl(pathname), {
41
+ method: 'POST',
42
+ headers: { 'Content-Type': 'application/json' },
43
+ body: JSON.stringify(payload ?? {}),
44
+ });
45
+ const text = await response.text();
46
+ let json = null;
47
+ try {
48
+ json = JSON.parse(text);
49
+ }
50
+ catch (error) {
51
+ json = null;
52
+ }
53
+ return { status: response.status, ok: response.ok, text, json };
54
+ }
55
+ async function getHeadedText(pathname) {
56
+ const response = await fetch(buildHeadedUrl(pathname));
57
+ const text = await response.text();
58
+ return { status: response.status, ok: response.ok, text };
59
+ }
36
60
  function inferExtensionFromMime(mimeType) {
37
61
  if (!mimeType)
38
62
  return null;
@@ -245,19 +269,19 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
245
269
  try {
246
270
  switch (name) {
247
271
  case 'headed_start_session': {
248
- const result = await postJson('/start_session', args);
272
+ const result = await postHeadedJson('/start_session', args);
249
273
  return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
250
274
  }
251
275
  case 'headed_end_session': {
252
- const result = await postJson('/end_session', args);
276
+ const result = await postHeadedJson('/end_session', args);
253
277
  return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
254
278
  }
255
279
  case 'headed_navigate_to_project': {
256
- const result = await postJson('/navigate_to_project', args);
280
+ const result = await postHeadedJson('/navigate_to_project', args);
257
281
  return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
258
282
  }
259
283
  case 'headed_send_msg': {
260
- const result = await postJson('/send_msg_headed', args);
284
+ const result = await postHeadedJson('/send_msg_headed', args);
261
285
  return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
262
286
  }
263
287
  case 'screenshots_preview': {
@@ -266,24 +290,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
266
290
  : args?.screenshotUrls
267
291
  ? { screenshotUrls: args.screenshotUrls }
268
292
  : args?.response || args;
269
- const result = await postJson('/preview_screenshots', payload);
293
+ const result = await postHeadedJson('/preview_screenshots', payload);
270
294
  return { content: [{ type: 'text', text: JSON.stringify({ status: result.status, ok: result.ok, html: result.text }, null, 2) }] };
271
295
  }
272
296
  case 'screenshots_get_preview': {
273
297
  const previewId = args?.previewId;
274
- const result = await getText(`/preview_screenshots/${encodeURIComponent(previewId)}`);
298
+ const result = await getHeadedText(`/preview_screenshots/${encodeURIComponent(previewId)}`);
275
299
  return { content: [{ type: 'text', text: JSON.stringify({ status: result.status, ok: result.ok, html: result.text }, null, 2) }] };
276
300
  }
277
301
  case 'workflow_end_to_end_project_generation': {
278
- const result = await postJson('/end_to_end_project_generation', args);
302
+ const result = await postHeadedJson('/end_to_end_project_generation', args);
279
303
  return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
280
304
  }
281
305
  case 'complete_project': {
282
- const result = await postJson('/complete_project', args);
306
+ const result = await postHeadedJson('/complete_project', args);
283
307
  return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
284
308
  }
285
309
  case 'get_container_logs': {
286
- const result = await postJson('/get_container_logs', args);
310
+ const result = await postJson('/api/gcloud/read', args);
287
311
  return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
288
312
  }
289
313
  case 'save_image_base64': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marble-headed-mcp",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "MCP server for Marble headed automation endpoints",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",