marble-headed-mcp 0.1.41 → 0.1.42
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/dist/index.js +23 -60
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -137,7 +137,7 @@ function resolveBrowserAppBaseUrl() {
|
|
|
137
137
|
if (selectedEnvironment) {
|
|
138
138
|
return normalizeBaseUrl(ENVIRONMENT_BASE_URLS[selectedEnvironment]);
|
|
139
139
|
}
|
|
140
|
-
return
|
|
140
|
+
return normalizeBaseUrl(ENVIRONMENT_BASE_URLS.localhost);
|
|
141
141
|
}
|
|
142
142
|
function buildUrl(pathname) {
|
|
143
143
|
return `${resolveHeadedServerAppBaseUrl()}${pathname}`;
|
|
@@ -145,9 +145,6 @@ function buildUrl(pathname) {
|
|
|
145
145
|
function buildHeadedUrl(pathname) {
|
|
146
146
|
return `${resolveHeadedServerAppBaseUrl()}/api/headed${pathname}`;
|
|
147
147
|
}
|
|
148
|
-
function buildBrowserHeadedUrl(pathname) {
|
|
149
|
-
return `${resolveBrowserAppBaseUrl()}/api/headed${pathname}`;
|
|
150
|
-
}
|
|
151
148
|
async function postJson(pathname, payload) {
|
|
152
149
|
const response = await fetch(buildUrl(pathname), {
|
|
153
150
|
method: 'POST',
|
|
@@ -185,27 +182,21 @@ async function postHeadedJson(pathname, payload) {
|
|
|
185
182
|
}
|
|
186
183
|
return { status: response.status, ok: response.ok, text, json };
|
|
187
184
|
}
|
|
188
|
-
async function
|
|
189
|
-
const response = await fetch(
|
|
190
|
-
method: 'POST',
|
|
191
|
-
headers: { 'Content-Type': 'application/json' },
|
|
192
|
-
body: JSON.stringify(payload ?? {}),
|
|
193
|
-
});
|
|
194
|
-
const text = await response.text();
|
|
195
|
-
let json = null;
|
|
196
|
-
try {
|
|
197
|
-
json = JSON.parse(text);
|
|
198
|
-
}
|
|
199
|
-
catch (error) {
|
|
200
|
-
json = null;
|
|
201
|
-
}
|
|
202
|
-
return { status: response.status, ok: response.ok, text, json };
|
|
203
|
-
}
|
|
204
|
-
async function getBrowserHeadedText(pathname) {
|
|
205
|
-
const response = await fetch(buildBrowserHeadedUrl(pathname));
|
|
185
|
+
async function getHeadedText(pathname) {
|
|
186
|
+
const response = await fetch(buildHeadedUrl(pathname));
|
|
206
187
|
const text = await response.text();
|
|
207
188
|
return { status: response.status, ok: response.ok, text };
|
|
208
189
|
}
|
|
190
|
+
function withBrowserAppBaseUrl(payload) {
|
|
191
|
+
const appBaseUrl = resolveBrowserAppBaseUrl();
|
|
192
|
+
if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
|
|
193
|
+
return {
|
|
194
|
+
...payload,
|
|
195
|
+
appBaseUrl,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return { appBaseUrl };
|
|
199
|
+
}
|
|
209
200
|
async function getJson(pathname) {
|
|
210
201
|
const response = await fetch(buildUrl(pathname));
|
|
211
202
|
const text = await response.text();
|
|
@@ -440,7 +431,7 @@ async function saveImageFromUrl({ url, filename }) {
|
|
|
440
431
|
const TOOLS = [
|
|
441
432
|
{
|
|
442
433
|
name: 'set_environment',
|
|
443
|
-
description: 'Set the
|
|
434
|
+
description: 'Set the in-browser app environment used by headed session actions. localhost -> http://localhost:3000, dev -> https://dev.withmarble.ai, production -> https://withmarble.ai. API calls still go to HEADED_SERVER_BASE_URL (default localhost:3000).',
|
|
444
435
|
inputSchema: {
|
|
445
436
|
type: 'object',
|
|
446
437
|
properties: {
|
|
@@ -491,20 +482,6 @@ const TOOLS = [
|
|
|
491
482
|
additionalProperties: false,
|
|
492
483
|
},
|
|
493
484
|
},
|
|
494
|
-
{
|
|
495
|
-
name: 'navigate_to_url',
|
|
496
|
-
description: 'Navigate a headed session to a URL. Prefer `headed_navigate_to_project` when possible; use this only for validating code in a separate browser tab (e.g., proxy URL access). If the URL already exists (ignoring query parameters), the existing tab will be focused instead of creating a new one.',
|
|
497
|
-
inputSchema: {
|
|
498
|
-
type: 'object',
|
|
499
|
-
properties: {
|
|
500
|
-
browserSession: { type: 'number', description: 'Headed browser session id.' },
|
|
501
|
-
browserSessionId: { type: 'number', description: 'Alias for browserSession.' },
|
|
502
|
-
url: { type: 'string', description: 'URL to navigate to.' },
|
|
503
|
-
},
|
|
504
|
-
required: ['url'],
|
|
505
|
-
additionalProperties: false,
|
|
506
|
-
},
|
|
507
|
-
},
|
|
508
485
|
{
|
|
509
486
|
name: 'start_plan_project',
|
|
510
487
|
description: 'Navigate to a project within a plan. If startProject is true (default), clicks BEGIN SIMULATION; if false, only navigates to the plan project without starting the simulation.',
|
|
@@ -798,7 +775,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
798
775
|
ok: true,
|
|
799
776
|
environment,
|
|
800
777
|
browserAppBaseUrl,
|
|
801
|
-
browserHeadedApiBaseUrl: `${browserAppBaseUrl}/api/headed`,
|
|
802
778
|
headedServerAppBaseUrl,
|
|
803
779
|
headedServerHeadedApiBaseUrl: `${headedServerAppBaseUrl}/api/headed`,
|
|
804
780
|
}, null, 2),
|
|
@@ -807,36 +783,23 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
807
783
|
};
|
|
808
784
|
}
|
|
809
785
|
case 'headed_start_session': {
|
|
810
|
-
const result = await
|
|
786
|
+
const result = await postHeadedJson('/start_session', withBrowserAppBaseUrl(args));
|
|
811
787
|
return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
|
|
812
788
|
}
|
|
813
789
|
case 'headed_end_session': {
|
|
814
|
-
const result = await
|
|
790
|
+
const result = await postHeadedJson('/end_session', withBrowserAppBaseUrl(args));
|
|
815
791
|
return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
|
|
816
792
|
}
|
|
817
793
|
case 'headed_navigate_to_project': {
|
|
818
|
-
const result = await
|
|
819
|
-
return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
|
|
820
|
-
}
|
|
821
|
-
case 'navigate_to_url': {
|
|
822
|
-
const url = typeof args?.url === 'string' ? args.url.trim() : '';
|
|
823
|
-
const browserSessionRaw = args?.browserSession ?? args?.browserSessionId;
|
|
824
|
-
const browserSessionId = typeof browserSessionRaw === 'number' ? browserSessionRaw : Number(browserSessionRaw);
|
|
825
|
-
if (!url) {
|
|
826
|
-
return { content: [{ type: 'text', text: JSON.stringify({ ok: false, error: 'url is required.' }, null, 2) }] };
|
|
827
|
-
}
|
|
828
|
-
if (!browserSessionId || Number.isNaN(browserSessionId)) {
|
|
829
|
-
return { content: [{ type: 'text', text: JSON.stringify({ ok: false, error: 'browserSession is required.' }, null, 2) }] };
|
|
830
|
-
}
|
|
831
|
-
const result = await postBrowserHeadedJson('/navigate_to_url', { browserSessionId, url });
|
|
794
|
+
const result = await postHeadedJson('/navigate_to_project', withBrowserAppBaseUrl(args));
|
|
832
795
|
return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
|
|
833
796
|
}
|
|
834
797
|
case 'start_plan_project': {
|
|
835
|
-
const result = await
|
|
798
|
+
const result = await postHeadedJson('/start_plan_project', withBrowserAppBaseUrl(args));
|
|
836
799
|
return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
|
|
837
800
|
}
|
|
838
801
|
case 'headed_send_msg': {
|
|
839
|
-
const result = await
|
|
802
|
+
const result = await postHeadedJson('/send_msg_headed', withBrowserAppBaseUrl(args));
|
|
840
803
|
const payload = (result.json && typeof result.json === 'object') ? result.json : null;
|
|
841
804
|
if (payload?.workflowRunId) {
|
|
842
805
|
const summaryResult = await fetchWorkflowEntries(String(payload.workflowRunId));
|
|
@@ -851,7 +814,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
851
814
|
return { content: [{ type: 'text', text: JSON.stringify(payload || { status: result.status, body: result.text }, null, 2) }] };
|
|
852
815
|
}
|
|
853
816
|
case 'take_screenshot': {
|
|
854
|
-
const result = await
|
|
817
|
+
const result = await postHeadedJson('/take_screenshot', withBrowserAppBaseUrl(args));
|
|
855
818
|
const payload = (result.json && typeof result.json === 'object') ? result.json : null;
|
|
856
819
|
if (payload?.workflowRunId) {
|
|
857
820
|
const summaryResult = await fetchWorkflowEntries(String(payload.workflowRunId));
|
|
@@ -866,19 +829,19 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
866
829
|
return { content: [{ type: 'text', text: JSON.stringify(payload || { status: result.status, body: result.text }, null, 2) }] };
|
|
867
830
|
}
|
|
868
831
|
case 'take_screenshot': {
|
|
869
|
-
const result = await
|
|
832
|
+
const result = await postHeadedJson('/take_screenshot', withBrowserAppBaseUrl(args));
|
|
870
833
|
return { content: [{ type: 'text', text: JSON.stringify(result.json || { status: result.status, body: result.text }, null, 2) }] };
|
|
871
834
|
}
|
|
872
835
|
case 'screenshots_preview': {
|
|
873
836
|
const payload = args?.screenshotUrls
|
|
874
837
|
? { screenshotUrls: args.screenshotUrls }
|
|
875
838
|
: args?.response || args;
|
|
876
|
-
const result = await
|
|
839
|
+
const result = await postHeadedJson('/preview_screenshots', withBrowserAppBaseUrl(payload));
|
|
877
840
|
return { content: [{ type: 'text', text: JSON.stringify({ status: result.status, ok: result.ok, html: result.text }, null, 2) }] };
|
|
878
841
|
}
|
|
879
842
|
case 'screenshots_get_preview': {
|
|
880
843
|
const previewId = args?.previewId;
|
|
881
|
-
const result = await
|
|
844
|
+
const result = await getHeadedText(`/preview_screenshots/${encodeURIComponent(previewId)}`);
|
|
882
845
|
return { content: [{ type: 'text', text: JSON.stringify({ status: result.status, ok: result.ok, html: result.text }, null, 2) }] };
|
|
883
846
|
}
|
|
884
847
|
case 'workflow_end_to_end_project_generation': {
|