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
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkUHJQUSUXcjs = require('./chunk-UHJQUSUX.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkFBDPX4H2cjs = require('./chunk-FBDPX4H2.cjs');
|
|
9
9
|
|
|
10
10
|
// src/FastMCP.ts
|
|
11
11
|
var _indexjs = require('@modelcontextprotocol/sdk/server/index.js');
|
|
@@ -141,7 +141,7 @@ var DiscoveryDocumentCache = class {
|
|
|
141
141
|
throw error;
|
|
142
142
|
}
|
|
143
143
|
if (!res.ok) {
|
|
144
|
-
await
|
|
144
|
+
await _chunkUHJQUSUXcjs.cancelResponseBody.call(void 0, res);
|
|
145
145
|
throw new Error(
|
|
146
146
|
`Failed to fetch discovery document from ${url}: ${res.status} ${res.statusText}`
|
|
147
147
|
);
|
|
@@ -258,7 +258,7 @@ var imageContent = async (input) => {
|
|
|
258
258
|
signal: AbortSignal.timeout(timeoutMs)
|
|
259
259
|
});
|
|
260
260
|
if (!response.ok) {
|
|
261
|
-
await
|
|
261
|
+
await _chunkUHJQUSUXcjs.cancelResponseBody.call(void 0, response);
|
|
262
262
|
throw new Error(
|
|
263
263
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
264
264
|
);
|
|
@@ -340,7 +340,7 @@ var audioContent = async (input) => {
|
|
|
340
340
|
signal: AbortSignal.timeout(timeoutMs)
|
|
341
341
|
});
|
|
342
342
|
if (!response.ok) {
|
|
343
|
-
await
|
|
343
|
+
await _chunkUHJQUSUXcjs.cancelResponseBody.call(void 0, response);
|
|
344
344
|
throw new Error(
|
|
345
345
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
346
346
|
);
|
|
@@ -1651,12 +1651,12 @@ ${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 {
|
|
1658
|
-
inputSchema = tool.parameters ?
|
|
1659
|
-
tool.parameters["~standard"].vendor === "zod" && "_zod" in tool.parameters ?
|
|
1658
|
+
inputSchema = tool.parameters ? _chunkFBDPX4H2cjs.strictInputSchema.call(void 0,
|
|
1659
|
+
tool.parameters["~standard"].vendor === "zod" && "_zod" in tool.parameters ? _chunkFBDPX4H2cjs.zodInputSchema.call(void 0, tool.parameters, "draft-7") : await _xsschema.toJsonSchema.call(void 0, tool.parameters)
|
|
1660
1660
|
) : {
|
|
1661
1661
|
additionalProperties: false,
|
|
1662
1662
|
properties: {},
|
|
@@ -1669,10 +1669,16 @@ ${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 {
|
|
1675
|
-
outputSchema =
|
|
1681
|
+
outputSchema = _chunkFBDPX4H2cjs.objectRootSchema.call(void 0,
|
|
1676
1682
|
await _xsschema.toJsonSchema.call(void 0, tool.outputSchema)
|
|
1677
1683
|
);
|
|
1678
1684
|
} catch (error) {
|
|
@@ -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(_optionalChain([context, 'optionalAccess', _72 => _72.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
|
+
_optionalChain([context, 'optionalAccess', _73 => _73.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(
|
|
@@ -2839,9 +2826,9 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2839
2826
|
const originalOnClose = transport.onclose;
|
|
2840
2827
|
transport.onclose = () => {
|
|
2841
2828
|
closed = true;
|
|
2842
|
-
_optionalChain([onClose, 'optionalCall',
|
|
2829
|
+
_optionalChain([onClose, 'optionalCall', _74 => _74()]);
|
|
2843
2830
|
this.#removeSession(session);
|
|
2844
|
-
_optionalChain([originalOnClose, 'optionalCall',
|
|
2831
|
+
_optionalChain([originalOnClose, 'optionalCall', _75 => _75()]);
|
|
2845
2832
|
};
|
|
2846
2833
|
await session.connect(transport);
|
|
2847
2834
|
if (closed) {
|
|
@@ -2868,7 +2855,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2868
2855
|
*/
|
|
2869
2856
|
#createInsufficientScopeResponse(challenge, id) {
|
|
2870
2857
|
const oauth = this.#options.oauth;
|
|
2871
|
-
const resource = _optionalChain([oauth, 'optionalAccess',
|
|
2858
|
+
const resource = _optionalChain([oauth, 'optionalAccess', _76 => _76.enabled]) ? _optionalChain([oauth, 'access', _77 => _77.protectedResource, 'optionalAccess', _78 => _78.resource]) : void 0;
|
|
2872
2859
|
const wwwAuthenticateParts = [
|
|
2873
2860
|
'error="insufficient_scope"',
|
|
2874
2861
|
`scope="${challenge.scopes.filter((scope) => SCOPE_TOKEN.test(scope)).join(" ")}"`
|
|
@@ -2954,7 +2941,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2954
2941
|
*/
|
|
2955
2942
|
#createUnauthorizedResponse(message) {
|
|
2956
2943
|
const oauth = this.#options.oauth;
|
|
2957
|
-
const resource = _optionalChain([oauth, 'optionalAccess',
|
|
2944
|
+
const resource = _optionalChain([oauth, 'optionalAccess', _79 => _79.enabled]) ? _optionalChain([oauth, 'access', _80 => _80.protectedResource, 'optionalAccess', _81 => _81.resource]) : void 0;
|
|
2958
2945
|
const wwwAuthenticateParts = [
|
|
2959
2946
|
'error="invalid_token"',
|
|
2960
2947
|
`error_description="${message.replace(/"/g, '\\"')}"`
|
|
@@ -3093,7 +3080,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3093
3080
|
}
|
|
3094
3081
|
}
|
|
3095
3082
|
const oauthConfig = this.#options.oauth;
|
|
3096
|
-
if (_optionalChain([oauthConfig, 'optionalAccess',
|
|
3083
|
+
if (_optionalChain([oauthConfig, 'optionalAccess', _82 => _82.enabled]) && req.method === "GET") {
|
|
3097
3084
|
const url2 = new URL(req.url || "", `http://${host}`);
|
|
3098
3085
|
const authorizationServerMetadataPath = joinPaths(
|
|
3099
3086
|
"",
|
|
@@ -3127,8 +3114,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3127
3114
|
}
|
|
3128
3115
|
}
|
|
3129
3116
|
}
|
|
3130
|
-
const oauthProxy = _optionalChain([oauthConfig, 'optionalAccess',
|
|
3131
|
-
if (oauthProxy && _optionalChain([oauthConfig, 'optionalAccess',
|
|
3117
|
+
const oauthProxy = _optionalChain([oauthConfig, 'optionalAccess', _83 => _83.proxy]);
|
|
3118
|
+
if (oauthProxy && _optionalChain([oauthConfig, 'optionalAccess', _84 => _84.enabled])) {
|
|
3132
3119
|
const url2 = new URL(req.url || "", `http://${host}`);
|
|
3133
3120
|
const oauthPath = basePathRelativePath;
|
|
3134
3121
|
try {
|
|
@@ -3181,7 +3168,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3181
3168
|
const statusCode = error.statusCode || 400;
|
|
3182
3169
|
res.writeHead(statusCode, OAUTH_CREDENTIAL_RESPONSE_HEADERS).end(
|
|
3183
3170
|
JSON.stringify(
|
|
3184
|
-
_optionalChain([error, 'access',
|
|
3171
|
+
_optionalChain([error, 'access', _85 => _85.toJSON, 'optionalCall', _86 => _86()]) || {
|
|
3185
3172
|
error: "invalid_request"
|
|
3186
3173
|
}
|
|
3187
3174
|
)
|
|
@@ -3206,7 +3193,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3206
3193
|
} catch (error) {
|
|
3207
3194
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
3208
3195
|
JSON.stringify(
|
|
3209
|
-
_optionalChain([error, 'access',
|
|
3196
|
+
_optionalChain([error, 'access', _87 => _87.toJSON, 'optionalCall', _88 => _88()]) || {
|
|
3210
3197
|
error: "invalid_request"
|
|
3211
3198
|
}
|
|
3212
3199
|
)
|
|
@@ -3224,7 +3211,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3224
3211
|
} catch (error) {
|
|
3225
3212
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
3226
3213
|
JSON.stringify(
|
|
3227
|
-
_optionalChain([error, 'access',
|
|
3214
|
+
_optionalChain([error, 'access', _89 => _89.toJSON, 'optionalCall', _90 => _90()]) || {
|
|
3228
3215
|
error: "server_error"
|
|
3229
3216
|
}
|
|
3230
3217
|
)
|
|
@@ -3288,7 +3275,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3288
3275
|
} catch (error) {
|
|
3289
3276
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
3290
3277
|
JSON.stringify(
|
|
3291
|
-
_optionalChain([error, 'access',
|
|
3278
|
+
_optionalChain([error, 'access', _91 => _91.toJSON, 'optionalCall', _92 => _92()]) || {
|
|
3292
3279
|
error: "server_error"
|
|
3293
3280
|
}
|
|
3294
3281
|
)
|
|
@@ -3403,7 +3390,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3403
3390
|
}
|
|
3404
3391
|
res.writeHead(200, OAUTH_CREDENTIAL_RESPONSE_HEADERS).end(JSON.stringify(response));
|
|
3405
3392
|
} catch (error) {
|
|
3406
|
-
const body = _optionalChain([error, 'access',
|
|
3393
|
+
const body = _optionalChain([error, 'access', _93 => _93.toJSON, 'optionalCall', _94 => _94()]) || {
|
|
3407
3394
|
error: "invalid_request"
|
|
3408
3395
|
};
|
|
3409
3396
|
if (body.error === "invalid_client") {
|
|
@@ -3433,7 +3420,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3433
3420
|
* regardless (RFC 7235), so no config is needed just to get the header.
|
|
3434
3421
|
*/
|
|
3435
3422
|
#httpStreamOAuthConfig() {
|
|
3436
|
-
const resource = _optionalChain([this, 'access',
|
|
3423
|
+
const resource = _optionalChain([this, 'access', _95 => _95.#options, 'access', _96 => _96.oauth, 'optionalAccess', _97 => _97.enabled]) ? _optionalChain([this, 'access', _98 => _98.#options, 'access', _99 => _99.oauth, 'access', _100 => _100.protectedResource, 'optionalAccess', _101 => _101.resource]) : void 0;
|
|
3437
3424
|
if (!resource) {
|
|
3438
3425
|
return {};
|
|
3439
3426
|
}
|
|
@@ -3573,25 +3560,25 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3573
3560
|
const envBasePath = process.env.FASTMCP_BASE_PATH;
|
|
3574
3561
|
const envStateless = process.env.FASTMCP_STATELESS;
|
|
3575
3562
|
const envHost = process.env.FASTMCP_HOST;
|
|
3576
|
-
const transportType = _optionalChain([overrides, 'optionalAccess',
|
|
3563
|
+
const transportType = _optionalChain([overrides, 'optionalAccess', _102 => _102.transportType]) || parseTransportSetting(transportArg, "--transport") || parseTransportSetting(envTransport, "FASTMCP_TRANSPORT") || "stdio";
|
|
3577
3564
|
if (transportType === "httpStream") {
|
|
3578
3565
|
const port = parseInt(
|
|
3579
|
-
_optionalChain([overrides, 'optionalAccess',
|
|
3566
|
+
_optionalChain([overrides, 'optionalAccess', _103 => _103.httpStream, 'optionalAccess', _104 => _104.port, 'optionalAccess', _105 => _105.toString, 'call', _106 => _106()]) || portArg || envPort || "8080"
|
|
3580
3567
|
);
|
|
3581
|
-
const host = _optionalChain([overrides, 'optionalAccess',
|
|
3582
|
-
const endpoint = _optionalChain([overrides, 'optionalAccess',
|
|
3568
|
+
const host = _optionalChain([overrides, 'optionalAccess', _107 => _107.httpStream, 'optionalAccess', _108 => _108.host]) || hostArg || envHost || "localhost";
|
|
3569
|
+
const endpoint = _optionalChain([overrides, 'optionalAccess', _109 => _109.httpStream, 'optionalAccess', _110 => _110.endpoint]) || endpointArg || envEndpoint || "/mcp";
|
|
3583
3570
|
const basePath = normalizeBasePath(
|
|
3584
|
-
_optionalChain([overrides, 'optionalAccess',
|
|
3571
|
+
_optionalChain([overrides, 'optionalAccess', _111 => _111.httpStream, 'optionalAccess', _112 => _112.basePath]) || basePathArg || envBasePath
|
|
3585
3572
|
);
|
|
3586
|
-
const enableJsonResponse = _optionalChain([overrides, 'optionalAccess',
|
|
3587
|
-
const stateless = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([overrides, 'optionalAccess',
|
|
3573
|
+
const enableJsonResponse = _optionalChain([overrides, 'optionalAccess', _113 => _113.httpStream, 'optionalAccess', _114 => _114.enableJsonResponse]) || false;
|
|
3574
|
+
const stateless = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([overrides, 'optionalAccess', _115 => _115.httpStream, 'optionalAccess', _116 => _116.stateless]), () => ( // A bare `--stateless` means `--stateless true`.
|
|
3588
3575
|
(statelessArg === "" ? true : parseBooleanSetting(statelessArg, "--stateless")))), () => ( parseBooleanSetting(envStateless, "FASTMCP_STATELESS"))), () => ( false));
|
|
3589
|
-
const cors = _optionalChain([overrides, 'optionalAccess',
|
|
3590
|
-
const eventStore = _optionalChain([overrides, 'optionalAccess',
|
|
3591
|
-
const sseEndpoint = _optionalChain([overrides, 'optionalAccess',
|
|
3592
|
-
const sslCa = _optionalChain([overrides, 'optionalAccess',
|
|
3593
|
-
const sslCert = _optionalChain([overrides, 'optionalAccess',
|
|
3594
|
-
const sslKey = _optionalChain([overrides, 'optionalAccess',
|
|
3576
|
+
const cors = _optionalChain([overrides, 'optionalAccess', _117 => _117.httpStream, 'optionalAccess', _118 => _118.cors]);
|
|
3577
|
+
const eventStore = _optionalChain([overrides, 'optionalAccess', _119 => _119.httpStream, 'optionalAccess', _120 => _120.eventStore]);
|
|
3578
|
+
const sseEndpoint = _optionalChain([overrides, 'optionalAccess', _121 => _121.httpStream, 'optionalAccess', _122 => _122.sseEndpoint]);
|
|
3579
|
+
const sslCa = _optionalChain([overrides, 'optionalAccess', _123 => _123.httpStream, 'optionalAccess', _124 => _124.sslCa]);
|
|
3580
|
+
const sslCert = _optionalChain([overrides, 'optionalAccess', _125 => _125.httpStream, 'optionalAccess', _126 => _126.sslCert]);
|
|
3581
|
+
const sslKey = _optionalChain([overrides, 'optionalAccess', _127 => _127.httpStream, 'optionalAccess', _128 => _128.sslKey]);
|
|
3595
3582
|
return {
|
|
3596
3583
|
httpStream: {
|
|
3597
3584
|
basePath,
|
|
@@ -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
|
}
|
|
@@ -3683,7 +3670,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3683
3670
|
*/
|
|
3684
3671
|
#useEndpointAsResource(endpoint) {
|
|
3685
3672
|
const oauth = this.#options.oauth;
|
|
3686
|
-
if (this.#providerResourceBase === void 0 || !_optionalChain([oauth, 'optionalAccess',
|
|
3673
|
+
if (this.#providerResourceBase === void 0 || !_optionalChain([oauth, 'optionalAccess', _129 => _129.protectedResource]))
|
|
3687
3674
|
return;
|
|
3688
3675
|
this.#options = {
|
|
3689
3676
|
...this.#options,
|
|
@@ -3712,4 +3699,4 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3712
3699
|
|
|
3713
3700
|
|
|
3714
3701
|
exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.jsonSchemaAdapter = jsonSchemaAdapter; exports.MEDIA_FETCH_TIMEOUT_MS = MEDIA_FETCH_TIMEOUT_MS; exports.imageContent = imageContent; exports.audioContent = audioContent; exports.FastMCPError = FastMCPError; exports.SessionError = SessionError; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.ServerState = ServerState; exports.FastMCPSession = FastMCPSession; exports.FastMCP = FastMCP;
|
|
3715
|
-
//# sourceMappingURL=chunk-
|
|
3702
|
+
//# sourceMappingURL=chunk-5EEESM57.cjs.map
|