fastmcp 4.7.1 → 4.8.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 +20 -0
- package/dist/FastMCP.cjs +2 -2
- package/dist/FastMCP.d.cts +20 -0
- package/dist/FastMCP.d.ts +20 -0
- package/dist/FastMCP.js +1 -1
- package/dist/{chunk-MLFG3TOK.cjs → chunk-GDMWRPPB.cjs} +124 -27
- package/dist/chunk-GDMWRPPB.cjs.map +1 -0
- package/dist/{chunk-YMUXVDGJ.js → chunk-JEOCXSB4.js} +103 -6
- package/dist/chunk-JEOCXSB4.js.map +1 -0
- package/dist/examples/custom-routes.cjs +2 -2
- package/dist/examples/custom-routes.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-MLFG3TOK.cjs.map +0 -1
- package/dist/chunk-YMUXVDGJ.js.map +0 -1
package/README.md
CHANGED
|
@@ -1406,6 +1406,26 @@ server.addResource({
|
|
|
1406
1406
|
});
|
|
1407
1407
|
```
|
|
1408
1408
|
|
|
1409
|
+
#### Subscribing to resource updates
|
|
1410
|
+
|
|
1411
|
+
Clients can subscribe to a resource with the MCP [`resources/subscribe`](https://modelcontextprotocol.io/specification/2025-06-18/server/resources#subscriptions) method to be notified whenever its contents change. FastMCP advertises the `subscribe` capability automatically for any server that exposes resources, tracks each client's subscriptions, and lets you emit an update with `sendResourceUpdated`:
|
|
1412
|
+
|
|
1413
|
+
```ts
|
|
1414
|
+
server.addResource({
|
|
1415
|
+
uri: "file:///logs/app.log",
|
|
1416
|
+
name: "Application Logs",
|
|
1417
|
+
mimeType: "text/plain",
|
|
1418
|
+
async load() {
|
|
1419
|
+
return { text: await readLogFile() };
|
|
1420
|
+
},
|
|
1421
|
+
});
|
|
1422
|
+
|
|
1423
|
+
// Whenever the underlying data changes, notify subscribed clients:
|
|
1424
|
+
await server.sendResourceUpdated("file:///logs/app.log");
|
|
1425
|
+
```
|
|
1426
|
+
|
|
1427
|
+
`sendResourceUpdated` only notifies clients that have subscribed to the given URI, so it is safe to call whenever your data changes. FastMCP also advertises the `listChanged` capability for resources and prompts and emits `notifications/resources/list_changed` / `notifications/prompts/list_changed` automatically when you add or remove resources, resource templates, or prompts at runtime.
|
|
1428
|
+
|
|
1409
1429
|
### Resource templates
|
|
1410
1430
|
|
|
1411
1431
|
You can also define resource templates:
|
package/dist/FastMCP.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkGDMWRPPBcjs = require('./chunk-GDMWRPPB.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -41,5 +41,5 @@ var _chunkIX3HKAX4cjs = require('./chunk-IX3HKAX4.cjs');
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
exports.AuthProvider = _chunkIX3HKAX4cjs.AuthProvider; exports.AzureProvider = _chunkIX3HKAX4cjs.AzureProvider; exports.DiscoveryDocumentCache =
|
|
44
|
+
exports.AuthProvider = _chunkIX3HKAX4cjs.AuthProvider; exports.AzureProvider = _chunkIX3HKAX4cjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkGDMWRPPBcjs.DiscoveryDocumentCache; exports.FastMCP = _chunkGDMWRPPBcjs.FastMCP; exports.FastMCPSession = _chunkGDMWRPPBcjs.FastMCPSession; exports.GitHubProvider = _chunkIX3HKAX4cjs.GitHubProvider; exports.GoogleProvider = _chunkIX3HKAX4cjs.GoogleProvider; exports.OAuthProvider = _chunkIX3HKAX4cjs.OAuthProvider; exports.ServerState = _chunkGDMWRPPBcjs.ServerState; exports.UnexpectedStateError = _chunkGDMWRPPBcjs.UnexpectedStateError; exports.UserError = _chunkGDMWRPPBcjs.UserError; exports.audioContent = _chunkGDMWRPPBcjs.audioContent; exports.getAuthSession = _chunkIX3HKAX4cjs.getAuthSession; exports.imageContent = _chunkGDMWRPPBcjs.imageContent; exports.requireAll = _chunkIX3HKAX4cjs.requireAll; exports.requireAny = _chunkIX3HKAX4cjs.requireAny; exports.requireAuth = _chunkIX3HKAX4cjs.requireAuth; exports.requireRole = _chunkIX3HKAX4cjs.requireRole; exports.requireScopes = _chunkIX3HKAX4cjs.requireScopes;
|
|
45
45
|
//# sourceMappingURL=FastMCP.cjs.map
|
package/dist/FastMCP.d.cts
CHANGED
|
@@ -750,6 +750,14 @@ declare class FastMCPSession<T extends FastMCPSessionAuth = FastMCPSessionAuth>
|
|
|
750
750
|
requestSampling(message: z.infer<typeof CreateMessageRequestSchema>["params"], options?: RequestOptions): Promise<SamplingResponse>;
|
|
751
751
|
resourcesListChanged(resources: Resource<T>[]): void;
|
|
752
752
|
resourceTemplatesListChanged(resourceTemplates: ResourceTemplate<T>[]): void;
|
|
753
|
+
/**
|
|
754
|
+
* Notifies the connected client that the contents of a resource have changed.
|
|
755
|
+
*
|
|
756
|
+
* The `notifications/resources/updated` notification is only sent when the
|
|
757
|
+
* client has subscribed to the URI via `resources/subscribe`; otherwise this
|
|
758
|
+
* is a no-op.
|
|
759
|
+
*/
|
|
760
|
+
sendResourceUpdated(uri: string): Promise<void>;
|
|
753
761
|
toolsListChanged(tools: Tool<T>[]): void;
|
|
754
762
|
triggerListChangedNotification(method: string): Promise<void>;
|
|
755
763
|
/**
|
|
@@ -766,6 +774,7 @@ declare class FastMCPSession<T extends FastMCPSessionAuth = FastMCPSessionAuth>
|
|
|
766
774
|
private setupLoggingHandlers;
|
|
767
775
|
private setupPromptHandlers;
|
|
768
776
|
private setupResourceHandlers;
|
|
777
|
+
private setupResourceSubscriptionHandlers;
|
|
769
778
|
private setupResourceTemplateHandlers;
|
|
770
779
|
private setupRootsHandlers;
|
|
771
780
|
private setupToolHandlers;
|
|
@@ -874,6 +883,17 @@ declare class FastMCP<T extends FastMCPSessionAuth = FastMCPSessionAuth> extends
|
|
|
874
883
|
* Removes tools from the server.
|
|
875
884
|
*/
|
|
876
885
|
removeTools(names: string[]): void;
|
|
886
|
+
/**
|
|
887
|
+
* Notifies subscribed clients that a resource's contents have changed.
|
|
888
|
+
*
|
|
889
|
+
* Sends a `notifications/resources/updated` notification to every connected
|
|
890
|
+
* session that has subscribed to `uri` via `resources/subscribe`. Sessions
|
|
891
|
+
* that have not subscribed to the URI are skipped, so it is safe to call this
|
|
892
|
+
* whenever the underlying data changes.
|
|
893
|
+
*
|
|
894
|
+
* @param uri - The URI of the resource whose contents changed.
|
|
895
|
+
*/
|
|
896
|
+
sendResourceUpdated(uri: string): Promise<void>;
|
|
877
897
|
/**
|
|
878
898
|
* Starts the server.
|
|
879
899
|
*/
|
package/dist/FastMCP.d.ts
CHANGED
|
@@ -750,6 +750,14 @@ declare class FastMCPSession<T extends FastMCPSessionAuth = FastMCPSessionAuth>
|
|
|
750
750
|
requestSampling(message: z.infer<typeof CreateMessageRequestSchema>["params"], options?: RequestOptions): Promise<SamplingResponse>;
|
|
751
751
|
resourcesListChanged(resources: Resource<T>[]): void;
|
|
752
752
|
resourceTemplatesListChanged(resourceTemplates: ResourceTemplate<T>[]): void;
|
|
753
|
+
/**
|
|
754
|
+
* Notifies the connected client that the contents of a resource have changed.
|
|
755
|
+
*
|
|
756
|
+
* The `notifications/resources/updated` notification is only sent when the
|
|
757
|
+
* client has subscribed to the URI via `resources/subscribe`; otherwise this
|
|
758
|
+
* is a no-op.
|
|
759
|
+
*/
|
|
760
|
+
sendResourceUpdated(uri: string): Promise<void>;
|
|
753
761
|
toolsListChanged(tools: Tool<T>[]): void;
|
|
754
762
|
triggerListChangedNotification(method: string): Promise<void>;
|
|
755
763
|
/**
|
|
@@ -766,6 +774,7 @@ declare class FastMCPSession<T extends FastMCPSessionAuth = FastMCPSessionAuth>
|
|
|
766
774
|
private setupLoggingHandlers;
|
|
767
775
|
private setupPromptHandlers;
|
|
768
776
|
private setupResourceHandlers;
|
|
777
|
+
private setupResourceSubscriptionHandlers;
|
|
769
778
|
private setupResourceTemplateHandlers;
|
|
770
779
|
private setupRootsHandlers;
|
|
771
780
|
private setupToolHandlers;
|
|
@@ -874,6 +883,17 @@ declare class FastMCP<T extends FastMCPSessionAuth = FastMCPSessionAuth> extends
|
|
|
874
883
|
* Removes tools from the server.
|
|
875
884
|
*/
|
|
876
885
|
removeTools(names: string[]): void;
|
|
886
|
+
/**
|
|
887
|
+
* Notifies subscribed clients that a resource's contents have changed.
|
|
888
|
+
*
|
|
889
|
+
* Sends a `notifications/resources/updated` notification to every connected
|
|
890
|
+
* session that has subscribed to `uri` via `resources/subscribe`. Sessions
|
|
891
|
+
* that have not subscribed to the URI are skipped, so it is safe to call this
|
|
892
|
+
* whenever the underlying data changes.
|
|
893
|
+
*
|
|
894
|
+
* @param uri - The URI of the resource whose contents changed.
|
|
895
|
+
*/
|
|
896
|
+
sendResourceUpdated(uri: string): Promise<void>;
|
|
877
897
|
/**
|
|
878
898
|
* Starts the server.
|
|
879
899
|
*/
|
package/dist/FastMCP.js
CHANGED
|
@@ -14,6 +14,8 @@ var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
|
|
18
|
+
|
|
17
19
|
var _typesjs = require('@modelcontextprotocol/sdk/types.js');
|
|
18
20
|
var _events = require('events');
|
|
19
21
|
var _promises = require('fs/promises');
|
|
@@ -357,6 +359,12 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
357
359
|
* Used to track per-session state across multiple requests.
|
|
358
360
|
*/
|
|
359
361
|
#sessionId;
|
|
362
|
+
/**
|
|
363
|
+
* Resource URIs the connected client has subscribed to via
|
|
364
|
+
* `resources/subscribe`. Used to scope `notifications/resources/updated`
|
|
365
|
+
* to interested clients only.
|
|
366
|
+
*/
|
|
367
|
+
#subscriptions = /* @__PURE__ */ new Set();
|
|
360
368
|
#utils;
|
|
361
369
|
constructor({
|
|
362
370
|
auth,
|
|
@@ -387,13 +395,13 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
387
395
|
this.#capabilities.tools = {};
|
|
388
396
|
}
|
|
389
397
|
if (resources.length || resourcesTemplates.length) {
|
|
390
|
-
this.#capabilities.resources = {};
|
|
398
|
+
this.#capabilities.resources = { listChanged: true, subscribe: true };
|
|
391
399
|
}
|
|
392
400
|
if (prompts.length) {
|
|
393
401
|
for (const prompt of prompts) {
|
|
394
402
|
this.addPrompt(prompt);
|
|
395
403
|
}
|
|
396
|
-
this.#capabilities.prompts = {};
|
|
404
|
+
this.#capabilities.prompts = { listChanged: true };
|
|
397
405
|
}
|
|
398
406
|
this.#capabilities.logging = {};
|
|
399
407
|
this.#capabilities.completions = {};
|
|
@@ -414,6 +422,7 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
414
422
|
this.addResource(resource);
|
|
415
423
|
}
|
|
416
424
|
this.setupResourceHandlers();
|
|
425
|
+
this.setupResourceSubscriptionHandlers();
|
|
417
426
|
if (resourcesTemplates.length) {
|
|
418
427
|
for (const resourceTemplate of resourcesTemplates) {
|
|
419
428
|
this.addResourceTemplate(resourceTemplate);
|
|
@@ -549,6 +558,27 @@ ${e instanceof Error ? e.stack : JSON.stringify(e)}`
|
|
|
549
558
|
this.setupResourceTemplateHandlers();
|
|
550
559
|
this.triggerListChangedNotification("notifications/resources/list_changed");
|
|
551
560
|
}
|
|
561
|
+
/**
|
|
562
|
+
* Notifies the connected client that the contents of a resource have changed.
|
|
563
|
+
*
|
|
564
|
+
* The `notifications/resources/updated` notification is only sent when the
|
|
565
|
+
* client has subscribed to the URI via `resources/subscribe`; otherwise this
|
|
566
|
+
* is a no-op.
|
|
567
|
+
*/
|
|
568
|
+
async sendResourceUpdated(uri) {
|
|
569
|
+
if (!this.#subscriptions.has(uri)) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
try {
|
|
573
|
+
await this.#server.sendResourceUpdated({ uri });
|
|
574
|
+
} catch (error) {
|
|
575
|
+
this.#logger.error(
|
|
576
|
+
`[FastMCP error] failed to send resources/updated notification for '${uri}'.
|
|
577
|
+
|
|
578
|
+
${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
552
582
|
toolsListChanged(tools) {
|
|
553
583
|
const allowedTools = tools.filter(
|
|
554
584
|
(tool) => tool.canAccess ? tool.canAccess(this.#auth) : true
|
|
@@ -997,6 +1027,16 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
997
1027
|
}
|
|
998
1028
|
);
|
|
999
1029
|
}
|
|
1030
|
+
setupResourceSubscriptionHandlers() {
|
|
1031
|
+
this.#server.setRequestHandler(_typesjs.SubscribeRequestSchema, (request) => {
|
|
1032
|
+
this.#subscriptions.add(request.params.uri);
|
|
1033
|
+
return {};
|
|
1034
|
+
});
|
|
1035
|
+
this.#server.setRequestHandler(_typesjs.UnsubscribeRequestSchema, (request) => {
|
|
1036
|
+
this.#subscriptions.delete(request.params.uri);
|
|
1037
|
+
return {};
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1000
1040
|
setupResourceTemplateHandlers() {
|
|
1001
1041
|
let cachedResourceTemplatesList = null;
|
|
1002
1042
|
this.#server.setRequestHandler(
|
|
@@ -1599,6 +1639,21 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1599
1639
|
this.#toolsListChanged(this.#tools);
|
|
1600
1640
|
}
|
|
1601
1641
|
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Notifies subscribed clients that a resource's contents have changed.
|
|
1644
|
+
*
|
|
1645
|
+
* Sends a `notifications/resources/updated` notification to every connected
|
|
1646
|
+
* session that has subscribed to `uri` via `resources/subscribe`. Sessions
|
|
1647
|
+
* that have not subscribed to the URI are skipped, so it is safe to call this
|
|
1648
|
+
* whenever the underlying data changes.
|
|
1649
|
+
*
|
|
1650
|
+
* @param uri - The URI of the resource whose contents changed.
|
|
1651
|
+
*/
|
|
1652
|
+
async sendResourceUpdated(uri) {
|
|
1653
|
+
await Promise.all(
|
|
1654
|
+
this.#sessions.map((session) => session.sendResourceUpdated(uri))
|
|
1655
|
+
);
|
|
1656
|
+
}
|
|
1602
1657
|
/**
|
|
1603
1658
|
* Starts the server.
|
|
1604
1659
|
*/
|
|
@@ -1676,7 +1731,9 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1676
1731
|
if (this.#authenticate) {
|
|
1677
1732
|
auth = await this.#authenticate(request);
|
|
1678
1733
|
if (auth === void 0 || auth === null) {
|
|
1679
|
-
throw
|
|
1734
|
+
throw this.#createUnauthorizedResponse(
|
|
1735
|
+
"Authentication required"
|
|
1736
|
+
);
|
|
1680
1737
|
}
|
|
1681
1738
|
}
|
|
1682
1739
|
const sessionId = Array.isArray(request.headers["mcp-session-id"]) ? request.headers["mcp-session-id"][0] : request.headers["mcp-session-id"];
|
|
@@ -1795,7 +1852,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1795
1852
|
#createSession(auth, sessionId) {
|
|
1796
1853
|
if (auth && typeof auth === "object" && "authenticated" in auth && !auth.authenticated) {
|
|
1797
1854
|
const errorMessage = "error" in auth && typeof auth.error === "string" ? auth.error : "Authentication failed";
|
|
1798
|
-
throw
|
|
1855
|
+
throw this.#createUnauthorizedResponse(errorMessage);
|
|
1799
1856
|
}
|
|
1800
1857
|
const allowedTools = auth ? this.#tools.filter(
|
|
1801
1858
|
(tool) => tool.canAccess ? tool.canAccess(auth) : true
|
|
@@ -1818,6 +1875,46 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1818
1875
|
version: this.#options.version
|
|
1819
1876
|
});
|
|
1820
1877
|
}
|
|
1878
|
+
/**
|
|
1879
|
+
* Builds a 401 Unauthorized HTTP Response for authentication failures.
|
|
1880
|
+
*
|
|
1881
|
+
* Throwing a `Response` (rather than a plain `Error`) guarantees that the
|
|
1882
|
+
* transport (e.g. mcp-proxy) surfaces the correct status code directly,
|
|
1883
|
+
* instead of relying on heuristics that infer the status code from the
|
|
1884
|
+
* error message's text (see https://github.com/punkpeye/fastmcp/issues/180).
|
|
1885
|
+
*
|
|
1886
|
+
* The response body matches the JSON-RPC error envelope FastMCP otherwise
|
|
1887
|
+
* produces, and a `WWW-Authenticate` header is included per RFC 7235 (and
|
|
1888
|
+
* RFC 9728 when protected-resource metadata is configured), so HTTP-aware
|
|
1889
|
+
* clients can distinguish "unauthenticated" from a malformed request.
|
|
1890
|
+
*/
|
|
1891
|
+
#createUnauthorizedResponse(message) {
|
|
1892
|
+
const oauth = this.#options.oauth;
|
|
1893
|
+
const resource = _optionalChain([oauth, 'optionalAccess', _48 => _48.enabled]) ? _optionalChain([oauth, 'access', _49 => _49.protectedResource, 'optionalAccess', _50 => _50.resource]) : void 0;
|
|
1894
|
+
const wwwAuthenticateParts = [
|
|
1895
|
+
'error="invalid_token"',
|
|
1896
|
+
`error_description="${message.replace(/"/g, '\\"')}"`
|
|
1897
|
+
];
|
|
1898
|
+
if (resource) {
|
|
1899
|
+
wwwAuthenticateParts.push(
|
|
1900
|
+
`resource_metadata="${resource}/.well-known/oauth-protected-resource"`
|
|
1901
|
+
);
|
|
1902
|
+
}
|
|
1903
|
+
return new Response(
|
|
1904
|
+
JSON.stringify({
|
|
1905
|
+
error: { code: -32e3, message },
|
|
1906
|
+
id: null,
|
|
1907
|
+
jsonrpc: "2.0"
|
|
1908
|
+
}),
|
|
1909
|
+
{
|
|
1910
|
+
headers: {
|
|
1911
|
+
"Content-Type": "application/json",
|
|
1912
|
+
"WWW-Authenticate": `Bearer ${wwwAuthenticateParts.join(", ")}`
|
|
1913
|
+
},
|
|
1914
|
+
status: 401
|
|
1915
|
+
}
|
|
1916
|
+
);
|
|
1917
|
+
}
|
|
1821
1918
|
/**
|
|
1822
1919
|
* Handles unhandled HTTP requests with health, readiness, OAuth endpoints, and custom routes
|
|
1823
1920
|
*/
|
|
@@ -1905,7 +2002,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1905
2002
|
}
|
|
1906
2003
|
}
|
|
1907
2004
|
const oauthConfig = this.#options.oauth;
|
|
1908
|
-
if (_optionalChain([oauthConfig, 'optionalAccess',
|
|
2005
|
+
if (_optionalChain([oauthConfig, 'optionalAccess', _51 => _51.enabled]) && req.method === "GET") {
|
|
1909
2006
|
const url2 = new URL(req.url || "", `http://${host}`);
|
|
1910
2007
|
const authorizationServerMetadataPath = joinPaths(
|
|
1911
2008
|
"",
|
|
@@ -1939,8 +2036,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1939
2036
|
}
|
|
1940
2037
|
}
|
|
1941
2038
|
}
|
|
1942
|
-
const oauthProxy = _optionalChain([oauthConfig, 'optionalAccess',
|
|
1943
|
-
if (oauthProxy && _optionalChain([oauthConfig, 'optionalAccess',
|
|
2039
|
+
const oauthProxy = _optionalChain([oauthConfig, 'optionalAccess', _52 => _52.proxy]);
|
|
2040
|
+
if (oauthProxy && _optionalChain([oauthConfig, 'optionalAccess', _53 => _53.enabled])) {
|
|
1944
2041
|
const url2 = new URL(req.url || "", `http://${host}`);
|
|
1945
2042
|
const oauthPath = basePathRelativePath;
|
|
1946
2043
|
try {
|
|
@@ -1957,7 +2054,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1957
2054
|
const statusCode = error.statusCode || 400;
|
|
1958
2055
|
res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
|
|
1959
2056
|
JSON.stringify(
|
|
1960
|
-
_optionalChain([error, 'access',
|
|
2057
|
+
_optionalChain([error, 'access', _54 => _54.toJSON, 'optionalCall', _55 => _55()]) || {
|
|
1961
2058
|
error: "invalid_request"
|
|
1962
2059
|
}
|
|
1963
2060
|
)
|
|
@@ -1984,7 +2081,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1984
2081
|
} catch (error) {
|
|
1985
2082
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
1986
2083
|
JSON.stringify(
|
|
1987
|
-
_optionalChain([error, 'access',
|
|
2084
|
+
_optionalChain([error, 'access', _56 => _56.toJSON, 'optionalCall', _57 => _57()]) || {
|
|
1988
2085
|
error: "invalid_request"
|
|
1989
2086
|
}
|
|
1990
2087
|
)
|
|
@@ -2006,7 +2103,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2006
2103
|
} catch (error) {
|
|
2007
2104
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
2008
2105
|
JSON.stringify(
|
|
2009
|
-
_optionalChain([error, 'access',
|
|
2106
|
+
_optionalChain([error, 'access', _58 => _58.toJSON, 'optionalCall', _59 => _59()]) || {
|
|
2010
2107
|
error: "server_error"
|
|
2011
2108
|
}
|
|
2012
2109
|
)
|
|
@@ -2041,7 +2138,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2041
2138
|
} catch (error) {
|
|
2042
2139
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
2043
2140
|
JSON.stringify(
|
|
2044
|
-
_optionalChain([error, 'access',
|
|
2141
|
+
_optionalChain([error, 'access', _60 => _60.toJSON, 'optionalCall', _61 => _61()]) || {
|
|
2045
2142
|
error: "server_error"
|
|
2046
2143
|
}
|
|
2047
2144
|
)
|
|
@@ -2063,8 +2160,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2063
2160
|
const basicAuth = parseBasicAuthHeader(
|
|
2064
2161
|
req.headers.authorization
|
|
2065
2162
|
);
|
|
2066
|
-
const clientId = _optionalChain([basicAuth, 'optionalAccess',
|
|
2067
|
-
const clientSecret = _nullishCoalesce(_nullishCoalesce(_optionalChain([basicAuth, 'optionalAccess',
|
|
2163
|
+
const clientId = _optionalChain([basicAuth, 'optionalAccess', _62 => _62.clientId]) || params.get("client_id") || "";
|
|
2164
|
+
const clientSecret = _nullishCoalesce(_nullishCoalesce(_optionalChain([basicAuth, 'optionalAccess', _63 => _63.clientSecret]), () => ( params.get("client_secret"))), () => ( void 0));
|
|
2068
2165
|
let response;
|
|
2069
2166
|
if (grantType === "authorization_code") {
|
|
2070
2167
|
response = await oauthProxy.exchangeAuthorizationCode({
|
|
@@ -2094,7 +2191,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2094
2191
|
const statusCode = error.statusCode || 400;
|
|
2095
2192
|
res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
|
|
2096
2193
|
JSON.stringify(
|
|
2097
|
-
_optionalChain([error, 'access',
|
|
2194
|
+
_optionalChain([error, 'access', _64 => _64.toJSON, 'optionalCall', _65 => _65()]) || {
|
|
2098
2195
|
error: "invalid_request"
|
|
2099
2196
|
}
|
|
2100
2197
|
)
|
|
@@ -2165,23 +2262,23 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2165
2262
|
const envBasePath = process.env.FASTMCP_BASE_PATH;
|
|
2166
2263
|
const envStateless = process.env.FASTMCP_STATELESS;
|
|
2167
2264
|
const envHost = process.env.FASTMCP_HOST;
|
|
2168
|
-
const transportType = _optionalChain([overrides, 'optionalAccess',
|
|
2265
|
+
const transportType = _optionalChain([overrides, 'optionalAccess', _66 => _66.transportType]) || (transportArg === "http-stream" ? "httpStream" : transportArg) || envTransport || "stdio";
|
|
2169
2266
|
if (transportType === "httpStream") {
|
|
2170
2267
|
const port = parseInt(
|
|
2171
|
-
_optionalChain([overrides, 'optionalAccess',
|
|
2268
|
+
_optionalChain([overrides, 'optionalAccess', _67 => _67.httpStream, 'optionalAccess', _68 => _68.port, 'optionalAccess', _69 => _69.toString, 'call', _70 => _70()]) || portArg || envPort || "8080"
|
|
2172
2269
|
);
|
|
2173
|
-
const host = _optionalChain([overrides, 'optionalAccess',
|
|
2174
|
-
const endpoint = _optionalChain([overrides, 'optionalAccess',
|
|
2270
|
+
const host = _optionalChain([overrides, 'optionalAccess', _71 => _71.httpStream, 'optionalAccess', _72 => _72.host]) || hostArg || envHost || "localhost";
|
|
2271
|
+
const endpoint = _optionalChain([overrides, 'optionalAccess', _73 => _73.httpStream, 'optionalAccess', _74 => _74.endpoint]) || endpointArg || envEndpoint || "/mcp";
|
|
2175
2272
|
const basePath = normalizeBasePath(
|
|
2176
|
-
_optionalChain([overrides, 'optionalAccess',
|
|
2273
|
+
_optionalChain([overrides, 'optionalAccess', _75 => _75.httpStream, 'optionalAccess', _76 => _76.basePath]) || basePathArg || envBasePath
|
|
2177
2274
|
);
|
|
2178
|
-
const enableJsonResponse = _optionalChain([overrides, 'optionalAccess',
|
|
2179
|
-
const stateless = _optionalChain([overrides, 'optionalAccess',
|
|
2180
|
-
const cors = _optionalChain([overrides, 'optionalAccess',
|
|
2181
|
-
const eventStore = _optionalChain([overrides, 'optionalAccess',
|
|
2182
|
-
const sslCa = _optionalChain([overrides, 'optionalAccess',
|
|
2183
|
-
const sslCert = _optionalChain([overrides, 'optionalAccess',
|
|
2184
|
-
const sslKey = _optionalChain([overrides, 'optionalAccess',
|
|
2275
|
+
const enableJsonResponse = _optionalChain([overrides, 'optionalAccess', _77 => _77.httpStream, 'optionalAccess', _78 => _78.enableJsonResponse]) || false;
|
|
2276
|
+
const stateless = _optionalChain([overrides, 'optionalAccess', _79 => _79.httpStream, 'optionalAccess', _80 => _80.stateless]) || statelessArg === "true" || envStateless === "true" || false;
|
|
2277
|
+
const cors = _optionalChain([overrides, 'optionalAccess', _81 => _81.httpStream, 'optionalAccess', _82 => _82.cors]);
|
|
2278
|
+
const eventStore = _optionalChain([overrides, 'optionalAccess', _83 => _83.httpStream, 'optionalAccess', _84 => _84.eventStore]);
|
|
2279
|
+
const sslCa = _optionalChain([overrides, 'optionalAccess', _85 => _85.httpStream, 'optionalAccess', _86 => _86.sslCa]);
|
|
2280
|
+
const sslCert = _optionalChain([overrides, 'optionalAccess', _87 => _87.httpStream, 'optionalAccess', _88 => _88.sslCert]);
|
|
2281
|
+
const sslKey = _optionalChain([overrides, 'optionalAccess', _89 => _89.httpStream, 'optionalAccess', _90 => _90.sslKey]);
|
|
2185
2282
|
return {
|
|
2186
2283
|
httpStream: {
|
|
2187
2284
|
basePath,
|
|
@@ -2254,4 +2351,4 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2254
2351
|
|
|
2255
2352
|
|
|
2256
2353
|
exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.imageContent = imageContent; exports.audioContent = audioContent; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.ServerState = ServerState; exports.FastMCPSession = FastMCPSession; exports.FastMCP = FastMCP;
|
|
2257
|
-
//# sourceMappingURL=chunk-
|
|
2354
|
+
//# sourceMappingURL=chunk-GDMWRPPB.cjs.map
|