Skip to content

Commit b10d4a9

Browse files
authored
Ignore cache for self gen (#915)
Signed-off-by: Marcos Candeia <marrcooos@gmail.com>
1 parent a39c431 commit b10d4a9

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

packages/ai/src/mcp.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,13 @@ const handleMCPResponse = async (client: Client) => {
295295
};
296296
export const swrMCPMetadata = (
297297
mcpServer: Pick<Integration, "connection" | "name">,
298+
ignoreCache = false,
298299
) => {
299300
const fetch = async () => {
300301
const client = await createServerClient(mcpServer);
301302
return handleMCPResponse(client).finally(() => client.close());
302303
};
303-
if ("url" in mcpServer.connection) {
304+
if ("url" in mcpServer.connection && !ignoreCache) {
304305
return swr.cache(fetch, mcpServer.connection.url);
305306
}
306307
return fetch();
@@ -309,6 +310,7 @@ export const swrMCPMetadata = (
309310
export async function listToolsByConnectionType(
310311
connection: MCPConnection,
311312
ctx: AppContext,
313+
ignoreCache = false,
312314
) {
313315
switch (connection.type) {
314316
case "INNATE": {
@@ -347,7 +349,7 @@ export async function listToolsByConnectionType(
347349
return await swrMCPMetadata({
348350
name: connection.type,
349351
connection,
350-
});
352+
}, ignoreCache);
351353
}
352354
default: {
353355
return { error: "Invalid connection type" };

packages/cli/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@deco/cli",
3-
"version": "0.9.7",
3+
"version": "0.9.8",
44
"description": "A CLI for interacting with deco.chat.",
55
"license": "MIT",
66
"exports": "./cli.ts",

packages/cli/src/typings.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,12 @@ export const genEnv = async (
172172
...bindings,
173173
...DEFAULT_BINDINGS,
174174
...selfUrl
175-
? [{ name: "SELF", type: "mcp", integration_url: selfUrl }]
175+
? [{
176+
name: "SELF",
177+
type: "mcp",
178+
integration_url: selfUrl,
179+
ignoreCache: true,
180+
}]
176181
: [],
177182
].map(async (binding) => {
178183
let connection: unknown;
@@ -207,6 +212,9 @@ export const genEnv = async (
207212
name: "INTEGRATIONS_LIST_TOOLS",
208213
arguments: {
209214
connection,
215+
ignoreCache: "ignoreCache" in binding
216+
? binding.ignoreCache
217+
: undefined,
210218
},
211219
}) as {
212220
structuredContent: {

packages/sdk/src/mcp/integrations/api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,18 @@ export const listTools = createIntegrationManagementTool({
159159
description: "List tools of a given integration",
160160
inputSchema: IntegrationSchema.pick({
161161
connection: true,
162+
}).extend({
163+
ignoreCache: z.boolean().optional().describe(
164+
"Whether to ignore the cache when listing tools",
165+
),
162166
}),
163-
handler: async ({ connection }, c) => {
167+
handler: async ({ connection, ignoreCache }, c) => {
164168
c.resourceAccess.grant();
165169

166170
const result = await listToolsByConnectionType(
167171
connection,
168172
c,
173+
ignoreCache,
169174
);
170175

171176
// Sort tools by name for consistent UI

0 commit comments

Comments
 (0)