fastmcp 4.28.4 → 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 +4 -2
- package/dist/FastMCP.d.ts +4 -2
- package/dist/FastMCP.js +3 -3
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-DPJW5QEO.cjs → chunk-5EEESM57.cjs} +64 -92
- 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-UFPH23EN.js → chunk-RWPENEKV.js} +5 -1
- package/dist/{chunk-UFPH23EN.js.map → chunk-RWPENEKV.js.map} +1 -1
- package/dist/{chunk-7IQ5QHVZ.cjs → chunk-UHJQUSUX.cjs} +5 -1
- package/dist/chunk-UHJQUSUX.cjs.map +1 -0
- package/dist/{chunk-Q57EM4LH.js → chunk-VN5SZ6IE.js} +31 -59
- package/dist/chunk-VN5SZ6IE.js.map +1 -0
- package/dist/edge/index.cjs +15 -4
- 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 +13 -2
- 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.js +136 -123
- package/dist/openapi/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-7IQ5QHVZ.cjs.map +0 -1
- package/dist/chunk-B2QUCZGV.js.map +0 -1
- package/dist/chunk-DPJW5QEO.cjs.map +0 -1
- package/dist/chunk-OCCYKYIM.cjs.map +0 -1
- package/dist/chunk-Q57EM4LH.js.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";
|
|
@@ -2273,9 +2273,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2273
2273
|
addPrompt(prompt) {
|
|
2274
2274
|
this.#prompts = this.#prompts.filter((p) => p.name !== prompt.name);
|
|
2275
2275
|
this.#prompts.push(prompt);
|
|
2276
|
-
|
|
2277
|
-
this.#promptsListChanged(this.#prompts);
|
|
2278
|
-
}
|
|
2276
|
+
this.#promptsListChanged(this.#prompts);
|
|
2279
2277
|
}
|
|
2280
2278
|
/**
|
|
2281
2279
|
* Adds prompts to the server.
|
|
@@ -2289,9 +2287,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2289
2287
|
promptsByName.set(prompt.name, prompt);
|
|
2290
2288
|
}
|
|
2291
2289
|
this.#prompts = Array.from(promptsByName.values());
|
|
2292
|
-
|
|
2293
|
-
this.#promptsListChanged(this.#prompts);
|
|
2294
|
-
}
|
|
2290
|
+
this.#promptsListChanged(this.#prompts);
|
|
2295
2291
|
}
|
|
2296
2292
|
/**
|
|
2297
2293
|
* Adds a resource to the server.
|
|
@@ -2301,9 +2297,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2301
2297
|
(r) => r.name !== resource.name && r.uri !== resource.uri
|
|
2302
2298
|
);
|
|
2303
2299
|
this.#resources.push(resource);
|
|
2304
|
-
|
|
2305
|
-
this.#resourcesListChanged(this.#resources);
|
|
2306
|
-
}
|
|
2300
|
+
this.#resourcesListChanged(this.#resources);
|
|
2307
2301
|
}
|
|
2308
2302
|
/**
|
|
2309
2303
|
* Adds resources to the server.
|
|
@@ -2315,9 +2309,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2315
2309
|
);
|
|
2316
2310
|
this.#resources.push(resource);
|
|
2317
2311
|
}
|
|
2318
|
-
|
|
2319
|
-
this.#resourcesListChanged(this.#resources);
|
|
2320
|
-
}
|
|
2312
|
+
this.#resourcesListChanged(this.#resources);
|
|
2321
2313
|
}
|
|
2322
2314
|
/**
|
|
2323
2315
|
* Adds a resource template to the server.
|
|
@@ -2327,9 +2319,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2327
2319
|
(t) => t.name !== resource.name
|
|
2328
2320
|
);
|
|
2329
2321
|
this.#resourcesTemplates.push(resource);
|
|
2330
|
-
|
|
2331
|
-
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2332
|
-
}
|
|
2322
|
+
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2333
2323
|
}
|
|
2334
2324
|
/**
|
|
2335
2325
|
* Adds resource templates to the server.
|
|
@@ -2341,9 +2331,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2341
2331
|
);
|
|
2342
2332
|
this.#resourcesTemplates.push(resource);
|
|
2343
2333
|
}
|
|
2344
|
-
|
|
2345
|
-
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2346
|
-
}
|
|
2334
|
+
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2347
2335
|
}
|
|
2348
2336
|
/**
|
|
2349
2337
|
* Adds a tool to the server.
|
|
@@ -2352,9 +2340,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2352
2340
|
assertToolSchemas(tool);
|
|
2353
2341
|
this.#tools = this.#tools.filter((t) => t.name !== tool.name);
|
|
2354
2342
|
this.#tools.push(tool);
|
|
2355
|
-
|
|
2356
|
-
this.#toolsListChanged(this.#tools);
|
|
2357
|
-
}
|
|
2343
|
+
this.#toolsListChanged(this.#tools);
|
|
2358
2344
|
}
|
|
2359
2345
|
/**
|
|
2360
2346
|
* Adds tools to the server.
|
|
@@ -2367,9 +2353,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2367
2353
|
toolsByName.set(tool.name, tool);
|
|
2368
2354
|
}
|
|
2369
2355
|
this.#tools = Array.from(toolsByName.values());
|
|
2370
|
-
|
|
2371
|
-
this.#toolsListChanged(this.#tools);
|
|
2372
|
-
}
|
|
2356
|
+
this.#toolsListChanged(this.#tools);
|
|
2373
2357
|
}
|
|
2374
2358
|
/**
|
|
2375
2359
|
* Connects the server to a transport you constructed yourself, instead of
|
|
@@ -2409,14 +2393,15 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2409
2393
|
* Embeds a resource by URI, making it easy to include resources in tool responses.
|
|
2410
2394
|
*
|
|
2411
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`
|
|
2412
2397
|
* @returns Promise<ResourceContent> - The embedded resource content
|
|
2413
2398
|
*/
|
|
2414
|
-
async embedded(uri) {
|
|
2399
|
+
async embedded(uri, context) {
|
|
2415
2400
|
const directResource = this.#resources.find(
|
|
2416
2401
|
(resource) => resource.uri === uri
|
|
2417
2402
|
);
|
|
2418
2403
|
if (directResource) {
|
|
2419
|
-
const result = await directResource.load();
|
|
2404
|
+
const result = await directResource.load(context?.session, context);
|
|
2420
2405
|
const results = Array.isArray(result) ? result : [result];
|
|
2421
2406
|
const firstResult = results[0];
|
|
2422
2407
|
if (!firstResult) {
|
|
@@ -2444,7 +2429,9 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2444
2429
|
continue;
|
|
2445
2430
|
}
|
|
2446
2431
|
const result = await template.load(
|
|
2447
|
-
params
|
|
2432
|
+
params,
|
|
2433
|
+
context?.session,
|
|
2434
|
+
context
|
|
2448
2435
|
);
|
|
2449
2436
|
const results = Array.isArray(result) ? result : [result];
|
|
2450
2437
|
const firstResult = results[0];
|
|
@@ -2497,9 +2484,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2497
2484
|
*/
|
|
2498
2485
|
removePrompt(name) {
|
|
2499
2486
|
this.#prompts = this.#prompts.filter((p) => p.name !== name);
|
|
2500
|
-
|
|
2501
|
-
this.#promptsListChanged(this.#prompts);
|
|
2502
|
-
}
|
|
2487
|
+
this.#promptsListChanged(this.#prompts);
|
|
2503
2488
|
}
|
|
2504
2489
|
/**
|
|
2505
2490
|
* Removes prompts from the server.
|
|
@@ -2508,18 +2493,14 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2508
2493
|
for (const name of names) {
|
|
2509
2494
|
this.#prompts = this.#prompts.filter((p) => p.name !== name);
|
|
2510
2495
|
}
|
|
2511
|
-
|
|
2512
|
-
this.#promptsListChanged(this.#prompts);
|
|
2513
|
-
}
|
|
2496
|
+
this.#promptsListChanged(this.#prompts);
|
|
2514
2497
|
}
|
|
2515
2498
|
/**
|
|
2516
2499
|
* Removes a resource from the server.
|
|
2517
2500
|
*/
|
|
2518
2501
|
removeResource(name) {
|
|
2519
2502
|
this.#resources = this.#resources.filter((r) => r.name !== name);
|
|
2520
|
-
|
|
2521
|
-
this.#resourcesListChanged(this.#resources);
|
|
2522
|
-
}
|
|
2503
|
+
this.#resourcesListChanged(this.#resources);
|
|
2523
2504
|
}
|
|
2524
2505
|
/**
|
|
2525
2506
|
* Removes resources from the server.
|
|
@@ -2528,9 +2509,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2528
2509
|
for (const name of names) {
|
|
2529
2510
|
this.#resources = this.#resources.filter((r) => r.name !== name);
|
|
2530
2511
|
}
|
|
2531
|
-
|
|
2532
|
-
this.#resourcesListChanged(this.#resources);
|
|
2533
|
-
}
|
|
2512
|
+
this.#resourcesListChanged(this.#resources);
|
|
2534
2513
|
}
|
|
2535
2514
|
/**
|
|
2536
2515
|
* Removes a resource template from the server.
|
|
@@ -2539,9 +2518,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2539
2518
|
this.#resourcesTemplates = this.#resourcesTemplates.filter(
|
|
2540
2519
|
(t) => t.name !== name
|
|
2541
2520
|
);
|
|
2542
|
-
|
|
2543
|
-
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2544
|
-
}
|
|
2521
|
+
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2545
2522
|
}
|
|
2546
2523
|
/**
|
|
2547
2524
|
* Removes resource templates from the server.
|
|
@@ -2552,18 +2529,14 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2552
2529
|
(t) => t.name !== name
|
|
2553
2530
|
);
|
|
2554
2531
|
}
|
|
2555
|
-
|
|
2556
|
-
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2557
|
-
}
|
|
2532
|
+
this.#resourceTemplatesListChanged(this.#resourcesTemplates);
|
|
2558
2533
|
}
|
|
2559
2534
|
/**
|
|
2560
2535
|
* Removes a tool from the server.
|
|
2561
2536
|
*/
|
|
2562
2537
|
removeTool(name) {
|
|
2563
2538
|
this.#tools = this.#tools.filter((t) => t.name !== name);
|
|
2564
|
-
|
|
2565
|
-
this.#toolsListChanged(this.#tools);
|
|
2566
|
-
}
|
|
2539
|
+
this.#toolsListChanged(this.#tools);
|
|
2567
2540
|
}
|
|
2568
2541
|
/**
|
|
2569
2542
|
* Removes tools from the server.
|
|
@@ -2572,9 +2545,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2572
2545
|
for (const name of names) {
|
|
2573
2546
|
this.#tools = this.#tools.filter((t) => t.name !== name);
|
|
2574
2547
|
}
|
|
2575
|
-
|
|
2576
|
-
this.#toolsListChanged(this.#tools);
|
|
2577
|
-
}
|
|
2548
|
+
this.#toolsListChanged(this.#tools);
|
|
2578
2549
|
}
|
|
2579
2550
|
/**
|
|
2580
2551
|
* Notifies subscribed clients that a resource's contents have changed.
|
|
@@ -2815,7 +2786,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2815
2786
|
}
|
|
2816
2787
|
/**
|
|
2817
2788
|
* Stops transports created by `start()`. Transports passed to `connect()`
|
|
2818
|
-
* 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.
|
|
2819
2791
|
*/
|
|
2820
2792
|
async stop() {
|
|
2821
2793
|
await Promise.all(
|
|
@@ -3631,7 +3603,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3631
3603
|
* Notifies all sessions that the prompts list has changed.
|
|
3632
3604
|
*/
|
|
3633
3605
|
#promptsListChanged(prompts) {
|
|
3634
|
-
for (const session of this.#sessions) {
|
|
3606
|
+
for (const session of [...this.#sessions]) {
|
|
3635
3607
|
session.promptsListChanged(prompts);
|
|
3636
3608
|
}
|
|
3637
3609
|
}
|
|
@@ -3669,7 +3641,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3669
3641
|
* Notifies all sessions that the resources list has changed.
|
|
3670
3642
|
*/
|
|
3671
3643
|
#resourcesListChanged(resources) {
|
|
3672
|
-
for (const session of this.#sessions) {
|
|
3644
|
+
for (const session of [...this.#sessions]) {
|
|
3673
3645
|
session.resourcesListChanged(resources);
|
|
3674
3646
|
}
|
|
3675
3647
|
}
|
|
@@ -3677,7 +3649,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3677
3649
|
* Notifies all sessions that the resource templates list has changed.
|
|
3678
3650
|
*/
|
|
3679
3651
|
#resourceTemplatesListChanged(templates) {
|
|
3680
|
-
for (const session of this.#sessions) {
|
|
3652
|
+
for (const session of [...this.#sessions]) {
|
|
3681
3653
|
session.resourceTemplatesListChanged(templates);
|
|
3682
3654
|
}
|
|
3683
3655
|
}
|
|
@@ -3685,7 +3657,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3685
3657
|
* Notifies all sessions that the tools list has changed.
|
|
3686
3658
|
*/
|
|
3687
3659
|
#toolsListChanged(tools) {
|
|
3688
|
-
for (const session of this.#sessions) {
|
|
3660
|
+
for (const session of [...this.#sessions]) {
|
|
3689
3661
|
session.toolsListChanged(tools);
|
|
3690
3662
|
}
|
|
3691
3663
|
}
|
|
@@ -3727,4 +3699,4 @@ export {
|
|
|
3727
3699
|
FastMCPSession,
|
|
3728
3700
|
FastMCP
|
|
3729
3701
|
};
|
|
3730
|
-
//# sourceMappingURL=chunk-
|
|
3702
|
+
//# sourceMappingURL=chunk-VN5SZ6IE.js.map
|