fastmcp 4.28.3 → 4.29.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/README.md +21 -0
- package/dist/FastMCP.cjs +4 -4
- package/dist/FastMCP.d.cts +6 -4
- package/dist/FastMCP.d.ts +6 -4
- package/dist/FastMCP.js +3 -3
- package/dist/{OAuthProvider-D9JYSSem.d.cts → OAuthProvider-C2Z93xC5.d.cts} +2 -1
- package/dist/{OAuthProvider-D9JYSSem.d.ts → OAuthProvider-C2Z93xC5.d.ts} +2 -1
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +2 -2
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-SQS3SIW7.cjs → chunk-5EEESM57.cjs} +81 -94
- package/dist/chunk-5EEESM57.cjs.map +1 -0
- package/dist/{chunk-OCCYKYIM.cjs → chunk-FBDPX4H2.cjs} +30 -3
- package/dist/chunk-FBDPX4H2.cjs.map +1 -0
- package/dist/{chunk-B2QUCZGV.js → chunk-JCKJRUCE.js} +30 -3
- package/dist/chunk-JCKJRUCE.js.map +1 -0
- package/dist/{chunk-2RLFFOY2.js → chunk-RWPENEKV.js} +8 -1
- package/dist/chunk-RWPENEKV.js.map +1 -0
- package/dist/{chunk-A2TZVOOY.cjs → chunk-UHJQUSUX.cjs} +8 -1
- package/dist/chunk-UHJQUSUX.cjs.map +1 -0
- package/dist/{chunk-GAPP6V64.js → chunk-VN5SZ6IE.js} +48 -61
- package/dist/chunk-VN5SZ6IE.js.map +1 -0
- package/dist/edge/index.cjs +31 -9
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.d.cts +4 -0
- package/dist/edge/index.d.ts +4 -0
- package/dist/edge/index.js +29 -7
- package/dist/edge/index.js.map +1 -1
- package/dist/examples/custom-routes.cjs +4 -4
- package/dist/examples/custom-routes.js +3 -3
- package/dist/openapi/index.cjs +145 -132
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +136 -123
- package/dist/openapi/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-2RLFFOY2.js.map +0 -1
- package/dist/chunk-A2TZVOOY.cjs.map +0 -1
- package/dist/chunk-B2QUCZGV.js.map +0 -1
- package/dist/chunk-GAPP6V64.js.map +0 -1
- package/dist/chunk-OCCYKYIM.cjs.map +0 -1
- package/dist/chunk-SQS3SIW7.cjs.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cancelResponseBody
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RWPENEKV.js";
|
|
4
4
|
import {
|
|
5
5
|
objectRootSchema,
|
|
6
6
|
strictInputSchema,
|
|
7
7
|
zodInputSchema
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JCKJRUCE.js";
|
|
9
9
|
|
|
10
10
|
// src/FastMCP.ts
|
|
11
11
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
@@ -1651,7 +1651,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1651
1651
|
tools: cachedToolsList
|
|
1652
1652
|
};
|
|
1653
1653
|
}
|
|
1654
|
-
|
|
1654
|
+
const listedTools = await Promise.all(
|
|
1655
1655
|
tools.map(async (tool) => {
|
|
1656
1656
|
let inputSchema;
|
|
1657
1657
|
try {
|
|
@@ -1669,6 +1669,12 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1669
1669
|
);
|
|
1670
1670
|
inputSchema = { type: "object" };
|
|
1671
1671
|
}
|
|
1672
|
+
if (inputSchema.type !== "object") {
|
|
1673
|
+
this.#logger.warn(
|
|
1674
|
+
`[FastMCP warning] Tool '${tool.name}' parameters must describe an object. Omitting the tool from tools/list.`
|
|
1675
|
+
);
|
|
1676
|
+
return void 0;
|
|
1677
|
+
}
|
|
1672
1678
|
let outputSchema;
|
|
1673
1679
|
if (tool.outputSchema) {
|
|
1674
1680
|
try {
|
|
@@ -1681,18 +1687,27 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1681
1687
|
error
|
|
1682
1688
|
);
|
|
1683
1689
|
}
|
|
1690
|
+
if (outputSchema && outputSchema.type !== "object") {
|
|
1691
|
+
this.#logger.warn(
|
|
1692
|
+
`[FastMCP warning] Tool '${tool.name}' outputSchema must describe an object. Omitting the tool from tools/list.`
|
|
1693
|
+
);
|
|
1694
|
+
return void 0;
|
|
1695
|
+
}
|
|
1684
1696
|
}
|
|
1685
1697
|
return {
|
|
1686
1698
|
annotations: tool.annotations,
|
|
1687
1699
|
description: tool.description,
|
|
1688
1700
|
inputSchema,
|
|
1689
1701
|
name: tool.name,
|
|
1690
|
-
...outputSchema && {
|
|
1702
|
+
...outputSchema && {
|
|
1703
|
+
outputSchema
|
|
1704
|
+
},
|
|
1691
1705
|
// Pass through _meta for MCP ext-apps UI support (issue #229)
|
|
1692
1706
|
...tool._meta && { _meta: tool._meta }
|
|
1693
1707
|
};
|
|
1694
1708
|
})
|
|
1695
1709
|
);
|
|
1710
|
+
cachedToolsList = listedTools.filter((tool) => tool !== void 0);
|
|
1696
1711
|
return {
|
|
1697
1712
|
tools: cachedToolsList
|
|
1698
1713
|
};
|
|
@@ -2258,9 +2273,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2258
2273
|
addPrompt(prompt) {
|
|
2259
2274
|
this.#prompts = this.#prompts.filter((p) => p.name !== prompt.name);
|
|
2260
2275
|
this.#prompts.push(prompt);
|
|
2261
|
-
|
|
2262
|
-
this.#promptsListChanged(this.#prompts);
|
|
2263
|
-
}
|
|
2276
|
+
this.#promptsListChanged(this.#prompts);
|
|
2264
2277
|
}
|
|
2265
2278
|
/**
|
|
2266
2279
|
* Adds prompts to the server.
|
|
@@ -2274,9 +2287,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2274
2287
|
promptsByName.set(prompt.name, prompt);
|
|
2275
2288
|
}
|
|
2276
2289
|
this.#prompts = Array.from(promptsByName.values());
|
|
2277
|
-
|
|
2278
|
-
this.#promptsListChanged(this.#prompts);
|
|
2279
|
-
}
|
|
2290
|
+
this.#promptsListChanged(this.#prompts);
|
|
2280
2291
|
}
|
|
2281
2292
|
/**
|
|
2282
2293
|
* Adds a resource to the server.
|
|
@@ -2286,9 +2297,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2286
2297
|
(r) => r.name !== resource.name && r.uri !== resource.uri
|
|
2287
2298
|
);
|
|
2288
2299
|
this.#resources.push(resource);
|
|
2289
|
-
|
|
2290
|
-
this.#resourcesListChanged(this.#resources);
|
|
2291
|
-
}
|
|
2300
|
+
this.#resourcesListChanged(this.#resources);
|
|
2292
2301
|
}
|
|
2293
2302
|
/**
|
|
2294
2303
|
* Adds resources to the server.
|
|
@@ -2300,9 +2309,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2300
2309
|
);
|
|
2301
2310
|
this.#resources.push(resource);
|
|
2302
2311
|
}
|
|
2303
|
-
|
|
2304
|
-
this.#resourcesListChanged(this.#resources);
|
|
2305
|
-
}
|
|
2312
|
+
this.#resourcesListChanged(this.#resources);
|
|
2306
2313
|
}
|
|
2307
2314
|
/**
|
|
2308
2315
|
* Adds a resource template to the server.
|
|
@@ -2312,9 +2319,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2312
2319
|
(t) => t.name !== resource.name
|
|
2313
2320
|
);
|
|
2314
2321
|
this.#resourcesTemplates.push(resource);
|
|
2315
|
-
|
|
2316
|
-
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2317
|
-
}
|
|
2322
|
+
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2318
2323
|
}
|
|
2319
2324
|
/**
|
|
2320
2325
|
* Adds resource templates to the server.
|
|
@@ -2326,9 +2331,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2326
2331
|
);
|
|
2327
2332
|
this.#resourcesTemplates.push(resource);
|
|
2328
2333
|
}
|
|
2329
|
-
|
|
2330
|
-
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2331
|
-
}
|
|
2334
|
+
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2332
2335
|
}
|
|
2333
2336
|
/**
|
|
2334
2337
|
* Adds a tool to the server.
|
|
@@ -2337,9 +2340,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2337
2340
|
assertToolSchemas(tool);
|
|
2338
2341
|
this.#tools = this.#tools.filter((t) => t.name !== tool.name);
|
|
2339
2342
|
this.#tools.push(tool);
|
|
2340
|
-
|
|
2341
|
-
this.#toolsListChanged(this.#tools);
|
|
2342
|
-
}
|
|
2343
|
+
this.#toolsListChanged(this.#tools);
|
|
2343
2344
|
}
|
|
2344
2345
|
/**
|
|
2345
2346
|
* Adds tools to the server.
|
|
@@ -2352,9 +2353,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2352
2353
|
toolsByName.set(tool.name, tool);
|
|
2353
2354
|
}
|
|
2354
2355
|
this.#tools = Array.from(toolsByName.values());
|
|
2355
|
-
|
|
2356
|
-
this.#toolsListChanged(this.#tools);
|
|
2357
|
-
}
|
|
2356
|
+
this.#toolsListChanged(this.#tools);
|
|
2358
2357
|
}
|
|
2359
2358
|
/**
|
|
2360
2359
|
* Connects the server to a transport you constructed yourself, instead of
|
|
@@ -2394,14 +2393,15 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2394
2393
|
* Embeds a resource by URI, making it easy to include resources in tool responses.
|
|
2395
2394
|
*
|
|
2396
2395
|
* @param uri - The URI of the resource to embed
|
|
2396
|
+
* @param context - The calling tool's context; its `session` reaches the loader as `auth`
|
|
2397
2397
|
* @returns Promise<ResourceContent> - The embedded resource content
|
|
2398
2398
|
*/
|
|
2399
|
-
async embedded(uri) {
|
|
2399
|
+
async embedded(uri, context) {
|
|
2400
2400
|
const directResource = this.#resources.find(
|
|
2401
2401
|
(resource) => resource.uri === uri
|
|
2402
2402
|
);
|
|
2403
2403
|
if (directResource) {
|
|
2404
|
-
const result = await directResource.load();
|
|
2404
|
+
const result = await directResource.load(context?.session, context);
|
|
2405
2405
|
const results = Array.isArray(result) ? result : [result];
|
|
2406
2406
|
const firstResult = results[0];
|
|
2407
2407
|
if (!firstResult) {
|
|
@@ -2429,7 +2429,9 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2429
2429
|
continue;
|
|
2430
2430
|
}
|
|
2431
2431
|
const result = await template.load(
|
|
2432
|
-
params
|
|
2432
|
+
params,
|
|
2433
|
+
context?.session,
|
|
2434
|
+
context
|
|
2433
2435
|
);
|
|
2434
2436
|
const results = Array.isArray(result) ? result : [result];
|
|
2435
2437
|
const firstResult = results[0];
|
|
@@ -2482,9 +2484,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2482
2484
|
*/
|
|
2483
2485
|
removePrompt(name) {
|
|
2484
2486
|
this.#prompts = this.#prompts.filter((p) => p.name !== name);
|
|
2485
|
-
|
|
2486
|
-
this.#promptsListChanged(this.#prompts);
|
|
2487
|
-
}
|
|
2487
|
+
this.#promptsListChanged(this.#prompts);
|
|
2488
2488
|
}
|
|
2489
2489
|
/**
|
|
2490
2490
|
* Removes prompts from the server.
|
|
@@ -2493,18 +2493,14 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2493
2493
|
for (const name of names) {
|
|
2494
2494
|
this.#prompts = this.#prompts.filter((p) => p.name !== name);
|
|
2495
2495
|
}
|
|
2496
|
-
|
|
2497
|
-
this.#promptsListChanged(this.#prompts);
|
|
2498
|
-
}
|
|
2496
|
+
this.#promptsListChanged(this.#prompts);
|
|
2499
2497
|
}
|
|
2500
2498
|
/**
|
|
2501
2499
|
* Removes a resource from the server.
|
|
2502
2500
|
*/
|
|
2503
2501
|
removeResource(name) {
|
|
2504
2502
|
this.#resources = this.#resources.filter((r) => r.name !== name);
|
|
2505
|
-
|
|
2506
|
-
this.#resourcesListChanged(this.#resources);
|
|
2507
|
-
}
|
|
2503
|
+
this.#resourcesListChanged(this.#resources);
|
|
2508
2504
|
}
|
|
2509
2505
|
/**
|
|
2510
2506
|
* Removes resources from the server.
|
|
@@ -2513,9 +2509,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2513
2509
|
for (const name of names) {
|
|
2514
2510
|
this.#resources = this.#resources.filter((r) => r.name !== name);
|
|
2515
2511
|
}
|
|
2516
|
-
|
|
2517
|
-
this.#resourcesListChanged(this.#resources);
|
|
2518
|
-
}
|
|
2512
|
+
this.#resourcesListChanged(this.#resources);
|
|
2519
2513
|
}
|
|
2520
2514
|
/**
|
|
2521
2515
|
* Removes a resource template from the server.
|
|
@@ -2524,9 +2518,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2524
2518
|
this.#resourcesTemplates = this.#resourcesTemplates.filter(
|
|
2525
2519
|
(t) => t.name !== name
|
|
2526
2520
|
);
|
|
2527
|
-
|
|
2528
|
-
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2529
|
-
}
|
|
2521
|
+
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2530
2522
|
}
|
|
2531
2523
|
/**
|
|
2532
2524
|
* Removes resource templates from the server.
|
|
@@ -2537,18 +2529,14 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2537
2529
|
(t) => t.name !== name
|
|
2538
2530
|
);
|
|
2539
2531
|
}
|
|
2540
|
-
|
|
2541
|
-
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2542
|
-
}
|
|
2532
|
+
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2543
2533
|
}
|
|
2544
2534
|
/**
|
|
2545
2535
|
* Removes a tool from the server.
|
|
2546
2536
|
*/
|
|
2547
2537
|
removeTool(name) {
|
|
2548
2538
|
this.#tools = this.#tools.filter((t) => t.name !== name);
|
|
2549
|
-
|
|
2550
|
-
this.#toolsListChanged(this.#tools);
|
|
2551
|
-
}
|
|
2539
|
+
this.#toolsListChanged(this.#tools);
|
|
2552
2540
|
}
|
|
2553
2541
|
/**
|
|
2554
2542
|
* Removes tools from the server.
|
|
@@ -2557,9 +2545,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2557
2545
|
for (const name of names) {
|
|
2558
2546
|
this.#tools = this.#tools.filter((t) => t.name !== name);
|
|
2559
2547
|
}
|
|
2560
|
-
|
|
2561
|
-
this.#toolsListChanged(this.#tools);
|
|
2562
|
-
}
|
|
2548
|
+
this.#toolsListChanged(this.#tools);
|
|
2563
2549
|
}
|
|
2564
2550
|
/**
|
|
2565
2551
|
* Notifies subscribed clients that a resource's contents have changed.
|
|
@@ -2800,7 +2786,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2800
2786
|
}
|
|
2801
2787
|
/**
|
|
2802
2788
|
* Stops transports created by `start()`. Transports passed to `connect()`
|
|
2803
|
-
* remain open and belong to the caller
|
|
2789
|
+
* remain open and belong to the caller, and continue receiving registration
|
|
2790
|
+
* updates until they are closed.
|
|
2804
2791
|
*/
|
|
2805
2792
|
async stop() {
|
|
2806
2793
|
await Promise.all(
|
|
@@ -3616,7 +3603,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3616
3603
|
* Notifies all sessions that the prompts list has changed.
|
|
3617
3604
|
*/
|
|
3618
3605
|
#promptsListChanged(prompts) {
|
|
3619
|
-
for (const session of this.#sessions) {
|
|
3606
|
+
for (const session of [...this.#sessions]) {
|
|
3620
3607
|
session.promptsListChanged(prompts);
|
|
3621
3608
|
}
|
|
3622
3609
|
}
|
|
@@ -3654,7 +3641,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3654
3641
|
* Notifies all sessions that the resources list has changed.
|
|
3655
3642
|
*/
|
|
3656
3643
|
#resourcesListChanged(resources) {
|
|
3657
|
-
for (const session of this.#sessions) {
|
|
3644
|
+
for (const session of [...this.#sessions]) {
|
|
3658
3645
|
session.resourcesListChanged(resources);
|
|
3659
3646
|
}
|
|
3660
3647
|
}
|
|
@@ -3662,7 +3649,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3662
3649
|
* Notifies all sessions that the resource templates list has changed.
|
|
3663
3650
|
*/
|
|
3664
3651
|
#resourceTemplatesListChanged(templates) {
|
|
3665
|
-
for (const session of this.#sessions) {
|
|
3652
|
+
for (const session of [...this.#sessions]) {
|
|
3666
3653
|
session.resourceTemplatesListChanged(templates);
|
|
3667
3654
|
}
|
|
3668
3655
|
}
|
|
@@ -3670,7 +3657,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3670
3657
|
* Notifies all sessions that the tools list has changed.
|
|
3671
3658
|
*/
|
|
3672
3659
|
#toolsListChanged(tools) {
|
|
3673
|
-
for (const session of this.#sessions) {
|
|
3660
|
+
for (const session of [...this.#sessions]) {
|
|
3674
3661
|
session.toolsListChanged(tools);
|
|
3675
3662
|
}
|
|
3676
3663
|
}
|
|
@@ -3712,4 +3699,4 @@ export {
|
|
|
3712
3699
|
FastMCPSession,
|
|
3713
3700
|
FastMCP
|
|
3714
3701
|
};
|
|
3715
|
-
//# sourceMappingURL=chunk-
|
|
3702
|
+
//# sourceMappingURL=chunk-VN5SZ6IE.js.map
|