@olib-ai/owl-browser-mcp 1.0.2 → 1.0.3
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 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26797,6 +26797,7 @@ var openapi_default = {
|
|
|
26797
26797
|
var API_ENDPOINT = process.env.OWL_API_ENDPOINT || "http://127.0.0.1:8080";
|
|
26798
26798
|
var API_TOKEN = process.env.OWL_API_TOKEN || "";
|
|
26799
26799
|
var activeContexts = /* @__PURE__ */ new Map();
|
|
26800
|
+
var toolIntegerFields = /* @__PURE__ */ new Map();
|
|
26800
26801
|
function convertOpenAPIToMCPTools(schema) {
|
|
26801
26802
|
const tools = [];
|
|
26802
26803
|
for (const [path, pathItem] of Object.entries(schema.paths)) {
|
|
@@ -26810,6 +26811,7 @@ function convertOpenAPIToMCPTools(schema) {
|
|
|
26810
26811
|
};
|
|
26811
26812
|
if (requestSchema?.properties) {
|
|
26812
26813
|
const properties = {};
|
|
26814
|
+
const integerFields = /* @__PURE__ */ new Set();
|
|
26813
26815
|
for (const [propName, propDef] of Object.entries(requestSchema.properties)) {
|
|
26814
26816
|
const prop = {};
|
|
26815
26817
|
if (propDef.type === "string") {
|
|
@@ -26821,6 +26823,9 @@ function convertOpenAPIToMCPTools(schema) {
|
|
|
26821
26823
|
prop.type = "boolean";
|
|
26822
26824
|
} else if (propDef.type === "number" || propDef.type === "integer") {
|
|
26823
26825
|
prop.type = "number";
|
|
26826
|
+
if (propDef.type === "integer") {
|
|
26827
|
+
integerFields.add(propName);
|
|
26828
|
+
}
|
|
26824
26829
|
} else if (propDef.type === "array") {
|
|
26825
26830
|
prop.type = "array";
|
|
26826
26831
|
if (propDef.items) {
|
|
@@ -26838,6 +26843,9 @@ function convertOpenAPIToMCPTools(schema) {
|
|
|
26838
26843
|
properties[propName] = prop;
|
|
26839
26844
|
}
|
|
26840
26845
|
inputSchema.properties = properties;
|
|
26846
|
+
if (integerFields.size > 0) {
|
|
26847
|
+
toolIntegerFields.set(toolName, integerFields);
|
|
26848
|
+
}
|
|
26841
26849
|
}
|
|
26842
26850
|
if (requestSchema?.required && requestSchema.required.length > 0) {
|
|
26843
26851
|
inputSchema.required = requestSchema.required;
|
|
@@ -26850,6 +26858,19 @@ function convertOpenAPIToMCPTools(schema) {
|
|
|
26850
26858
|
}
|
|
26851
26859
|
return tools;
|
|
26852
26860
|
}
|
|
26861
|
+
function coerceIntegerFields(toolName, args) {
|
|
26862
|
+
const integerFields = toolIntegerFields.get(toolName);
|
|
26863
|
+
if (!integerFields || integerFields.size === 0) {
|
|
26864
|
+
return args;
|
|
26865
|
+
}
|
|
26866
|
+
const coerced = { ...args };
|
|
26867
|
+
for (const field of integerFields) {
|
|
26868
|
+
if (field in coerced && typeof coerced[field] === "number") {
|
|
26869
|
+
coerced[field] = Math.round(coerced[field]);
|
|
26870
|
+
}
|
|
26871
|
+
}
|
|
26872
|
+
return coerced;
|
|
26873
|
+
}
|
|
26853
26874
|
async function callBrowserAPI(toolName, args) {
|
|
26854
26875
|
const url2 = `${API_ENDPOINT}/api/execute/${toolName}`;
|
|
26855
26876
|
const headers = {
|
|
@@ -26858,11 +26879,12 @@ async function callBrowserAPI(toolName, args) {
|
|
|
26858
26879
|
if (API_TOKEN) {
|
|
26859
26880
|
headers["Authorization"] = `Bearer ${API_TOKEN}`;
|
|
26860
26881
|
}
|
|
26882
|
+
const coercedArgs = coerceIntegerFields(toolName, args);
|
|
26861
26883
|
try {
|
|
26862
26884
|
const response = await fetch(url2, {
|
|
26863
26885
|
method: "POST",
|
|
26864
26886
|
headers,
|
|
26865
|
-
body: JSON.stringify(
|
|
26887
|
+
body: JSON.stringify(coercedArgs)
|
|
26866
26888
|
});
|
|
26867
26889
|
const contentType = response.headers.get("content-type") || "";
|
|
26868
26890
|
let data;
|