integrate-sdk 0.9.58 → 0.9.61
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/adapters/index.js +1 -1
- package/dist/adapters/solid-start.js +1 -1
- package/dist/adapters/svelte-kit.js +1 -1
- package/dist/ai/index.js +77 -0
- package/dist/ai/tool-cache.d.ts +50 -0
- package/dist/ai/tool-cache.d.ts.map +1 -0
- package/dist/ai/utils.d.ts +5 -0
- package/dist/ai/utils.d.ts.map +1 -1
- package/dist/ai/vercel-ai.d.ts.map +1 -1
- package/dist/ai/vercel-ai.js +77 -0
- package/dist/index.js +65 -1
- package/dist/integrations.js +65 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +86 -0
- package/dist/server.js +341 -29
- package/dist/src/ai/tool-cache.d.ts +50 -0
- package/dist/src/ai/tool-cache.d.ts.map +1 -0
- package/dist/src/ai/utils.d.ts +5 -0
- package/dist/src/ai/utils.d.ts.map +1 -1
- package/dist/src/ai/vercel-ai.d.ts.map +1 -1
- package/dist/src/client.d.ts +1 -3
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +11 -0
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/integrations/bundle.d.ts +18 -0
- package/dist/src/integrations/bundle.d.ts.map +1 -0
- package/dist/src/react/hooks.d.ts +16 -0
- package/dist/src/react/hooks.d.ts.map +1 -1
- package/dist/src/server.d.ts +12 -0
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/utils/normalize-tool-name.d.ts +14 -0
- package/dist/src/utils/normalize-tool-name.d.ts.map +1 -0
- package/dist/src/utils/parse-tool-result.d.ts +23 -0
- package/dist/src/utils/parse-tool-result.d.ts.map +1 -0
- package/package.json +1 -1
- package/react.ts +10 -2
package/dist/server.js
CHANGED
|
@@ -5298,7 +5298,7 @@ class MCPClientBase {
|
|
|
5298
5298
|
logger5.debug(`Discovered ${totalDiscovered} tools, ${enabledCount} enabled by integrations`);
|
|
5299
5299
|
}
|
|
5300
5300
|
async _callToolByName(name, args, options) {
|
|
5301
|
-
return await this.
|
|
5301
|
+
return await this.callTool(name, args, options);
|
|
5302
5302
|
}
|
|
5303
5303
|
async callTool(name, args, options) {
|
|
5304
5304
|
return await this.callToolWithRetry(name, args, 0, options);
|
|
@@ -6148,6 +6148,51 @@ async function sendWebResponse(webRes, nodeRes) {
|
|
|
6148
6148
|
// src/server.ts
|
|
6149
6149
|
init_logger();
|
|
6150
6150
|
|
|
6151
|
+
// src/utils/normalize-tool-name.ts
|
|
6152
|
+
var TOOL_ALIASES = {
|
|
6153
|
+
github_list_repo_contents: "github_get_file_contents",
|
|
6154
|
+
gdrive_list: "gdrive_list_files",
|
|
6155
|
+
gdrive_get: "gdrive_get_file",
|
|
6156
|
+
gdrive_delete: "gdrive_delete_file",
|
|
6157
|
+
gdrive_trash: "gdrive_trash_file",
|
|
6158
|
+
gdrive_upload: "gdrive_upload_text_file",
|
|
6159
|
+
gdrive_download: "gdrive_download_file",
|
|
6160
|
+
slack_send: "slack_send_message",
|
|
6161
|
+
gmail_send: "gmail_send_email",
|
|
6162
|
+
notion_create_page: "notion_create_page"
|
|
6163
|
+
};
|
|
6164
|
+
function normalizeToolName(toolName, integrationCandidates = []) {
|
|
6165
|
+
if (TOOL_ALIASES[toolName]) {
|
|
6166
|
+
return TOOL_ALIASES[toolName];
|
|
6167
|
+
}
|
|
6168
|
+
const tripleIdx = toolName.indexOf("___");
|
|
6169
|
+
if (tripleIdx > 0) {
|
|
6170
|
+
const prefix = toolName.slice(0, tripleIdx);
|
|
6171
|
+
const suffix = toolName.slice(tripleIdx + 3);
|
|
6172
|
+
if (integrationCandidates.some((c) => c === prefix)) {
|
|
6173
|
+
if (suffix.startsWith("_")) {
|
|
6174
|
+
return `___${suffix.slice(1)}`;
|
|
6175
|
+
}
|
|
6176
|
+
return `${prefix}_${suffix}`;
|
|
6177
|
+
}
|
|
6178
|
+
}
|
|
6179
|
+
for (const candidate of integrationCandidates) {
|
|
6180
|
+
const doublePrefix = `${candidate}_${candidate}_`;
|
|
6181
|
+
if (toolName.startsWith(doublePrefix)) {
|
|
6182
|
+
return `${candidate}_${toolName.slice(doublePrefix.length)}`;
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
const firstUnderscore = toolName.indexOf("_");
|
|
6186
|
+
if (firstUnderscore > 0) {
|
|
6187
|
+
const prefix = toolName.slice(0, firstUnderscore);
|
|
6188
|
+
const rest = toolName.slice(firstUnderscore + 1);
|
|
6189
|
+
if (integrationCandidates.includes(prefix) && rest.startsWith(`${prefix}_`)) {
|
|
6190
|
+
return `${prefix}_${rest.slice(prefix.length + 1)}`;
|
|
6191
|
+
}
|
|
6192
|
+
}
|
|
6193
|
+
return toolName;
|
|
6194
|
+
}
|
|
6195
|
+
|
|
6151
6196
|
// src/integrations/github.ts
|
|
6152
6197
|
init_logger();
|
|
6153
6198
|
var logger8 = createLogger("GitHub");
|
|
@@ -18834,6 +18879,82 @@ function createTriggerTools(config, context) {
|
|
|
18834
18879
|
|
|
18835
18880
|
// src/ai/vercel-ai.ts
|
|
18836
18881
|
init_tool_builder();
|
|
18882
|
+
|
|
18883
|
+
// src/ai/tool-cache.ts
|
|
18884
|
+
function buildToolDiscoveryCacheKey(userId, connectedIntegrationIds) {
|
|
18885
|
+
const sorted = [...connectedIntegrationIds].sort().join(",");
|
|
18886
|
+
return `${userId}:${sorted}`;
|
|
18887
|
+
}
|
|
18888
|
+
function createMemoryToolDiscoveryCache() {
|
|
18889
|
+
const store = new Map;
|
|
18890
|
+
return {
|
|
18891
|
+
async get(key) {
|
|
18892
|
+
const entry = store.get(key);
|
|
18893
|
+
if (!entry)
|
|
18894
|
+
return null;
|
|
18895
|
+
if (entry.expiresAt <= Date.now()) {
|
|
18896
|
+
store.delete(key);
|
|
18897
|
+
return null;
|
|
18898
|
+
}
|
|
18899
|
+
return entry.stubs;
|
|
18900
|
+
},
|
|
18901
|
+
async set(key, stubs, ttlMs = 5 * 60 * 1000) {
|
|
18902
|
+
store.set(key, { stubs, expiresAt: Date.now() + ttlMs });
|
|
18903
|
+
},
|
|
18904
|
+
async invalidate(userIdOrKey) {
|
|
18905
|
+
for (const key of [...store.keys()]) {
|
|
18906
|
+
if (key === userIdOrKey || key.startsWith(`${userIdOrKey}:`)) {
|
|
18907
|
+
store.delete(key);
|
|
18908
|
+
}
|
|
18909
|
+
}
|
|
18910
|
+
}
|
|
18911
|
+
};
|
|
18912
|
+
}
|
|
18913
|
+
function createToolDiscoveryCacheInvalidator(cache) {
|
|
18914
|
+
return ({ userId }) => {
|
|
18915
|
+
cache.invalidate(userId);
|
|
18916
|
+
};
|
|
18917
|
+
}
|
|
18918
|
+
async function resolveToolDiscoveryCacheKey(client, context, options) {
|
|
18919
|
+
const userId = context.userId;
|
|
18920
|
+
if (!userId)
|
|
18921
|
+
return;
|
|
18922
|
+
const configuredIds = (client.integrations ?? []).map((i) => i.id);
|
|
18923
|
+
let targetIds;
|
|
18924
|
+
if (options?.integrationIds?.length) {
|
|
18925
|
+
targetIds = options.integrationIds;
|
|
18926
|
+
} else if (options?.connectedOnly) {
|
|
18927
|
+
targetIds = await listConnectedProviders(configuredIds, (provider, email, ctx) => client.getProviderToken(provider, email, ctx), context);
|
|
18928
|
+
} else {
|
|
18929
|
+
targetIds = configuredIds;
|
|
18930
|
+
}
|
|
18931
|
+
return buildToolDiscoveryCacheKey(userId, targetIds);
|
|
18932
|
+
}
|
|
18933
|
+
function stubsFromTools(tools) {
|
|
18934
|
+
return tools.map((t) => ({
|
|
18935
|
+
name: t.name,
|
|
18936
|
+
description: t.description,
|
|
18937
|
+
inputSchema: t.inputSchema
|
|
18938
|
+
}));
|
|
18939
|
+
}
|
|
18940
|
+
function applyToolDiscoveryCache(client, stubs) {
|
|
18941
|
+
client.hydrateToolCache(stubs);
|
|
18942
|
+
}
|
|
18943
|
+
async function persistToolDiscoveryCache(client, cache, cacheKey, ttlMs) {
|
|
18944
|
+
const tools = client.getAvailableTools();
|
|
18945
|
+
if (tools.length === 0)
|
|
18946
|
+
return;
|
|
18947
|
+
await cache.set(cacheKey, stubsFromTools(tools), ttlMs);
|
|
18948
|
+
}
|
|
18949
|
+
async function warmToolDiscoveryFromCache(client, cache, cacheKey) {
|
|
18950
|
+
const stubs = await cache.get(cacheKey);
|
|
18951
|
+
if (!stubs || stubs.length === 0)
|
|
18952
|
+
return false;
|
|
18953
|
+
applyToolDiscoveryCache(client, stubs);
|
|
18954
|
+
return true;
|
|
18955
|
+
}
|
|
18956
|
+
|
|
18957
|
+
// src/ai/vercel-ai.ts
|
|
18837
18958
|
function convertMCPToolToVercelAI(mcpTool, client, options) {
|
|
18838
18959
|
return {
|
|
18839
18960
|
description: mcpTool.description || `Execute ${mcpTool.name}`,
|
|
@@ -18855,7 +18976,21 @@ async function getVercelAITools(client, options) {
|
|
|
18855
18976
|
}
|
|
18856
18977
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
18857
18978
|
await ensureClientConnected(client);
|
|
18979
|
+
const cacheConfig = options?.cache;
|
|
18980
|
+
let cacheKey;
|
|
18981
|
+
if (cacheConfig?.cache && options?.context) {
|
|
18982
|
+
cacheKey = await resolveToolDiscoveryCacheKey(client, options.context, {
|
|
18983
|
+
integrationIds: options.integrationIds,
|
|
18984
|
+
connectedOnly: options.connectedOnly
|
|
18985
|
+
});
|
|
18986
|
+
if (cacheKey) {
|
|
18987
|
+
await warmToolDiscoveryFromCache(client, cacheConfig.cache, cacheKey);
|
|
18988
|
+
}
|
|
18989
|
+
}
|
|
18858
18990
|
const mcpTools = await client.getEnabledToolsAsync(toEnabledToolsAsyncOptions(options));
|
|
18991
|
+
if (cacheConfig?.cache && cacheKey) {
|
|
18992
|
+
await persistToolDiscoveryCache(client, cacheConfig.cache, cacheKey, cacheConfig.ttlMs);
|
|
18993
|
+
}
|
|
18859
18994
|
const vercelTools = {};
|
|
18860
18995
|
let effectiveMode;
|
|
18861
18996
|
if (options?.mode !== undefined) {
|
|
@@ -21432,6 +21567,126 @@ function zohoSprintsIntegration(config = {}) {
|
|
|
21432
21567
|
}
|
|
21433
21568
|
};
|
|
21434
21569
|
}
|
|
21570
|
+
// src/integrations/bundle.ts
|
|
21571
|
+
function allIntegrations() {
|
|
21572
|
+
return [
|
|
21573
|
+
githubIntegration(),
|
|
21574
|
+
gmailIntegration(),
|
|
21575
|
+
notionIntegration(),
|
|
21576
|
+
slackIntegration(),
|
|
21577
|
+
discordIntegration(),
|
|
21578
|
+
boxIntegration(),
|
|
21579
|
+
paypalIntegration(),
|
|
21580
|
+
squareIntegration(),
|
|
21581
|
+
spotifyIntegration(),
|
|
21582
|
+
stravaIntegration(),
|
|
21583
|
+
asanaIntegration(),
|
|
21584
|
+
confluenceIntegration(),
|
|
21585
|
+
oktaIntegration(),
|
|
21586
|
+
quickbooksIntegration(),
|
|
21587
|
+
bitbucketIntegration(),
|
|
21588
|
+
smartthingsIntegration(),
|
|
21589
|
+
googleAdsIntegration(),
|
|
21590
|
+
pinterestIntegration(),
|
|
21591
|
+
twitchIntegration(),
|
|
21592
|
+
xIntegration(),
|
|
21593
|
+
ebayIntegration(),
|
|
21594
|
+
miroIntegration(),
|
|
21595
|
+
smartsheetIntegration(),
|
|
21596
|
+
docusignIntegration(),
|
|
21597
|
+
pipedriveIntegration(),
|
|
21598
|
+
freshserviceIntegration(),
|
|
21599
|
+
zohoCrmIntegration(),
|
|
21600
|
+
zohoMailIntegration(),
|
|
21601
|
+
zohoDeskIntegration(),
|
|
21602
|
+
zohoBooksIntegration(),
|
|
21603
|
+
zohoProjectsIntegration(),
|
|
21604
|
+
zohoCampaignsIntegration(),
|
|
21605
|
+
zohoAnalyticsIntegration(),
|
|
21606
|
+
zohoInvoiceIntegration(),
|
|
21607
|
+
linearIntegration(),
|
|
21608
|
+
vercelIntegration(),
|
|
21609
|
+
zendeskIntegration(),
|
|
21610
|
+
stripeIntegration(),
|
|
21611
|
+
gcalIntegration(),
|
|
21612
|
+
gmeetIntegration(),
|
|
21613
|
+
gtasksIntegration(),
|
|
21614
|
+
gkeepIntegration(),
|
|
21615
|
+
gcontactsIntegration(),
|
|
21616
|
+
outlookIntegration(),
|
|
21617
|
+
teamsIntegration(),
|
|
21618
|
+
airtableIntegration(),
|
|
21619
|
+
attioIntegration(),
|
|
21620
|
+
todoistIntegration(),
|
|
21621
|
+
whatsappIntegration(),
|
|
21622
|
+
calcomIntegration(),
|
|
21623
|
+
canvaIntegration(),
|
|
21624
|
+
cloudflareIntegration(),
|
|
21625
|
+
rampIntegration(),
|
|
21626
|
+
onedriveIntegration(),
|
|
21627
|
+
plannerIntegration(),
|
|
21628
|
+
sharepointIntegration(),
|
|
21629
|
+
wordIntegration(),
|
|
21630
|
+
excelIntegration(),
|
|
21631
|
+
powerpointIntegration(),
|
|
21632
|
+
gdocsIntegration(),
|
|
21633
|
+
gdriveIntegration(),
|
|
21634
|
+
gsheetsIntegration(),
|
|
21635
|
+
gslidesIntegration(),
|
|
21636
|
+
polarIntegration(),
|
|
21637
|
+
facebookIntegration(),
|
|
21638
|
+
figmaIntegration(),
|
|
21639
|
+
intercomIntegration(),
|
|
21640
|
+
hubspotIntegration(),
|
|
21641
|
+
instagramIntegration(),
|
|
21642
|
+
linkedinIntegration(),
|
|
21643
|
+
threadsIntegration(),
|
|
21644
|
+
tiktokIntegration(),
|
|
21645
|
+
typeformIntegration(),
|
|
21646
|
+
xeroIntegration(),
|
|
21647
|
+
gchatIntegration(),
|
|
21648
|
+
shopifyIntegration(),
|
|
21649
|
+
youtubeIntegration(),
|
|
21650
|
+
zoomIntegration(),
|
|
21651
|
+
redditIntegration(),
|
|
21652
|
+
cursorIntegration(),
|
|
21653
|
+
posthogIntegration(),
|
|
21654
|
+
sentryIntegration(),
|
|
21655
|
+
datadogIntegration(),
|
|
21656
|
+
netlifyIntegration(),
|
|
21657
|
+
mondayIntegration(),
|
|
21658
|
+
webflowIntegration(),
|
|
21659
|
+
jiraIntegration(),
|
|
21660
|
+
salesforceIntegration(),
|
|
21661
|
+
workdayIntegration(),
|
|
21662
|
+
calendlyIntegration(),
|
|
21663
|
+
klaviyoIntegration(),
|
|
21664
|
+
googleFormsIntegration(),
|
|
21665
|
+
firebaseIntegration(),
|
|
21666
|
+
microsoftToDoIntegration(),
|
|
21667
|
+
onenoteIntegration(),
|
|
21668
|
+
microsoftBookingsIntegration(),
|
|
21669
|
+
azureDevopsIntegration(),
|
|
21670
|
+
googlePlayConsoleIntegration(),
|
|
21671
|
+
squarespaceIntegration(),
|
|
21672
|
+
zohoPeopleIntegration(),
|
|
21673
|
+
zohoRecruitIntegration(),
|
|
21674
|
+
zohoSignIntegration(),
|
|
21675
|
+
zohoWorkdriveIntegration(),
|
|
21676
|
+
zohoCreatorIntegration(),
|
|
21677
|
+
zohoInventoryIntegration(),
|
|
21678
|
+
zohoBillingIntegration(),
|
|
21679
|
+
zohoWriterIntegration(),
|
|
21680
|
+
zohoSprintsIntegration()
|
|
21681
|
+
];
|
|
21682
|
+
}
|
|
21683
|
+
function createIntegrationBundle(options) {
|
|
21684
|
+
const all = allIntegrations();
|
|
21685
|
+
if (!options?.include?.length)
|
|
21686
|
+
return all;
|
|
21687
|
+
const allowed = new Set(options.include);
|
|
21688
|
+
return all.filter((i) => allowed.has(i.id));
|
|
21689
|
+
}
|
|
21435
21690
|
// src/database/trigger-store.ts
|
|
21436
21691
|
function toIsoString(value) {
|
|
21437
21692
|
if (!value)
|
|
@@ -24768,6 +25023,69 @@ var integrateTrigger = pgTable("trigger", {
|
|
|
24768
25023
|
index("trigger_status_idx").on(table.status),
|
|
24769
25024
|
index("trigger_next_run_at_idx").on(table.nextRunAt)
|
|
24770
25025
|
]);
|
|
25026
|
+
// src/utils/parse-tool-result.ts
|
|
25027
|
+
function isRecord(value) {
|
|
25028
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25029
|
+
}
|
|
25030
|
+
function getBooleanProperty(value, key) {
|
|
25031
|
+
const property = value[key];
|
|
25032
|
+
return typeof property === "boolean" ? property : undefined;
|
|
25033
|
+
}
|
|
25034
|
+
function getStringProperty(value, key) {
|
|
25035
|
+
const property = value[key];
|
|
25036
|
+
if (typeof property !== "string") {
|
|
25037
|
+
return;
|
|
25038
|
+
}
|
|
25039
|
+
const trimmed = property.trim();
|
|
25040
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
25041
|
+
}
|
|
25042
|
+
function getStructuredContent(result) {
|
|
25043
|
+
const structuredContent = result.structuredContent;
|
|
25044
|
+
return isRecord(structuredContent) ? structuredContent : undefined;
|
|
25045
|
+
}
|
|
25046
|
+
function getContentText(result) {
|
|
25047
|
+
const content = result.content;
|
|
25048
|
+
if (!Array.isArray(content)) {
|
|
25049
|
+
return;
|
|
25050
|
+
}
|
|
25051
|
+
for (const item of content) {
|
|
25052
|
+
if (!isRecord(item)) {
|
|
25053
|
+
continue;
|
|
25054
|
+
}
|
|
25055
|
+
const text2 = getStringProperty(item, "text");
|
|
25056
|
+
if (text2) {
|
|
25057
|
+
return text2;
|
|
25058
|
+
}
|
|
25059
|
+
}
|
|
25060
|
+
return;
|
|
25061
|
+
}
|
|
25062
|
+
function isMCPToolError(result) {
|
|
25063
|
+
return parseMCPToolResult(result).ok === false;
|
|
25064
|
+
}
|
|
25065
|
+
function parseMCPToolResult(result) {
|
|
25066
|
+
if (!isRecord(result)) {
|
|
25067
|
+
return {
|
|
25068
|
+
ok: true,
|
|
25069
|
+
data: result,
|
|
25070
|
+
raw: result
|
|
25071
|
+
};
|
|
25072
|
+
}
|
|
25073
|
+
const structuredContent = getStructuredContent(result);
|
|
25074
|
+
const failed = getBooleanProperty(result, "isError") === true || getBooleanProperty(result, "success") === false || getBooleanProperty(structuredContent ?? {}, "isError") === true || getBooleanProperty(structuredContent ?? {}, "success") === false;
|
|
25075
|
+
if (!failed) {
|
|
25076
|
+
return {
|
|
25077
|
+
ok: true,
|
|
25078
|
+
data: structuredContent ?? result,
|
|
25079
|
+
raw: result
|
|
25080
|
+
};
|
|
25081
|
+
}
|
|
25082
|
+
return {
|
|
25083
|
+
ok: false,
|
|
25084
|
+
error: getStringProperty(result, "error") ?? getStringProperty(structuredContent ?? {}, "error") ?? getContentText(result) ?? "Tool returned an error result",
|
|
25085
|
+
raw: result
|
|
25086
|
+
};
|
|
25087
|
+
}
|
|
25088
|
+
|
|
24771
25089
|
// src/server.ts
|
|
24772
25090
|
var SERVER_LOG_CONTEXT3 = "server";
|
|
24773
25091
|
var logger203 = createLogger("MCPServer", SERVER_LOG_CONTEXT3);
|
|
@@ -24841,33 +25159,6 @@ function resolveProviderFromToolName(toolName, candidates) {
|
|
|
24841
25159
|
}
|
|
24842
25160
|
return best;
|
|
24843
25161
|
}
|
|
24844
|
-
var TOOL_ALIASES = {
|
|
24845
|
-
github_list_repo_contents: "github_get_file_contents",
|
|
24846
|
-
gdrive_list: "gdrive_list_files",
|
|
24847
|
-
gdrive_get: "gdrive_get_file",
|
|
24848
|
-
gdrive_delete: "gdrive_delete_file",
|
|
24849
|
-
gdrive_trash: "gdrive_trash_file",
|
|
24850
|
-
gdrive_upload: "gdrive_upload_text_file",
|
|
24851
|
-
gdrive_download: "gdrive_download_file"
|
|
24852
|
-
};
|
|
24853
|
-
function normalizeToolName(toolName, candidates) {
|
|
24854
|
-
if (TOOL_ALIASES[toolName])
|
|
24855
|
-
return TOOL_ALIASES[toolName];
|
|
24856
|
-
const tripleIdx = toolName.indexOf("___");
|
|
24857
|
-
if (tripleIdx > 0) {
|
|
24858
|
-
const prefix = toolName.slice(0, tripleIdx);
|
|
24859
|
-
if (candidates.some((c) => c === prefix)) {
|
|
24860
|
-
return toolName.slice(tripleIdx);
|
|
24861
|
-
}
|
|
24862
|
-
}
|
|
24863
|
-
for (const candidate of candidates) {
|
|
24864
|
-
const doublePrefix = `${candidate}_${candidate}_`;
|
|
24865
|
-
if (toolName.startsWith(doublePrefix)) {
|
|
24866
|
-
return `${candidate}_${toolName.slice(doublePrefix.length)}`;
|
|
24867
|
-
}
|
|
24868
|
-
}
|
|
24869
|
-
return toolName;
|
|
24870
|
-
}
|
|
24871
25162
|
var unauthenticatedCodeModeWarnings = new Set;
|
|
24872
25163
|
function warnUnauthenticatedCodeModeCallback(details) {
|
|
24873
25164
|
if (unauthenticatedCodeModeWarnings.has(details.toolName))
|
|
@@ -24922,7 +25213,14 @@ function getDefaultRedirectUri() {
|
|
|
24922
25213
|
return "http://localhost:3000/api/integrate/oauth/callback";
|
|
24923
25214
|
}
|
|
24924
25215
|
function createMCPServer(inputConfig) {
|
|
24925
|
-
|
|
25216
|
+
let config = mergeDatabaseConfig(inputConfig);
|
|
25217
|
+
if (config.enabledProviders?.length) {
|
|
25218
|
+
const allowed = new Set(config.enabledProviders);
|
|
25219
|
+
config = {
|
|
25220
|
+
...config,
|
|
25221
|
+
integrations: config.integrations.filter((i) => allowed.has(i.id))
|
|
25222
|
+
};
|
|
25223
|
+
}
|
|
24926
25224
|
setLogLevel(config.debug ? "debug" : "error", SERVER_LOG_CONTEXT3);
|
|
24927
25225
|
if (typeof window !== "undefined") {
|
|
24928
25226
|
throw new Error("createMCPServer() should only be called on the server-side. " + "Use createMCPClient() for client-side code.");
|
|
@@ -25859,6 +26157,7 @@ export {
|
|
|
25859
26157
|
whoopIntegration,
|
|
25860
26158
|
whatsappIntegration,
|
|
25861
26159
|
webflowIntegration,
|
|
26160
|
+
warmToolDiscoveryFromCache,
|
|
25862
26161
|
vercelIntegration,
|
|
25863
26162
|
upstashIntegration,
|
|
25864
26163
|
upsIntegration,
|
|
@@ -25891,6 +26190,7 @@ export {
|
|
|
25891
26190
|
tableauIntegration,
|
|
25892
26191
|
svelteKitHandler,
|
|
25893
26192
|
supabaseIntegration,
|
|
26193
|
+
stubsFromTools,
|
|
25894
26194
|
stripeIntegration,
|
|
25895
26195
|
stravaIntegration,
|
|
25896
26196
|
storeCodeVerifier,
|
|
@@ -25910,6 +26210,7 @@ export {
|
|
|
25910
26210
|
salesforceIntegration,
|
|
25911
26211
|
sageIntegration,
|
|
25912
26212
|
ringIntegration,
|
|
26213
|
+
resolveToolDiscoveryCacheKey,
|
|
25913
26214
|
resendIntegration,
|
|
25914
26215
|
redisIntegration,
|
|
25915
26216
|
redditIntegration,
|
|
@@ -25930,8 +26231,10 @@ export {
|
|
|
25930
26231
|
pinterestIntegration,
|
|
25931
26232
|
philipsHueIntegration,
|
|
25932
26233
|
phantomIntegration,
|
|
26234
|
+
persistToolDiscoveryCache,
|
|
25933
26235
|
paypalIntegration,
|
|
25934
26236
|
parseScopes,
|
|
26237
|
+
parseMCPToolResult,
|
|
25935
26238
|
paperIntegration,
|
|
25936
26239
|
pandadocIntegration,
|
|
25937
26240
|
outlookIntegration,
|
|
@@ -25941,6 +26244,7 @@ export {
|
|
|
25941
26244
|
onedriveIntegration,
|
|
25942
26245
|
oktaIntegration,
|
|
25943
26246
|
notionIntegration,
|
|
26247
|
+
normalizeToolName,
|
|
25944
26248
|
normalizeProviderTokenType,
|
|
25945
26249
|
normalizeAccountIdentifier,
|
|
25946
26250
|
normalizeAccountIdHint,
|
|
@@ -25974,6 +26278,7 @@ export {
|
|
|
25974
26278
|
klaviyoIntegration,
|
|
25975
26279
|
kickIntegration,
|
|
25976
26280
|
jiraIntegration,
|
|
26281
|
+
isMCPToolError,
|
|
25977
26282
|
isLikelyUsableToken,
|
|
25978
26283
|
intercomIntegration,
|
|
25979
26284
|
integrateTrigger,
|
|
@@ -26048,10 +26353,13 @@ export {
|
|
|
26048
26353
|
databricksIntegration,
|
|
26049
26354
|
cursorIntegration,
|
|
26050
26355
|
createTriggerTools,
|
|
26356
|
+
createToolDiscoveryCacheInvalidator,
|
|
26051
26357
|
createTanStackOAuthHandler,
|
|
26052
26358
|
createSimpleIntegration,
|
|
26053
26359
|
createNextOAuthHandler,
|
|
26360
|
+
createMemoryToolDiscoveryCache,
|
|
26054
26361
|
createMCPServer,
|
|
26362
|
+
createIntegrationBundle,
|
|
26055
26363
|
createDatabaseAdapterFactory,
|
|
26056
26364
|
createDatabaseAdapterCallbacks,
|
|
26057
26365
|
convexIntegration,
|
|
@@ -26064,6 +26372,7 @@ export {
|
|
|
26064
26372
|
canvaIntegration,
|
|
26065
26373
|
calendlyIntegration,
|
|
26066
26374
|
calcomIntegration,
|
|
26375
|
+
buildToolDiscoveryCacheKey,
|
|
26067
26376
|
buildPhantomBrowseDeeplink,
|
|
26068
26377
|
buildCodeModeTool,
|
|
26069
26378
|
boxIntegration,
|
|
@@ -26079,13 +26388,16 @@ export {
|
|
|
26079
26388
|
attioIntegration,
|
|
26080
26389
|
astronomerIntegration,
|
|
26081
26390
|
asanaIntegration,
|
|
26391
|
+
applyToolDiscoveryCache,
|
|
26082
26392
|
amazonIntegration,
|
|
26083
26393
|
amazonAdsIntegration,
|
|
26084
26394
|
amadeusIntegration,
|
|
26085
26395
|
alpacaIntegration,
|
|
26396
|
+
allIntegrations,
|
|
26086
26397
|
airtableIntegration,
|
|
26087
26398
|
adobeAcrobatSignIntegration,
|
|
26088
26399
|
__resetUnauthenticatedCodeModeWarnings,
|
|
26400
|
+
TOOL_ALIASES,
|
|
26089
26401
|
RUNTIME_STUB_SOURCE,
|
|
26090
26402
|
POST,
|
|
26091
26403
|
OAuthHandler,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { MCPClient } from "../client.js";
|
|
2
|
+
import type { MCPTool } from "../protocol/messages.js";
|
|
3
|
+
import type { MCPContext } from "../config/types.js";
|
|
4
|
+
/** Serializable MCP tool metadata for cross-request / Redis caching. */
|
|
5
|
+
export type ToolMetadataStub = Pick<MCPTool, "name" | "description" | "inputSchema">;
|
|
6
|
+
export interface ToolDiscoveryCacheAdapter {
|
|
7
|
+
get(key: string): Promise<ToolMetadataStub[] | null>;
|
|
8
|
+
set(key: string, stubs: ToolMetadataStub[], ttlMs?: number): Promise<void>;
|
|
9
|
+
/** Invalidate all keys for a user (prefix match) or a single key when exact. */
|
|
10
|
+
invalidate(userIdOrKey: string): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export interface ToolDiscoveryCacheOptions {
|
|
13
|
+
cache: ToolDiscoveryCacheAdapter;
|
|
14
|
+
/** @default 5 minutes */
|
|
15
|
+
ttlMs?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Build a cache key from user id and connected integration ids.
|
|
19
|
+
* Include connected providers so reconnecting OAuth invalidates stale tool lists.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildToolDiscoveryCacheKey(userId: string, connectedIntegrationIds: readonly string[]): string;
|
|
22
|
+
/**
|
|
23
|
+
* In-memory tool discovery cache (single process). Use Redis in production serverless.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createMemoryToolDiscoveryCache(): ToolDiscoveryCacheAdapter;
|
|
26
|
+
/**
|
|
27
|
+
* Hook for database adapter `onTokenChange` — invalidates cached tool metadata for the user.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createToolDiscoveryCacheInvalidator(cache: ToolDiscoveryCacheAdapter): (event: {
|
|
30
|
+
userId: string;
|
|
31
|
+
}) => void;
|
|
32
|
+
export declare function resolveToolDiscoveryCacheKey(client: MCPClient<any>, context: MCPContext, options?: {
|
|
33
|
+
integrationIds?: string[];
|
|
34
|
+
connectedOnly?: boolean;
|
|
35
|
+
}): Promise<string | undefined>;
|
|
36
|
+
export declare function stubsFromTools(tools: readonly MCPTool[]): ToolMetadataStub[];
|
|
37
|
+
/**
|
|
38
|
+
* Hydrate the client tool cache from persisted stubs (serverless cold start).
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyToolDiscoveryCache(client: MCPClient<any>, stubs: readonly ToolMetadataStub[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* Persist current client tool metadata to a cache adapter.
|
|
43
|
+
*/
|
|
44
|
+
export declare function persistToolDiscoveryCache(client: MCPClient<any>, cache: ToolDiscoveryCacheAdapter, cacheKey: string, ttlMs?: number): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Load stubs from cache into the client before tool discovery.
|
|
47
|
+
* @returns true when cache was hydrated
|
|
48
|
+
*/
|
|
49
|
+
export declare function warmToolDiscoveryFromCache(client: MCPClient<any>, cache: ToolDiscoveryCacheAdapter, cacheKey: string): Promise<boolean>;
|
|
50
|
+
//# sourceMappingURL=tool-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-cache.d.ts","sourceRoot":"","sources":["../../../src/ai/tool-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,CAAC,CAAC;AAErF,MAAM,WAAW,yBAAyB;IACxC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,CAAC;IACrD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,gFAAgF;IAChF,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,yBAAyB,CAAC;IACjC,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,SAAS,MAAM,EAAE,GACzC,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,yBAAyB,CAwB1E;AAED;;GAEG;AACH,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,yBAAyB,GAC/B,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,CAIrC;AAED,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GACA,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAuB7B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,gBAAgB,EAAE,CAM5E;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,KAAK,EAAE,SAAS,gBAAgB,EAAE,GACjC,IAAI,CAEN;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,KAAK,EAAE,yBAAyB,EAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,KAAK,EAAE,yBAAyB,EAChC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAKlB"}
|
package/dist/src/ai/utils.d.ts
CHANGED
|
@@ -57,6 +57,11 @@ export interface AIToolsOptions {
|
|
|
57
57
|
* @default 8
|
|
58
58
|
*/
|
|
59
59
|
fetchConcurrency?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Optional cache for tool metadata (serverless cold-start optimization).
|
|
62
|
+
* Pair with {@link createToolDiscoveryCacheInvalidator} on `onTokenChange`.
|
|
63
|
+
*/
|
|
64
|
+
cache?: import("./tool-cache.js").ToolDiscoveryCacheOptions;
|
|
60
65
|
}
|
|
61
66
|
/** Map AI helper options to client tool-discovery options */
|
|
62
67
|
export declare function toEnabledToolsAsyncOptions(options?: Pick<AIToolsOptions, "integrationIds" | "connectedOnly" | "context" | "fetchConcurrency">): EnabledToolsAsyncOptions | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ai/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ai/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,iBAAiB,EAAE,yBAAyB,CAAC;CAC7D;AAED,6DAA6D;AAC7D,wBAAgB,0BAA0B,CACxC,OAAO,CAAC,EAAE,IAAI,CACZ,cAAc,EACd,gBAAgB,GAAG,eAAe,GAAG,SAAS,GAAG,kBAAkB,CACpE,GACA,wBAAwB,GAAG,SAAS,CAYtC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG/F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAqFvE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAoD7D;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,GAAG,CAAC,CAuCd;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjF;AAED;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-ai.d.ts","sourceRoot":"","sources":["../../../src/ai/vercel-ai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"vercel-ai.d.ts","sourceRoot":"","sources":["../../../src/ai/vercel-ai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAepB;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,kDAAkD;IAClD,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,oBAAoB,gCA+F/B"}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -524,9 +524,7 @@ export declare class MCPClientBase<TIntegrations extends readonly MCPIntegration
|
|
|
524
524
|
*/
|
|
525
525
|
private discoverTools;
|
|
526
526
|
/**
|
|
527
|
-
*
|
|
528
|
-
* Used by integrations like Vercel AI that need to map from tool names
|
|
529
|
-
* @internal
|
|
527
|
+
* @deprecated Use {@link MCPClientBase.callTool} instead. Alias retained for compatibility.
|
|
530
528
|
*/
|
|
531
529
|
_callToolByName(name: string, args?: Record<string, unknown>, options?: ToolCallOptions): Promise<MCPToolCallResponse>;
|
|
532
530
|
/**
|