mcp-use 1.11.0-canary.9 → 1.11.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/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-N3DO4P2L.js → chunk-A4QJRN7Z.js} +2 -2
- package/dist/{chunk-UCPSHMNO.js → chunk-B7AGEK7F.js} +1 -1
- package/dist/{chunk-HU2DGJ5J.js → chunk-GN5HOAV3.js} +491 -5
- package/dist/{chunk-D3CNYAYE.js → chunk-QPIDKGV4.js} +199 -8
- package/dist/{chunk-ZFZPZ4GE.js → chunk-V77WS6CS.js} +9 -0
- package/dist/{chunk-5QFJZ7H3.js → chunk-VRHAF2WT.js} +10 -4
- package/dist/{chunk-F3BZFJCD.js → chunk-Y2HHHJQB.js} +10 -5
- package/dist/{chunk-Q5LZL6BH.js → chunk-ZLZOOXMJ.js} +96 -43
- package/dist/index.cjs +122 -47
- package/dist/index.js +15 -19
- package/dist/src/agents/index.cjs +108 -44
- package/dist/src/agents/index.d.ts +1 -1
- package/dist/src/agents/index.d.ts.map +1 -1
- package/dist/src/agents/index.js +7 -11
- package/dist/src/agents/mcp_agent.d.ts.map +1 -1
- package/dist/src/{client/prompts.d.ts → agents/prompts/index.d.ts} +3 -3
- package/dist/src/agents/prompts/index.d.ts.map +1 -0
- package/dist/src/browser.cjs +115 -45
- package/dist/src/browser.js +10 -13
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/client.cjs +108 -43
- package/dist/src/client.d.ts +2 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +6 -5
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/connectors/http.d.ts +2 -0
- package/dist/src/connectors/http.d.ts.map +1 -1
- package/dist/src/react/index.cjs +119 -46
- package/dist/src/react/index.js +7 -8
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/dist/src/server/index.cjs +178 -113
- package/dist/src/server/index.js +92 -80
- package/dist/src/server/types/widget.d.ts +2 -2
- package/dist/src/server/types/widget.d.ts.map +1 -1
- package/dist/src/server/widgets/mount-widgets-dev.d.ts.map +1 -1
- package/dist/src/server/widgets/ui-resource-registration.d.ts.map +1 -1
- package/dist/src/telemetry/telemetry.d.ts +1 -0
- package/dist/src/telemetry/telemetry.d.ts.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/{tool-execution-helpers-MXVN6YNU.js → tool-execution-helpers-ZUA5D5IO.js} +2 -2
- package/package.json +49 -52
- package/dist/chunk-ESMOFYJ6.js +0 -2638
- package/dist/chunk-M7WATKYM.js +0 -204
- package/dist/chunk-OWPXM4QQ.js +0 -12
- package/dist/chunk-WW3A2EKQ.js +0 -1055
- package/dist/chunk-XEFWIBQF.js +0 -491
- package/dist/src/client/prompts.cjs +0 -407
- package/dist/src/client/prompts.d.ts.map +0 -1
- package/dist/src/client/prompts.js +0 -11
package/dist/src/agents/index.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BaseAgent
|
|
3
|
-
|
|
2
|
+
BaseAgent,
|
|
3
|
+
PROMPTS
|
|
4
|
+
} from "../../chunk-V77WS6CS.js";
|
|
4
5
|
import {
|
|
5
6
|
MCPAgent,
|
|
6
7
|
RemoteAgent
|
|
7
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-A4QJRN7Z.js";
|
|
8
9
|
import "../../chunk-JRGQRPTN.js";
|
|
9
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-QPIDKGV4.js";
|
|
10
11
|
import "../../chunk-MFSO5PUW.js";
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
} from "../../chunk-OWPXM4QQ.js";
|
|
14
|
-
import "../../chunk-M7WATKYM.js";
|
|
15
|
-
import "../../chunk-HU2DGJ5J.js";
|
|
16
|
-
import "../../chunk-XEFWIBQF.js";
|
|
17
|
-
import "../../chunk-Q5LZL6BH.js";
|
|
12
|
+
import "../../chunk-GN5HOAV3.js";
|
|
13
|
+
import "../../chunk-ZLZOOXMJ.js";
|
|
18
14
|
import "../../chunk-FRUZDWXH.js";
|
|
19
15
|
import "../../chunk-3GQAWCBQ.js";
|
|
20
16
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp_agent.d.ts","sourceRoot":"","sources":["../../../src/agents/mcp_agent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAKL,aAAa,
|
|
1
|
+
{"version":3,"file":"mcp_agent.d.ts","sourceRoot":"","sources":["../../../src/agents/mcp_agent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAKL,aAAa,EAGd,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAOrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAUjE,OAAO,KAAK,EACV,WAAW,EAEX,eAAe,EAEhB,MAAM,YAAY,CAAC;AAIpB,YAAY,EACV,aAAa,EACb,WAAW,EACX,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,GAAG,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,MAAM;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,WAAW,EAAE,CAAC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P
|
|
2
|
+
* Prompt templates for MCP agents.
|
|
3
3
|
*
|
|
4
4
|
* This module provides prompt templates to guide agents on how to use
|
|
5
|
-
* MCP tools
|
|
5
|
+
* MCP tools, including code execution mode.
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* Collection of prompt templates for MCP agents.
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
export declare const PROMPTS: {
|
|
11
11
|
readonly CODE_MODE: "\n## MCP Code Mode Tool Usage Guide\n\nYou have access to an MCP Code Mode Client that allows you to execute JavaScript/TypeScript code with access to registered tools. Follow this workflow:\n\n### 1. Tool Discovery Phase\n**Always start by discovering available tools:**\n- Tools are organized by server namespace (e.g., `server_name.tool_name`)\n- Use the `search_tools(query, detail_level)` function to find available tools\n- You can access `__tool_namespaces` to see all available server namespaces\n\n```javascript\n// Find all GitHub-related tools\nconst tools = await search_tools(\"github\");\nfor (const tool of tools) {\n console.log(`${tool.server}.${tool.name}: ${tool.description}`);\n}\n\n// Get only tool names for quick overview\nconst tools = await search_tools(\"\", \"names\");\n```\n\n### 2. Interface Introspection\n**Understand tool contracts before using them:**\n- Use `search_tools` to get tool descriptions and input schemas\n- Look for \"Access as: server.tool(args)\" patterns in descriptions\n\n### 3. Code Execution Guidelines\n**When writing code:**\n- Use `await server.tool({ param: value })` syntax for all tool calls\n- Tools are async functions that return promises\n- You have access to standard JavaScript globals: `console`, `JSON`, `Math`, `Date`, etc.\n- All console output (`console.log`, `console.error`, etc.) is automatically captured and returned\n- Build properly structured input objects based on interface definitions\n- Handle errors appropriately with try/catch blocks\n- Chain tool calls by using results from previous calls\n\n### 4. Best Practices\n- **Discover first, code second**: Always explore available tools before writing execution code\n- **Respect namespaces**: Use full `server.tool` names to avoid conflicts\n- **Minimize Context**: Process large data in code, return only essential results\n- **Error handling**: Wrap tool calls in try/catch for robustness\n- **Data flow**: Chain tools by passing outputs as inputs to subsequent tools\n\n### 5. Available Runtime Context\n- `search_tools(query, detail_level)`: Function to discover tools\n- `__tool_namespaces`: Array of available server namespaces\n- All registered tools as `server.tool` functions\n- Standard JavaScript built-ins for data processing\n\n### Example Workflow\n\n```javascript\n// 1. Discover available tools\nconst github_tools = await search_tools(\"github pull request\");\nconsole.log(`Available GitHub PR tools: ${github_tools.map(t => t.name)}`);\n\n// 2. Call tools with proper parameters\nconst pr = await github.get_pull_request({\n owner: \"facebook\",\n repo: \"react\",\n number: 12345\n});\n\n// 3. Process results\nlet result;\nif (pr.state === 'open' && pr.labels.some(l => l.name === 'bug')) {\n // 4. Chain with other tools\n await slack.post_message({\n channel: \"#bugs\",\n text: `🐛 Bug PR needs review: ${pr.title}`\n });\n result = \"Notification sent\";\n} else {\n result = \"No action needed\";\n}\n\n// 5. Return structured results\nreturn {\n pr_number: pr.number,\n pr_title: pr.title,\n action_taken: result\n};\n```\n\nRemember: Always discover and understand available tools before attempting to use them in code execution.\n";
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agents/prompts/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,eAAO,MAAM,OAAO;;CAEV,CAAC"}
|
package/dist/src/browser.cjs
CHANGED
|
@@ -1651,7 +1651,7 @@ __name(generateUUID, "generateUUID");
|
|
|
1651
1651
|
init_logging();
|
|
1652
1652
|
|
|
1653
1653
|
// src/version.ts
|
|
1654
|
-
var VERSION = "1.11.0
|
|
1654
|
+
var VERSION = "1.11.0";
|
|
1655
1655
|
function getPackageVersion() {
|
|
1656
1656
|
return VERSION;
|
|
1657
1657
|
}
|
|
@@ -1690,6 +1690,20 @@ function extractModelInfo(llm) {
|
|
|
1690
1690
|
__name(extractModelInfo, "extractModelInfo");
|
|
1691
1691
|
|
|
1692
1692
|
// src/telemetry/telemetry.ts
|
|
1693
|
+
function secureRandomString() {
|
|
1694
|
+
if (typeof window !== "undefined" && window.crypto && typeof window.crypto.getRandomValues === "function") {
|
|
1695
|
+
const array = new Uint8Array(8);
|
|
1696
|
+
window.crypto.getRandomValues(array);
|
|
1697
|
+
return Array.from(array, (v) => v.toString(16).padStart(2, "0")).join("");
|
|
1698
|
+
}
|
|
1699
|
+
try {
|
|
1700
|
+
const crypto = require("crypto");
|
|
1701
|
+
return crypto.randomBytes(8).toString("hex");
|
|
1702
|
+
} catch (e) {
|
|
1703
|
+
return Math.random().toString(36).substring(2, 15);
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
__name(secureRandomString, "secureRandomString");
|
|
1693
1707
|
var USER_ID_STORAGE_KEY = "mcp_use_user_id";
|
|
1694
1708
|
function detectRuntimeEnvironment() {
|
|
1695
1709
|
try {
|
|
@@ -1821,12 +1835,26 @@ var Telemetry = class _Telemetry {
|
|
|
1821
1835
|
"Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
|
|
1822
1836
|
);
|
|
1823
1837
|
this._posthogLoading = this._initPostHog();
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1838
|
+
if (this._runtimeEnvironment !== "browser") {
|
|
1839
|
+
try {
|
|
1840
|
+
this._scarfClient = new ScarfEventLogger(
|
|
1841
|
+
this.SCARF_GATEWAY_URL,
|
|
1842
|
+
3e3
|
|
1843
|
+
);
|
|
1844
|
+
} catch (e) {
|
|
1845
|
+
logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
|
|
1846
|
+
this._scarfClient = null;
|
|
1847
|
+
}
|
|
1848
|
+
} else {
|
|
1828
1849
|
this._scarfClient = null;
|
|
1829
1850
|
}
|
|
1851
|
+
if (this._storageCapability === "filesystem" && this._scarfClient) {
|
|
1852
|
+
setTimeout(() => {
|
|
1853
|
+
this.trackPackageDownload({ triggered_by: "initialization" }).catch(
|
|
1854
|
+
(e) => logger.debug(`Failed to track package download: ${e}`)
|
|
1855
|
+
);
|
|
1856
|
+
}, 0);
|
|
1857
|
+
}
|
|
1830
1858
|
}
|
|
1831
1859
|
}
|
|
1832
1860
|
_checkTelemetryDisabled() {
|
|
@@ -1951,47 +1979,65 @@ var Telemetry = class _Telemetry {
|
|
|
1951
1979
|
break;
|
|
1952
1980
|
case "session-only":
|
|
1953
1981
|
default:
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1982
|
+
try {
|
|
1983
|
+
this._currUserId = `session-${generateUUID()}`;
|
|
1984
|
+
} catch (uuidError) {
|
|
1985
|
+
this._currUserId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1986
|
+
}
|
|
1958
1987
|
break;
|
|
1959
1988
|
}
|
|
1960
|
-
if (this._storageCapability === "filesystem" && this._currUserId) {
|
|
1961
|
-
this._trackPackageDownloadInternal(this._currUserId, {
|
|
1962
|
-
triggered_by: "user_id_property"
|
|
1963
|
-
}).catch((e) => logger.debug(`Failed to track package download: ${e}`));
|
|
1964
|
-
}
|
|
1965
1989
|
} catch (e) {
|
|
1966
|
-
logger.debug(`Failed to get/create user ID: ${e}`);
|
|
1967
1990
|
this._currUserId = this.UNKNOWN_USER_ID;
|
|
1968
1991
|
}
|
|
1969
1992
|
return this._currUserId;
|
|
1970
1993
|
}
|
|
1971
1994
|
/**
|
|
1972
1995
|
* Get or create user ID from filesystem (Node.js/Bun)
|
|
1996
|
+
* Falls back to session ID if filesystem operations fail
|
|
1973
1997
|
*/
|
|
1974
1998
|
_getUserIdFromFilesystem() {
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1999
|
+
try {
|
|
2000
|
+
let fs2, os, path2;
|
|
2001
|
+
try {
|
|
2002
|
+
fs2 = require("fs");
|
|
2003
|
+
os = require("os");
|
|
2004
|
+
path2 = require("path");
|
|
2005
|
+
} catch (requireError) {
|
|
2006
|
+
try {
|
|
2007
|
+
const sessionId = `session-${generateUUID()}`;
|
|
2008
|
+
return sessionId;
|
|
2009
|
+
} catch (uuidError) {
|
|
2010
|
+
return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
if (!this._userIdPath) {
|
|
2014
|
+
this._userIdPath = path2.join(
|
|
2015
|
+
this._getCacheHome(os, path2),
|
|
2016
|
+
"mcp_use_3",
|
|
2017
|
+
"telemetry_user_id"
|
|
2018
|
+
);
|
|
2019
|
+
}
|
|
2020
|
+
const isFirstTime = !fs2.existsSync(this._userIdPath);
|
|
2021
|
+
if (isFirstTime) {
|
|
2022
|
+
fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
|
|
2023
|
+
let newUserId;
|
|
2024
|
+
try {
|
|
2025
|
+
newUserId = generateUUID();
|
|
2026
|
+
} catch (uuidError) {
|
|
2027
|
+
newUserId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
2028
|
+
}
|
|
2029
|
+
fs2.writeFileSync(this._userIdPath, newUserId);
|
|
2030
|
+
return newUserId;
|
|
2031
|
+
}
|
|
2032
|
+
const userId = fs2.readFileSync(this._userIdPath, "utf-8").trim();
|
|
2033
|
+
return userId;
|
|
2034
|
+
} catch (e) {
|
|
2035
|
+
try {
|
|
2036
|
+
return `session-${generateUUID()}`;
|
|
2037
|
+
} catch (uuidError) {
|
|
2038
|
+
return `session-${Date.now()}-${secureRandomString()}`;
|
|
2039
|
+
}
|
|
1993
2040
|
}
|
|
1994
|
-
return fs2.readFileSync(this._userIdPath, "utf-8").trim();
|
|
1995
2041
|
}
|
|
1996
2042
|
/**
|
|
1997
2043
|
* Get or create user ID from localStorage (Browser)
|
|
@@ -2000,14 +2046,22 @@ var Telemetry = class _Telemetry {
|
|
|
2000
2046
|
try {
|
|
2001
2047
|
let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
|
|
2002
2048
|
if (!userId) {
|
|
2003
|
-
|
|
2049
|
+
try {
|
|
2050
|
+
userId = generateUUID();
|
|
2051
|
+
} catch (uuidError) {
|
|
2052
|
+
userId = `${Date.now()}-${secureRandomString()}`;
|
|
2053
|
+
}
|
|
2004
2054
|
localStorage.setItem(USER_ID_STORAGE_KEY, userId);
|
|
2005
|
-
logger.debug(`Created new browser user ID`);
|
|
2006
2055
|
}
|
|
2007
2056
|
return userId;
|
|
2008
2057
|
} catch (e) {
|
|
2009
|
-
|
|
2010
|
-
|
|
2058
|
+
let sessionId;
|
|
2059
|
+
try {
|
|
2060
|
+
sessionId = `session-${generateUUID()}`;
|
|
2061
|
+
} catch (uuidError) {
|
|
2062
|
+
sessionId = `session-${Date.now()}-${secureRandomString()}`;
|
|
2063
|
+
}
|
|
2064
|
+
return sessionId;
|
|
2011
2065
|
}
|
|
2012
2066
|
}
|
|
2013
2067
|
_getCacheHome(os, path2) {
|
|
@@ -2036,6 +2090,7 @@ var Telemetry = class _Telemetry {
|
|
|
2036
2090
|
if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
|
|
2037
2091
|
return;
|
|
2038
2092
|
}
|
|
2093
|
+
const currentUserId = this.userId;
|
|
2039
2094
|
const properties = { ...event.properties };
|
|
2040
2095
|
properties.mcp_use_version = getPackageVersion();
|
|
2041
2096
|
properties.language = "typescript";
|
|
@@ -2043,9 +2098,8 @@ var Telemetry = class _Telemetry {
|
|
|
2043
2098
|
properties.runtime = this._runtimeEnvironment;
|
|
2044
2099
|
if (this._posthogNodeClient) {
|
|
2045
2100
|
try {
|
|
2046
|
-
logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
|
|
2047
2101
|
this._posthogNodeClient.capture({
|
|
2048
|
-
distinctId:
|
|
2102
|
+
distinctId: currentUserId,
|
|
2049
2103
|
event: event.name,
|
|
2050
2104
|
properties
|
|
2051
2105
|
});
|
|
@@ -2055,10 +2109,9 @@ var Telemetry = class _Telemetry {
|
|
|
2055
2109
|
}
|
|
2056
2110
|
if (this._posthogBrowserClient) {
|
|
2057
2111
|
try {
|
|
2058
|
-
logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
|
|
2059
2112
|
this._posthogBrowserClient.capture(event.name, {
|
|
2060
2113
|
...properties,
|
|
2061
|
-
distinct_id:
|
|
2114
|
+
distinct_id: currentUserId
|
|
2062
2115
|
});
|
|
2063
2116
|
} catch (e) {
|
|
2064
2117
|
logger.debug(
|
|
@@ -2070,7 +2123,7 @@ var Telemetry = class _Telemetry {
|
|
|
2070
2123
|
try {
|
|
2071
2124
|
const scarfProperties = {
|
|
2072
2125
|
...properties,
|
|
2073
|
-
user_id:
|
|
2126
|
+
user_id: currentUserId,
|
|
2074
2127
|
event: event.name
|
|
2075
2128
|
};
|
|
2076
2129
|
await this._scarfClient.logEvent(scarfProperties);
|
|
@@ -2808,6 +2861,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
2808
2861
|
sseReadTimeout;
|
|
2809
2862
|
clientInfo;
|
|
2810
2863
|
preferSse;
|
|
2864
|
+
disableSseFallback;
|
|
2811
2865
|
transportType = null;
|
|
2812
2866
|
streamableTransport = null;
|
|
2813
2867
|
constructor(baseUrl, opts = {}) {
|
|
@@ -2824,6 +2878,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
2824
2878
|
version: "1.0.0"
|
|
2825
2879
|
};
|
|
2826
2880
|
this.preferSse = opts.preferSse ?? false;
|
|
2881
|
+
this.disableSseFallback = opts.disableSseFallback ?? false;
|
|
2827
2882
|
}
|
|
2828
2883
|
/** Establish connection to the MCP implementation via HTTP (streamable or SSE). */
|
|
2829
2884
|
async connect() {
|
|
@@ -2880,6 +2935,13 @@ var HttpConnector = class extends BaseConnector {
|
|
|
2880
2935
|
authError.code = 401;
|
|
2881
2936
|
throw authError;
|
|
2882
2937
|
}
|
|
2938
|
+
if (this.disableSseFallback) {
|
|
2939
|
+
logger.info("SSE fallback disabled - failing connection");
|
|
2940
|
+
await this.cleanupResources();
|
|
2941
|
+
throw new Error(
|
|
2942
|
+
`Streamable HTTP connection failed: ${fallbackReason}. SSE fallback is disabled.`
|
|
2943
|
+
);
|
|
2944
|
+
}
|
|
2883
2945
|
logger.info("\u{1F504} Falling back to SSE transport...");
|
|
2884
2946
|
try {
|
|
2885
2947
|
await this.connectWithSse(baseUrl);
|
|
@@ -3527,7 +3589,9 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
3527
3589
|
wrapTransport,
|
|
3528
3590
|
clientOptions,
|
|
3529
3591
|
samplingCallback,
|
|
3530
|
-
elicitationCallback
|
|
3592
|
+
elicitationCallback,
|
|
3593
|
+
disableSseFallback,
|
|
3594
|
+
preferSse
|
|
3531
3595
|
} = serverConfig;
|
|
3532
3596
|
if (!url) {
|
|
3533
3597
|
throw new Error("Server URL is required");
|
|
@@ -3543,8 +3607,12 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
3543
3607
|
// ← Pass client options (capabilities, etc.) to connector
|
|
3544
3608
|
samplingCallback,
|
|
3545
3609
|
// ← Pass sampling callback to connector
|
|
3546
|
-
elicitationCallback
|
|
3610
|
+
elicitationCallback,
|
|
3547
3611
|
// ← Pass elicitation callback to connector
|
|
3612
|
+
disableSseFallback,
|
|
3613
|
+
// ← Disable automatic SSE fallback
|
|
3614
|
+
preferSse
|
|
3615
|
+
// ← Use SSE transport directly
|
|
3548
3616
|
};
|
|
3549
3617
|
if (clientOptions) {
|
|
3550
3618
|
console.log(
|
|
@@ -5526,6 +5594,8 @@ function createConnectorFromConfig(serverConfig, connectorOptions) {
|
|
|
5526
5594
|
authToken: serverConfig.auth_token || serverConfig.authToken,
|
|
5527
5595
|
// Only force SSE if explicitly requested
|
|
5528
5596
|
preferSse: serverConfig.preferSse || transport === "sse",
|
|
5597
|
+
// Disable SSE fallback if explicitly disabled in config
|
|
5598
|
+
disableSseFallback: serverConfig.disableSseFallback,
|
|
5529
5599
|
...connectorOptions
|
|
5530
5600
|
});
|
|
5531
5601
|
}
|
package/dist/src/browser.js
CHANGED
|
@@ -12,38 +12,35 @@ import {
|
|
|
12
12
|
getSupportedProviders,
|
|
13
13
|
isValidLLMString,
|
|
14
14
|
parseLLMString
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-A4QJRN7Z.js";
|
|
16
16
|
import "../chunk-JRGQRPTN.js";
|
|
17
|
-
import "../chunk-
|
|
17
|
+
import "../chunk-QPIDKGV4.js";
|
|
18
18
|
import {
|
|
19
19
|
BaseAdapter
|
|
20
20
|
} from "../chunk-MFSO5PUW.js";
|
|
21
|
-
import "../chunk-M7WATKYM.js";
|
|
22
21
|
import {
|
|
23
22
|
BrowserMCPClient
|
|
24
|
-
} from "../chunk-
|
|
25
|
-
import {
|
|
26
|
-
BrowserOAuthClientProvider,
|
|
27
|
-
onMcpAuthorization
|
|
28
|
-
} from "../chunk-J75I2C26.js";
|
|
23
|
+
} from "../chunk-VRHAF2WT.js";
|
|
29
24
|
import {
|
|
25
|
+
BaseConnector,
|
|
30
26
|
HttpConnector,
|
|
31
27
|
MCPSession
|
|
32
|
-
} from "../chunk-
|
|
33
|
-
import {
|
|
34
|
-
BaseConnector
|
|
35
|
-
} from "../chunk-XEFWIBQF.js";
|
|
28
|
+
} from "../chunk-GN5HOAV3.js";
|
|
36
29
|
import {
|
|
37
30
|
Tel,
|
|
38
31
|
Telemetry,
|
|
39
32
|
VERSION,
|
|
40
33
|
getPackageVersion,
|
|
41
34
|
setTelemetrySource
|
|
42
|
-
} from "../chunk-
|
|
35
|
+
} from "../chunk-ZLZOOXMJ.js";
|
|
43
36
|
import {
|
|
44
37
|
Logger,
|
|
45
38
|
logger
|
|
46
39
|
} from "../chunk-FRUZDWXH.js";
|
|
40
|
+
import {
|
|
41
|
+
BrowserOAuthClientProvider,
|
|
42
|
+
onMcpAuthorization
|
|
43
|
+
} from "../chunk-J75I2C26.js";
|
|
47
44
|
import "../chunk-3GQAWCBQ.js";
|
|
48
45
|
export {
|
|
49
46
|
BaseAdapter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/client/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IACjD;;;OAGG;WACW,iBAAiB,IAAI,MAAM;gBAI7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAKxC,OAAO,CAAC,gBAAgB;WAkBV,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;IAIlE;;;OAGG;IACH,SAAS,CAAC,yBAAyB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,aAAa;
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/client/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IACjD;;;OAGG;WACW,iBAAiB,IAAI,MAAM;gBAI7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAKxC,OAAO,CAAC,gBAAgB;WAkBV,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;IAIlE;;;OAGG;IACH,SAAS,CAAC,yBAAyB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,aAAa;CA8CjB"}
|