fastmcp 4.20.8 → 4.20.10
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/dist/FastMCP.cjs +3 -3
- package/dist/FastMCP.d.cts +6 -1
- package/dist/FastMCP.d.ts +6 -1
- package/dist/FastMCP.js +2 -2
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-HTMIU2GU.cjs → chunk-27HK2PAJ.cjs} +37 -23
- package/dist/chunk-27HK2PAJ.cjs.map +1 -0
- package/dist/{chunk-XYUWODT6.js → chunk-A5IEOE6F.js} +34 -20
- package/dist/chunk-A5IEOE6F.js.map +1 -0
- package/dist/{chunk-YO76IUZ6.cjs → chunk-BTXI2HQS.cjs} +3 -3
- package/dist/{chunk-YO76IUZ6.cjs.map → chunk-BTXI2HQS.cjs.map} +1 -1
- package/dist/{chunk-LRXZYGFR.js → chunk-YRIK6EIY.js} +3 -3
- package/dist/{chunk-LRXZYGFR.js.map → chunk-YRIK6EIY.js.map} +1 -1
- package/dist/edge/index.cjs +28 -8
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.d.cts +6 -0
- package/dist/edge/index.d.ts +6 -0
- package/dist/edge/index.js +22 -2
- package/dist/edge/index.js.map +1 -1
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/dist/openapi/index.cjs +6 -6
- package/dist/openapi/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-HTMIU2GU.cjs.map +0 -1
- package/dist/chunk-XYUWODT6.js.map +0 -1
package/dist/FastMCP.cjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunk27HK2PAJcjs = require('./chunk-27HK2PAJ.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -24,7 +24,7 @@ var _chunkHTMIU2GUcjs = require('./chunk-HTMIU2GU.cjs');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkBTXI2HQScjs = require('./chunk-BTXI2HQS.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -49,5 +49,5 @@ var _chunkYO76IUZ6cjs = require('./chunk-YO76IUZ6.cjs');
|
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
exports.AuthProvider =
|
|
52
|
+
exports.AuthProvider = _chunkBTXI2HQScjs.AuthProvider; exports.AzureProvider = _chunkBTXI2HQScjs.AzureProvider; exports.DiscoveryDocumentCache = _chunk27HK2PAJcjs.DiscoveryDocumentCache; exports.FastMCP = _chunk27HK2PAJcjs.FastMCP; exports.FastMCPError = _chunk27HK2PAJcjs.FastMCPError; exports.FastMCPSession = _chunk27HK2PAJcjs.FastMCPSession; exports.GitHubProvider = _chunkBTXI2HQScjs.GitHubProvider; exports.GoogleProvider = _chunkBTXI2HQScjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunk27HK2PAJcjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkBTXI2HQScjs.OAuthProvider; exports.ServerState = _chunk27HK2PAJcjs.ServerState; exports.SessionError = _chunk27HK2PAJcjs.SessionError; exports.UnexpectedStateError = _chunk27HK2PAJcjs.UnexpectedStateError; exports.UserError = _chunk27HK2PAJcjs.UserError; exports.audioContent = _chunk27HK2PAJcjs.audioContent; exports.getAuthSession = _chunkBTXI2HQScjs.getAuthSession; exports.imageContent = _chunk27HK2PAJcjs.imageContent; exports.jsonSchemaAdapter = _chunk27HK2PAJcjs.jsonSchemaAdapter; exports.requireAll = _chunkBTXI2HQScjs.requireAll; exports.requireAny = _chunkBTXI2HQScjs.requireAny; exports.requireAuth = _chunkBTXI2HQScjs.requireAuth; exports.requireRole = _chunkBTXI2HQScjs.requireRole; exports.requireScopes = _chunkBTXI2HQScjs.requireScopes;
|
|
53
53
|
//# sourceMappingURL=FastMCP.cjs.map
|
package/dist/FastMCP.d.cts
CHANGED
|
@@ -916,8 +916,13 @@ declare class FastMCPSession<T extends FastMCPSessionAuth = FastMCPSessionAuth>
|
|
|
916
916
|
*/
|
|
917
917
|
get sessionId(): string | undefined;
|
|
918
918
|
set sessionId(value: string | undefined);
|
|
919
|
-
constructor({ auth, icons, instructions, logger, name, onToolCall, ping, prompts, resources, resourcesTemplates, roots, sessionId, stateless, streamKeepalive, title, tools, transportType, utils, version, websiteUrl, }: {
|
|
919
|
+
constructor({ auth, hasTools, icons, instructions, logger, name, onToolCall, ping, prompts, resources, resourcesTemplates, roots, sessionId, stateless, streamKeepalive, title, tools, transportType, utils, version, websiteUrl, }: {
|
|
920
920
|
auth?: T;
|
|
921
|
+
/**
|
|
922
|
+
* Whether the server has any tools at all, including ones this session's
|
|
923
|
+
* `canAccess` filtering removed from `tools`. Defaults to `tools.length > 0`.
|
|
924
|
+
*/
|
|
925
|
+
hasTools?: boolean;
|
|
921
926
|
icons?: Icon[];
|
|
922
927
|
instructions?: string;
|
|
923
928
|
logger: Logger;
|
package/dist/FastMCP.d.ts
CHANGED
|
@@ -916,8 +916,13 @@ declare class FastMCPSession<T extends FastMCPSessionAuth = FastMCPSessionAuth>
|
|
|
916
916
|
*/
|
|
917
917
|
get sessionId(): string | undefined;
|
|
918
918
|
set sessionId(value: string | undefined);
|
|
919
|
-
constructor({ auth, icons, instructions, logger, name, onToolCall, ping, prompts, resources, resourcesTemplates, roots, sessionId, stateless, streamKeepalive, title, tools, transportType, utils, version, websiteUrl, }: {
|
|
919
|
+
constructor({ auth, hasTools, icons, instructions, logger, name, onToolCall, ping, prompts, resources, resourcesTemplates, roots, sessionId, stateless, streamKeepalive, title, tools, transportType, utils, version, websiteUrl, }: {
|
|
920
920
|
auth?: T;
|
|
921
|
+
/**
|
|
922
|
+
* Whether the server has any tools at all, including ones this session's
|
|
923
|
+
* `canAccess` filtering removed from `tools`. Defaults to `tools.length > 0`.
|
|
924
|
+
*/
|
|
925
|
+
hasTools?: boolean;
|
|
921
926
|
icons?: Icon[];
|
|
922
927
|
instructions?: string;
|
|
923
928
|
logger: Logger;
|
package/dist/FastMCP.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
audioContent,
|
|
12
12
|
imageContent,
|
|
13
13
|
jsonSchemaAdapter
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-A5IEOE6F.js";
|
|
15
15
|
import {
|
|
16
16
|
AuthProvider,
|
|
17
17
|
AzureProvider,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
requireAuth,
|
|
25
25
|
requireRole,
|
|
26
26
|
requireScopes
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-YRIK6EIY.js";
|
|
28
28
|
export {
|
|
29
29
|
AuthProvider,
|
|
30
30
|
AzureProvider,
|
package/dist/auth/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkBTXI2HQScjs = require('../chunk-BTXI2HQS.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -51,5 +51,5 @@ var _chunkYO76IUZ6cjs = require('../chunk-YO76IUZ6.cjs');
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
exports.AuthProvider =
|
|
54
|
+
exports.AuthProvider = _chunkBTXI2HQScjs.AuthProvider; exports.AzureProvider = _chunkBTXI2HQScjs.AzureProvider; exports.ConsentManager = _chunkBTXI2HQScjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkBTXI2HQScjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkBTXI2HQScjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkBTXI2HQScjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkBTXI2HQScjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkBTXI2HQScjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkBTXI2HQScjs.DiskStore; exports.EncryptedTokenStorage = _chunkBTXI2HQScjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkBTXI2HQScjs.GitHubProvider; exports.GoogleProvider = _chunkBTXI2HQScjs.GoogleProvider; exports.JWKSVerifier = _chunkBTXI2HQScjs.JWKSVerifier; exports.JWTIssuer = _chunkBTXI2HQScjs.JWTIssuer; exports.MemoryTokenStorage = _chunkBTXI2HQScjs.MemoryTokenStorage; exports.OAuthProvider = _chunkBTXI2HQScjs.OAuthProvider; exports.OAuthProxy = _chunkBTXI2HQScjs.OAuthProxy; exports.OAuthProxyError = _chunkBTXI2HQScjs.OAuthProxyError; exports.PKCEUtils = _chunkBTXI2HQScjs.PKCEUtils; exports.getAuthSession = _chunkBTXI2HQScjs.getAuthSession; exports.requireAll = _chunkBTXI2HQScjs.requireAll; exports.requireAny = _chunkBTXI2HQScjs.requireAny; exports.requireAuth = _chunkBTXI2HQScjs.requireAuth; exports.requireRole = _chunkBTXI2HQScjs.requireRole; exports.requireScopes = _chunkBTXI2HQScjs.requireScopes;
|
|
55
55
|
//# sourceMappingURL=index.cjs.map
|
package/dist/auth/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 _chunkBTXI2HQScjs = require('./chunk-BTXI2HQS.cjs');
|
|
4
4
|
|
|
5
5
|
// src/FastMCP.ts
|
|
6
6
|
var _indexjs = require('@modelcontextprotocol/sdk/server/index.js');
|
|
@@ -131,7 +131,7 @@ var DiscoveryDocumentCache = class {
|
|
|
131
131
|
throw error;
|
|
132
132
|
}
|
|
133
133
|
if (!res.ok) {
|
|
134
|
-
await
|
|
134
|
+
await _chunkBTXI2HQScjs.cancelResponseBody.call(void 0, res);
|
|
135
135
|
throw new Error(
|
|
136
136
|
`Failed to fetch discovery document from ${url}: ${res.status} ${res.statusText}`
|
|
137
137
|
);
|
|
@@ -227,7 +227,7 @@ var imageContent = async (input) => {
|
|
|
227
227
|
signal: AbortSignal.timeout(timeoutMs)
|
|
228
228
|
});
|
|
229
229
|
if (!response.ok) {
|
|
230
|
-
await
|
|
230
|
+
await _chunkBTXI2HQScjs.cancelResponseBody.call(void 0, response);
|
|
231
231
|
throw new Error(
|
|
232
232
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
233
233
|
);
|
|
@@ -289,7 +289,7 @@ var audioContent = async (input) => {
|
|
|
289
289
|
signal: AbortSignal.timeout(timeoutMs)
|
|
290
290
|
});
|
|
291
291
|
if (!response.ok) {
|
|
292
|
-
await
|
|
292
|
+
await _chunkBTXI2HQScjs.cancelResponseBody.call(void 0, response);
|
|
293
293
|
throw new Error(
|
|
294
294
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
295
295
|
);
|
|
@@ -556,9 +556,11 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
556
556
|
* to interested clients only.
|
|
557
557
|
*/
|
|
558
558
|
#subscriptions = /* @__PURE__ */ new Set();
|
|
559
|
+
#transportType;
|
|
559
560
|
#utils;
|
|
560
561
|
constructor({
|
|
561
562
|
auth,
|
|
563
|
+
hasTools,
|
|
562
564
|
icons,
|
|
563
565
|
instructions,
|
|
564
566
|
logger,
|
|
@@ -588,8 +590,10 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
588
590
|
this.#sessionId = sessionId;
|
|
589
591
|
this.#stateless = stateless;
|
|
590
592
|
this.#streamKeepaliveConfig = streamKeepalive;
|
|
593
|
+
this.#transportType = transportType;
|
|
591
594
|
this.#needsEventLoopFlush = transportType === "httpStream";
|
|
592
|
-
|
|
595
|
+
const supportsTools = _nullishCoalesce(hasTools, () => ( tools.length > 0));
|
|
596
|
+
if (supportsTools) {
|
|
593
597
|
this.#capabilities.tools = {};
|
|
594
598
|
}
|
|
595
599
|
if (resources.length || resourcesTemplates.length) {
|
|
@@ -618,7 +622,7 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
618
622
|
this.setupLoggingHandlers();
|
|
619
623
|
this.setupRootsHandlers();
|
|
620
624
|
this.setupCompleteHandlers();
|
|
621
|
-
if (
|
|
625
|
+
if (supportsTools) {
|
|
622
626
|
this.setupToolHandlers(tools);
|
|
623
627
|
}
|
|
624
628
|
if (resources.length || resourcesTemplates.length) {
|
|
@@ -692,7 +696,7 @@ ${e instanceof Error ? e.stack : JSON.stringify(e)}`
|
|
|
692
696
|
}
|
|
693
697
|
}
|
|
694
698
|
if (this.#clientCapabilities) {
|
|
695
|
-
const pingConfig = this.#getPingConfig(
|
|
699
|
+
const pingConfig = this.#getPingConfig();
|
|
696
700
|
if (pingConfig.enabled) {
|
|
697
701
|
this.#pingInterval = setInterval(async () => {
|
|
698
702
|
if (this.#pingInFlight) {
|
|
@@ -916,14 +920,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
916
920
|
return `${path}: ${issue.message}`;
|
|
917
921
|
}).join(", ");
|
|
918
922
|
}
|
|
919
|
-
#getPingConfig(
|
|
923
|
+
#getPingConfig() {
|
|
920
924
|
const pingConfig = this.#pingConfig || {};
|
|
921
|
-
|
|
922
|
-
if ("type" in transport) {
|
|
923
|
-
if (transport.type === "httpStream") {
|
|
924
|
-
defaultEnabled = true;
|
|
925
|
-
}
|
|
926
|
-
}
|
|
925
|
+
const defaultEnabled = this.#transportType === "httpStream";
|
|
927
926
|
return {
|
|
928
927
|
enabled: pingConfig.enabled !== void 0 ? pingConfig.enabled : defaultEnabled,
|
|
929
928
|
intervalMs: pingConfig.intervalMs || 5e3,
|
|
@@ -1836,9 +1835,15 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1836
1835
|
const result = await directResource.load();
|
|
1837
1836
|
const results = Array.isArray(result) ? result : [result];
|
|
1838
1837
|
const firstResult = results[0];
|
|
1838
|
+
if (!firstResult) {
|
|
1839
|
+
throw new UnexpectedStateError(
|
|
1840
|
+
`Resource returned no contents: ${uri}`,
|
|
1841
|
+
{ uri }
|
|
1842
|
+
);
|
|
1843
|
+
}
|
|
1839
1844
|
const resourceData = {
|
|
1840
|
-
mimeType: directResource.mimeType,
|
|
1841
|
-
uri
|
|
1845
|
+
mimeType: _nullishCoalesce(firstResult.mimeType, () => ( directResource.mimeType)),
|
|
1846
|
+
uri: _nullishCoalesce(firstResult.uri, () => ( uri))
|
|
1842
1847
|
};
|
|
1843
1848
|
if ("text" in firstResult) {
|
|
1844
1849
|
resourceData.text = firstResult.text;
|
|
@@ -1857,15 +1862,23 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1857
1862
|
const result = await template.load(
|
|
1858
1863
|
params
|
|
1859
1864
|
);
|
|
1865
|
+
const results = Array.isArray(result) ? result : [result];
|
|
1866
|
+
const firstResult = results[0];
|
|
1867
|
+
if (!firstResult) {
|
|
1868
|
+
throw new UnexpectedStateError(
|
|
1869
|
+
`Resource returned no contents: ${uri}`,
|
|
1870
|
+
{ uri }
|
|
1871
|
+
);
|
|
1872
|
+
}
|
|
1860
1873
|
const resourceData = {
|
|
1861
|
-
mimeType: template.mimeType,
|
|
1862
|
-
uri
|
|
1874
|
+
mimeType: _nullishCoalesce(firstResult.mimeType, () => ( template.mimeType)),
|
|
1875
|
+
uri: _nullishCoalesce(firstResult.uri, () => ( uri))
|
|
1863
1876
|
};
|
|
1864
|
-
if ("text" in
|
|
1865
|
-
resourceData.text =
|
|
1877
|
+
if ("text" in firstResult) {
|
|
1878
|
+
resourceData.text = firstResult.text;
|
|
1866
1879
|
}
|
|
1867
|
-
if ("blob" in
|
|
1868
|
-
resourceData.blob =
|
|
1880
|
+
if ("blob" in firstResult) {
|
|
1881
|
+
resourceData.blob = firstResult.blob;
|
|
1869
1882
|
}
|
|
1870
1883
|
return resourceData;
|
|
1871
1884
|
}
|
|
@@ -2203,6 +2216,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2203
2216
|
) : this.#tools;
|
|
2204
2217
|
return new FastMCPSession({
|
|
2205
2218
|
auth,
|
|
2219
|
+
hasTools: this.#tools.length > 0,
|
|
2206
2220
|
icons: this.#options.icons,
|
|
2207
2221
|
instructions: this.#options.instructions,
|
|
2208
2222
|
logger: this.#logger,
|
|
@@ -2913,4 +2927,4 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2913
2927
|
|
|
2914
2928
|
|
|
2915
2929
|
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;
|
|
2916
|
-
//# sourceMappingURL=chunk-
|
|
2930
|
+
//# sourceMappingURL=chunk-27HK2PAJ.cjs.map
|