Skip to content

Commit 470d7d8

Browse files
committed
Release 0.2.0
Signed-off-by: Marcos Candeia <[email protected]>
1 parent ef175af commit 470d7d8

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@deco/mcp",
3-
"version": "0.1.16",
3+
"version": "0.2.0",
44
"exports": "./mod.ts",
55
"tasks": {
66
"check": "deno fmt && deno lint && deno check mod.ts"

mcp/server.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function setupMcpServer<TManifest extends AppManifest>(
2828
options?: Options<TManifest>,
2929
) {
3030
const mcp = new McpServer({
31-
name: `deco-site-${context.site ?? Deno.env.get("DECO_SITE_NAME")}`,
31+
name: `deco-site-${crypto.randomUUID()}`,
3232
version: context.deploymentId ?? "unknown",
3333
}, {
3434
capabilities: {
@@ -188,13 +188,17 @@ function registerTools<TManifest extends AppManifest>(
188188
options?: Options<TManifest>,
189189
) {
190190
// Add map to store slugified names to original names
191-
const toolNames = new Map<string, string>();
192-
193-
mcp.server.setRequestHandler(ListToolsRequestSchema, async () => {
191+
let toolNames: null | Map<string, string> = null;
192+
const loadTools = async () => {
193+
toolNames ??= new Map<string, string>();
194194
const meta = await deco.meta().then((v) => v?.value);
195195
if (!meta) return { tools: [] };
196196
const schemas = meta.schema;
197197
return { tools: getTools(toolNames, schemas, options) };
198+
};
199+
200+
mcp.server.setRequestHandler(ListToolsRequestSchema, async () => {
201+
return await loadTools();
198202
});
199203

200204
mcp.server.setRequestHandler(CallToolRequestSchema, async (req) => {
@@ -207,7 +211,10 @@ function registerTools<TManifest extends AppManifest>(
207211
},
208212
});
209213
// Use the original name from the map when invoking
210-
const originalName = toolNames.get(req.params.name);
214+
if (!toolNames) {
215+
await loadTools();
216+
}
217+
const originalName = toolNames!.get(req.params.name);
211218
if (!originalName) {
212219
throw new Error(`Tool not found: ${req.params.name}`);
213220
}

0 commit comments

Comments
 (0)