mcp-use 1.11.0-canary.8 → 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-5RTMAOZ6.js → chunk-A4QJRN7Z.js} +5 -1041
- package/dist/{chunk-4LZSXUFM.js → chunk-B7AGEK7F.js} +1 -1
- package/dist/{chunk-TAEHPLGV.js → chunk-GN5HOAV3.js} +664 -136
- package/dist/chunk-QPIDKGV4.js +1246 -0
- package/dist/chunk-UWWLWLS2.js +62 -0
- package/dist/{chunk-ZFZPZ4GE.js → chunk-V77WS6CS.js} +9 -0
- package/dist/{chunk-EBSNALCB.js → chunk-VRHAF2WT.js} +10 -4
- package/dist/{chunk-X7JKFBPN.js → chunk-Y2HHHJQB.js} +159 -8
- package/dist/{chunk-JPKFN73V.js → chunk-ZLZOOXMJ.js} +96 -43
- package/dist/index.cjs +316 -53
- package/dist/index.js +22 -24
- package/dist/notifications-FLGIFS56.js +9 -0
- package/dist/src/agents/index.cjs +153 -47
- 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 -10
- 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 +160 -48
- package/dist/src/browser.js +10 -12
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/client.cjs +3852 -0
- package/dist/src/client.d.ts +2 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +21 -0
- 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 +313 -52
- package/dist/src/react/index.js +7 -8
- package/dist/src/react/types.d.ts +41 -1
- package/dist/src/react/types.d.ts.map +1 -1
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/dist/src/server/endpoints/mount-mcp.d.ts.map +1 -1
- package/dist/src/server/index.cjs +1339 -256
- package/dist/src/server/index.d.ts +2 -0
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/index.js +1119 -156
- package/dist/src/server/mcp-server.d.ts +4 -1
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/notifications/index.d.ts +1 -1
- package/dist/src/server/notifications/index.d.ts.map +1 -1
- package/dist/src/server/notifications/notification-registration.d.ts +51 -0
- package/dist/src/server/notifications/notification-registration.d.ts.map +1 -1
- package/dist/src/server/sessions/index.d.ts +3 -1
- package/dist/src/server/sessions/index.d.ts.map +1 -1
- package/dist/src/server/sessions/session-manager.d.ts +30 -16
- package/dist/src/server/sessions/session-manager.d.ts.map +1 -1
- package/dist/src/server/sessions/stores/filesystem.d.ts +121 -0
- package/dist/src/server/sessions/stores/filesystem.d.ts.map +1 -0
- package/dist/src/server/sessions/stores/index.d.ts +94 -0
- package/dist/src/server/sessions/stores/index.d.ts.map +1 -0
- package/dist/src/server/sessions/stores/memory.d.ts +82 -0
- package/dist/src/server/sessions/stores/memory.d.ts.map +1 -0
- package/dist/src/server/sessions/stores/redis.d.ts +164 -0
- package/dist/src/server/sessions/stores/redis.d.ts.map +1 -0
- package/dist/src/server/sessions/streams/index.d.ts +77 -0
- package/dist/src/server/sessions/streams/index.d.ts.map +1 -0
- package/dist/src/server/sessions/streams/memory.d.ts +76 -0
- package/dist/src/server/sessions/streams/memory.d.ts.map +1 -0
- package/dist/src/server/sessions/streams/redis.d.ts +146 -0
- package/dist/src/server/sessions/streams/redis.d.ts.map +1 -0
- package/dist/src/server/types/common.d.ts +82 -28
- package/dist/src/server/types/common.d.ts.map +1 -1
- 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/utils/response-helpers.d.ts +4 -2
- package/dist/src/server/utils/response-helpers.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/task_managers/index.d.ts +10 -0
- package/dist/src/task_managers/index.d.ts.map +1 -1
- package/dist/src/task_managers/sse.d.ts +34 -1
- package/dist/src/task_managers/sse.d.ts.map +1 -1
- package/dist/src/task_managers/streamable_http.d.ts +8 -2
- package/dist/src/task_managers/streamable_http.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-EYAIJERC.js → tool-execution-helpers-ZUA5D5IO.js} +2 -2
- package/dist/tsup.config.d.ts.map +1 -1
- package/package.json +62 -52
- package/dist/chunk-GVU7C2ZD.js +0 -12
- package/dist/chunk-JZNXOM7C.js +0 -204
- package/dist/chunk-XKTBHYNM.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
|
@@ -1417,7 +1417,7 @@ __name(generateUUID, "generateUUID");
|
|
|
1417
1417
|
init_logging();
|
|
1418
1418
|
|
|
1419
1419
|
// src/version.ts
|
|
1420
|
-
var VERSION = "1.11.0
|
|
1420
|
+
var VERSION = "1.11.0";
|
|
1421
1421
|
function getPackageVersion() {
|
|
1422
1422
|
return VERSION;
|
|
1423
1423
|
}
|
|
@@ -1456,6 +1456,20 @@ function extractModelInfo(llm) {
|
|
|
1456
1456
|
__name(extractModelInfo, "extractModelInfo");
|
|
1457
1457
|
|
|
1458
1458
|
// src/telemetry/telemetry.ts
|
|
1459
|
+
function secureRandomString() {
|
|
1460
|
+
if (typeof window !== "undefined" && window.crypto && typeof window.crypto.getRandomValues === "function") {
|
|
1461
|
+
const array = new Uint8Array(8);
|
|
1462
|
+
window.crypto.getRandomValues(array);
|
|
1463
|
+
return Array.from(array, (v) => v.toString(16).padStart(2, "0")).join("");
|
|
1464
|
+
}
|
|
1465
|
+
try {
|
|
1466
|
+
const crypto = require("crypto");
|
|
1467
|
+
return crypto.randomBytes(8).toString("hex");
|
|
1468
|
+
} catch (e) {
|
|
1469
|
+
return Math.random().toString(36).substring(2, 15);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
__name(secureRandomString, "secureRandomString");
|
|
1459
1473
|
var USER_ID_STORAGE_KEY = "mcp_use_user_id";
|
|
1460
1474
|
function detectRuntimeEnvironment() {
|
|
1461
1475
|
try {
|
|
@@ -1587,12 +1601,26 @@ var Telemetry = class _Telemetry {
|
|
|
1587
1601
|
"Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
|
|
1588
1602
|
);
|
|
1589
1603
|
this._posthogLoading = this._initPostHog();
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1604
|
+
if (this._runtimeEnvironment !== "browser") {
|
|
1605
|
+
try {
|
|
1606
|
+
this._scarfClient = new ScarfEventLogger(
|
|
1607
|
+
this.SCARF_GATEWAY_URL,
|
|
1608
|
+
3e3
|
|
1609
|
+
);
|
|
1610
|
+
} catch (e) {
|
|
1611
|
+
logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
|
|
1612
|
+
this._scarfClient = null;
|
|
1613
|
+
}
|
|
1614
|
+
} else {
|
|
1594
1615
|
this._scarfClient = null;
|
|
1595
1616
|
}
|
|
1617
|
+
if (this._storageCapability === "filesystem" && this._scarfClient) {
|
|
1618
|
+
setTimeout(() => {
|
|
1619
|
+
this.trackPackageDownload({ triggered_by: "initialization" }).catch(
|
|
1620
|
+
(e) => logger.debug(`Failed to track package download: ${e}`)
|
|
1621
|
+
);
|
|
1622
|
+
}, 0);
|
|
1623
|
+
}
|
|
1596
1624
|
}
|
|
1597
1625
|
}
|
|
1598
1626
|
_checkTelemetryDisabled() {
|
|
@@ -1717,47 +1745,65 @@ var Telemetry = class _Telemetry {
|
|
|
1717
1745
|
break;
|
|
1718
1746
|
case "session-only":
|
|
1719
1747
|
default:
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1748
|
+
try {
|
|
1749
|
+
this._currUserId = `session-${generateUUID()}`;
|
|
1750
|
+
} catch (uuidError) {
|
|
1751
|
+
this._currUserId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1752
|
+
}
|
|
1724
1753
|
break;
|
|
1725
1754
|
}
|
|
1726
|
-
if (this._storageCapability === "filesystem" && this._currUserId) {
|
|
1727
|
-
this._trackPackageDownloadInternal(this._currUserId, {
|
|
1728
|
-
triggered_by: "user_id_property"
|
|
1729
|
-
}).catch((e) => logger.debug(`Failed to track package download: ${e}`));
|
|
1730
|
-
}
|
|
1731
1755
|
} catch (e) {
|
|
1732
|
-
logger.debug(`Failed to get/create user ID: ${e}`);
|
|
1733
1756
|
this._currUserId = this.UNKNOWN_USER_ID;
|
|
1734
1757
|
}
|
|
1735
1758
|
return this._currUserId;
|
|
1736
1759
|
}
|
|
1737
1760
|
/**
|
|
1738
1761
|
* Get or create user ID from filesystem (Node.js/Bun)
|
|
1762
|
+
* Falls back to session ID if filesystem operations fail
|
|
1739
1763
|
*/
|
|
1740
1764
|
_getUserIdFromFilesystem() {
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1765
|
+
try {
|
|
1766
|
+
let fs2, os, path2;
|
|
1767
|
+
try {
|
|
1768
|
+
fs2 = require("fs");
|
|
1769
|
+
os = require("os");
|
|
1770
|
+
path2 = require("path");
|
|
1771
|
+
} catch (requireError) {
|
|
1772
|
+
try {
|
|
1773
|
+
const sessionId = `session-${generateUUID()}`;
|
|
1774
|
+
return sessionId;
|
|
1775
|
+
} catch (uuidError) {
|
|
1776
|
+
return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
if (!this._userIdPath) {
|
|
1780
|
+
this._userIdPath = path2.join(
|
|
1781
|
+
this._getCacheHome(os, path2),
|
|
1782
|
+
"mcp_use_3",
|
|
1783
|
+
"telemetry_user_id"
|
|
1784
|
+
);
|
|
1785
|
+
}
|
|
1786
|
+
const isFirstTime = !fs2.existsSync(this._userIdPath);
|
|
1787
|
+
if (isFirstTime) {
|
|
1788
|
+
fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
|
|
1789
|
+
let newUserId;
|
|
1790
|
+
try {
|
|
1791
|
+
newUserId = generateUUID();
|
|
1792
|
+
} catch (uuidError) {
|
|
1793
|
+
newUserId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1794
|
+
}
|
|
1795
|
+
fs2.writeFileSync(this._userIdPath, newUserId);
|
|
1796
|
+
return newUserId;
|
|
1797
|
+
}
|
|
1798
|
+
const userId = fs2.readFileSync(this._userIdPath, "utf-8").trim();
|
|
1799
|
+
return userId;
|
|
1800
|
+
} catch (e) {
|
|
1801
|
+
try {
|
|
1802
|
+
return `session-${generateUUID()}`;
|
|
1803
|
+
} catch (uuidError) {
|
|
1804
|
+
return `session-${Date.now()}-${secureRandomString()}`;
|
|
1805
|
+
}
|
|
1759
1806
|
}
|
|
1760
|
-
return fs2.readFileSync(this._userIdPath, "utf-8").trim();
|
|
1761
1807
|
}
|
|
1762
1808
|
/**
|
|
1763
1809
|
* Get or create user ID from localStorage (Browser)
|
|
@@ -1766,14 +1812,22 @@ var Telemetry = class _Telemetry {
|
|
|
1766
1812
|
try {
|
|
1767
1813
|
let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
|
|
1768
1814
|
if (!userId) {
|
|
1769
|
-
|
|
1815
|
+
try {
|
|
1816
|
+
userId = generateUUID();
|
|
1817
|
+
} catch (uuidError) {
|
|
1818
|
+
userId = `${Date.now()}-${secureRandomString()}`;
|
|
1819
|
+
}
|
|
1770
1820
|
localStorage.setItem(USER_ID_STORAGE_KEY, userId);
|
|
1771
|
-
logger.debug(`Created new browser user ID`);
|
|
1772
1821
|
}
|
|
1773
1822
|
return userId;
|
|
1774
1823
|
} catch (e) {
|
|
1775
|
-
|
|
1776
|
-
|
|
1824
|
+
let sessionId;
|
|
1825
|
+
try {
|
|
1826
|
+
sessionId = `session-${generateUUID()}`;
|
|
1827
|
+
} catch (uuidError) {
|
|
1828
|
+
sessionId = `session-${Date.now()}-${secureRandomString()}`;
|
|
1829
|
+
}
|
|
1830
|
+
return sessionId;
|
|
1777
1831
|
}
|
|
1778
1832
|
}
|
|
1779
1833
|
_getCacheHome(os, path2) {
|
|
@@ -1802,6 +1856,7 @@ var Telemetry = class _Telemetry {
|
|
|
1802
1856
|
if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
|
|
1803
1857
|
return;
|
|
1804
1858
|
}
|
|
1859
|
+
const currentUserId = this.userId;
|
|
1805
1860
|
const properties = { ...event.properties };
|
|
1806
1861
|
properties.mcp_use_version = getPackageVersion();
|
|
1807
1862
|
properties.language = "typescript";
|
|
@@ -1809,9 +1864,8 @@ var Telemetry = class _Telemetry {
|
|
|
1809
1864
|
properties.runtime = this._runtimeEnvironment;
|
|
1810
1865
|
if (this._posthogNodeClient) {
|
|
1811
1866
|
try {
|
|
1812
|
-
logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
|
|
1813
1867
|
this._posthogNodeClient.capture({
|
|
1814
|
-
distinctId:
|
|
1868
|
+
distinctId: currentUserId,
|
|
1815
1869
|
event: event.name,
|
|
1816
1870
|
properties
|
|
1817
1871
|
});
|
|
@@ -1821,10 +1875,9 @@ var Telemetry = class _Telemetry {
|
|
|
1821
1875
|
}
|
|
1822
1876
|
if (this._posthogBrowserClient) {
|
|
1823
1877
|
try {
|
|
1824
|
-
logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
|
|
1825
1878
|
this._posthogBrowserClient.capture(event.name, {
|
|
1826
1879
|
...properties,
|
|
1827
|
-
distinct_id:
|
|
1880
|
+
distinct_id: currentUserId
|
|
1828
1881
|
});
|
|
1829
1882
|
} catch (e) {
|
|
1830
1883
|
logger.debug(
|
|
@@ -1836,7 +1889,7 @@ var Telemetry = class _Telemetry {
|
|
|
1836
1889
|
try {
|
|
1837
1890
|
const scarfProperties = {
|
|
1838
1891
|
...properties,
|
|
1839
|
-
user_id:
|
|
1892
|
+
user_id: currentUserId,
|
|
1840
1893
|
event: event.name
|
|
1841
1894
|
};
|
|
1842
1895
|
await this._scarfClient.logEvent(scarfProperties);
|
|
@@ -2752,7 +2805,7 @@ var CodeModeConnector = class extends BaseConnector {
|
|
|
2752
2805
|
}
|
|
2753
2806
|
};
|
|
2754
2807
|
|
|
2755
|
-
// src/
|
|
2808
|
+
// src/agents/prompts/index.ts
|
|
2756
2809
|
var PROMPTS = {
|
|
2757
2810
|
CODE_MODE: CODE_MODE_AGENT_PROMPT
|
|
2758
2811
|
};
|
|
@@ -4994,6 +5047,7 @@ var SseConnectionManager = class extends ConnectionManager {
|
|
|
4994
5047
|
url;
|
|
4995
5048
|
opts;
|
|
4996
5049
|
_transport = null;
|
|
5050
|
+
reinitializing = false;
|
|
4997
5051
|
/**
|
|
4998
5052
|
* Create an SSE connection manager.
|
|
4999
5053
|
*
|
|
@@ -5006,12 +5060,53 @@ var SseConnectionManager = class extends ConnectionManager {
|
|
|
5006
5060
|
this.opts = opts;
|
|
5007
5061
|
}
|
|
5008
5062
|
/**
|
|
5009
|
-
* Spawn a new `SSEClientTransport` and
|
|
5063
|
+
* Spawn a new `SSEClientTransport` and wrap it with 404 handling.
|
|
5064
|
+
* Per MCP spec, clients MUST re-initialize when receiving 404 for stale sessions.
|
|
5010
5065
|
*/
|
|
5011
5066
|
async establishConnection() {
|
|
5012
|
-
|
|
5067
|
+
const transport = new import_sse.SSEClientTransport(this.url, this.opts);
|
|
5068
|
+
const originalSend = transport.send.bind(transport);
|
|
5069
|
+
transport.send = async (message) => {
|
|
5070
|
+
const sendMessage = /* @__PURE__ */ __name(async (msg) => {
|
|
5071
|
+
if (Array.isArray(msg)) {
|
|
5072
|
+
for (const singleMsg of msg) {
|
|
5073
|
+
await originalSend(singleMsg);
|
|
5074
|
+
}
|
|
5075
|
+
} else {
|
|
5076
|
+
await originalSend(msg);
|
|
5077
|
+
}
|
|
5078
|
+
}, "sendMessage");
|
|
5079
|
+
try {
|
|
5080
|
+
await sendMessage(message);
|
|
5081
|
+
} catch (error) {
|
|
5082
|
+
if (error?.code === 404 && transport.sessionId && !this.reinitializing) {
|
|
5083
|
+
logger.warn(
|
|
5084
|
+
`[SSE] Session not found (404), re-initializing per MCP spec...`
|
|
5085
|
+
);
|
|
5086
|
+
this.reinitializing = true;
|
|
5087
|
+
try {
|
|
5088
|
+
transport.sessionId = void 0;
|
|
5089
|
+
await this.reinitialize(transport);
|
|
5090
|
+
logger.info(`[SSE] Re-initialization successful, retrying request`);
|
|
5091
|
+
await sendMessage(message);
|
|
5092
|
+
} finally {
|
|
5093
|
+
this.reinitializing = false;
|
|
5094
|
+
}
|
|
5095
|
+
} else {
|
|
5096
|
+
throw error;
|
|
5097
|
+
}
|
|
5098
|
+
}
|
|
5099
|
+
};
|
|
5100
|
+
this._transport = transport;
|
|
5013
5101
|
logger.debug(`${this.constructor.name} connected successfully`);
|
|
5014
|
-
return
|
|
5102
|
+
return transport;
|
|
5103
|
+
}
|
|
5104
|
+
/**
|
|
5105
|
+
* Re-initialize the transport with a new session
|
|
5106
|
+
* This is called when the server returns 404 for a stale session
|
|
5107
|
+
*/
|
|
5108
|
+
async reinitialize(transport) {
|
|
5109
|
+
logger.debug(`[SSE] Re-initialization triggered`);
|
|
5015
5110
|
}
|
|
5016
5111
|
/**
|
|
5017
5112
|
* Close the underlying transport and clean up resources.
|
|
@@ -5040,6 +5135,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
5040
5135
|
sseReadTimeout;
|
|
5041
5136
|
clientInfo;
|
|
5042
5137
|
preferSse;
|
|
5138
|
+
disableSseFallback;
|
|
5043
5139
|
transportType = null;
|
|
5044
5140
|
streamableTransport = null;
|
|
5045
5141
|
constructor(baseUrl, opts = {}) {
|
|
@@ -5056,6 +5152,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
5056
5152
|
version: "1.0.0"
|
|
5057
5153
|
};
|
|
5058
5154
|
this.preferSse = opts.preferSse ?? false;
|
|
5155
|
+
this.disableSseFallback = opts.disableSseFallback ?? false;
|
|
5059
5156
|
}
|
|
5060
5157
|
/** Establish connection to the MCP implementation via HTTP (streamable or SSE). */
|
|
5061
5158
|
async connect() {
|
|
@@ -5112,6 +5209,13 @@ var HttpConnector = class extends BaseConnector {
|
|
|
5112
5209
|
authError.code = 401;
|
|
5113
5210
|
throw authError;
|
|
5114
5211
|
}
|
|
5212
|
+
if (this.disableSseFallback) {
|
|
5213
|
+
logger.info("SSE fallback disabled - failing connection");
|
|
5214
|
+
await this.cleanupResources();
|
|
5215
|
+
throw new Error(
|
|
5216
|
+
`Streamable HTTP connection failed: ${fallbackReason}. SSE fallback is disabled.`
|
|
5217
|
+
);
|
|
5218
|
+
}
|
|
5115
5219
|
logger.info("\u{1F504} Falling back to SSE transport...");
|
|
5116
5220
|
try {
|
|
5117
5221
|
await this.connectWithSse(baseUrl);
|
|
@@ -5478,6 +5582,8 @@ function createConnectorFromConfig(serverConfig, connectorOptions) {
|
|
|
5478
5582
|
authToken: serverConfig.auth_token || serverConfig.authToken,
|
|
5479
5583
|
// Only force SSE if explicitly requested
|
|
5480
5584
|
preferSse: serverConfig.preferSse || transport === "sse",
|
|
5585
|
+
// Disable SSE fallback if explicitly disabled in config
|
|
5586
|
+
disableSseFallback: serverConfig.disableSseFallback,
|
|
5481
5587
|
...connectorOptions
|
|
5482
5588
|
});
|
|
5483
5589
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,eAAe,EACf,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/src/agents/index.js
CHANGED
|
@@ -1,19 +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";
|
|
10
|
+
import "../../chunk-QPIDKGV4.js";
|
|
9
11
|
import "../../chunk-MFSO5PUW.js";
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
} from "../../chunk-GVU7C2ZD.js";
|
|
13
|
-
import "../../chunk-JZNXOM7C.js";
|
|
14
|
-
import "../../chunk-TAEHPLGV.js";
|
|
15
|
-
import "../../chunk-XKTBHYNM.js";
|
|
16
|
-
import "../../chunk-JPKFN73V.js";
|
|
12
|
+
import "../../chunk-GN5HOAV3.js";
|
|
13
|
+
import "../../chunk-ZLZOOXMJ.js";
|
|
17
14
|
import "../../chunk-FRUZDWXH.js";
|
|
18
15
|
import "../../chunk-3GQAWCBQ.js";
|
|
19
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,W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
-
* Prompt templates for MCP
|
|
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"}
|