fastmcp 4.12.3 → 4.12.4
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 +2 -0
- package/dist/FastMCP.cjs +4 -2
- package/dist/FastMCP.cjs.map +1 -1
- package/dist/FastMCP.d.cts +13 -10
- package/dist/FastMCP.d.ts +13 -10
- package/dist/FastMCP.js +3 -1
- package/dist/{chunk-3O5ZKWCC.cjs → chunk-DD63MJG7.cjs} +22 -4
- package/dist/chunk-DD63MJG7.cjs.map +1 -0
- package/dist/{chunk-5K4GLQMV.js → chunk-FKX5QBJV.js} +21 -3
- package/dist/chunk-FKX5QBJV.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-3O5ZKWCC.cjs.map +0 -1
- package/dist/chunk-5K4GLQMV.js.map +0 -1
package/README.md
CHANGED
|
@@ -848,6 +848,7 @@ server.addTool({
|
|
|
848
848
|
The `imageContent` function takes the following options:
|
|
849
849
|
|
|
850
850
|
- `url`: The URL of the image.
|
|
851
|
+
- `timeoutMs`: Optional timeout for a URL download in milliseconds (defaults to 30 seconds).
|
|
851
852
|
- `path`: The path to the image file.
|
|
852
853
|
- `buffer`: The image data as a buffer.
|
|
853
854
|
|
|
@@ -1025,6 +1026,7 @@ server.addTool({
|
|
|
1025
1026
|
The `audioContent` function takes the following options:
|
|
1026
1027
|
|
|
1027
1028
|
- `url`: The URL of the audio.
|
|
1029
|
+
- `timeoutMs`: Optional timeout for a URL download in milliseconds (defaults to 30 seconds).
|
|
1028
1030
|
- `path`: The path to the audio file.
|
|
1029
1031
|
- `buffer`: The audio data as a buffer.
|
|
1030
1032
|
|
package/dist/FastMCP.cjs
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
var _chunkDD63MJG7cjs = require('./chunk-DD63MJG7.cjs');
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
|
|
@@ -47,5 +48,6 @@ var _chunkENMHHQJFcjs = require('./chunk-ENMHHQJF.cjs');
|
|
|
47
48
|
|
|
48
49
|
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
|
|
52
|
+
exports.AuthProvider = _chunkENMHHQJFcjs.AuthProvider; exports.AzureProvider = _chunkENMHHQJFcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkDD63MJG7cjs.DiscoveryDocumentCache; exports.FastMCP = _chunkDD63MJG7cjs.FastMCP; exports.FastMCPError = _chunkDD63MJG7cjs.FastMCPError; exports.FastMCPSession = _chunkDD63MJG7cjs.FastMCPSession; exports.GitHubProvider = _chunkENMHHQJFcjs.GitHubProvider; exports.GoogleProvider = _chunkENMHHQJFcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkDD63MJG7cjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkENMHHQJFcjs.OAuthProvider; exports.ServerState = _chunkDD63MJG7cjs.ServerState; exports.SessionError = _chunkDD63MJG7cjs.SessionError; exports.UnexpectedStateError = _chunkDD63MJG7cjs.UnexpectedStateError; exports.UserError = _chunkDD63MJG7cjs.UserError; exports.audioContent = _chunkDD63MJG7cjs.audioContent; exports.getAuthSession = _chunkENMHHQJFcjs.getAuthSession; exports.imageContent = _chunkDD63MJG7cjs.imageContent; exports.jsonSchemaAdapter = _chunkDD63MJG7cjs.jsonSchemaAdapter; exports.requireAll = _chunkENMHHQJFcjs.requireAll; exports.requireAny = _chunkENMHHQJFcjs.requireAny; exports.requireAuth = _chunkENMHHQJFcjs.requireAuth; exports.requireRole = _chunkENMHHQJFcjs.requireRole; exports.requireScopes = _chunkENMHHQJFcjs.requireScopes;
|
|
51
53
|
//# sourceMappingURL=FastMCP.cjs.map
|
package/dist/FastMCP.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/fastmcp/fastmcp/dist/FastMCP.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/fastmcp/fastmcp/dist/FastMCP.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,0yCAAC","file":"/home/runner/work/fastmcp/fastmcp/dist/FastMCP.cjs"}
|
package/dist/FastMCP.d.cts
CHANGED
|
@@ -141,20 +141,23 @@ type FastMCPSessionEvents = {
|
|
|
141
141
|
roots: Root[];
|
|
142
142
|
}) => void;
|
|
143
143
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Timeout for image/audio URL fetches (in milliseconds). The OAuth upstream
|
|
146
|
+
* fetches (#304) use 10s because they are short interactive exchanges; media
|
|
147
|
+
* downloads can be larger and slower, so 30s is the balance between hanging
|
|
148
|
+
* forever on an unresponsive server and false positives on slow connections.
|
|
149
|
+
*/
|
|
150
|
+
declare const MEDIA_FETCH_TIMEOUT_MS = 30000;
|
|
151
|
+
type MediaContentInput = {
|
|
152
152
|
buffer: Buffer;
|
|
153
153
|
} | {
|
|
154
154
|
path: string;
|
|
155
155
|
} | {
|
|
156
|
+
timeoutMs?: number;
|
|
156
157
|
url: string;
|
|
157
|
-
}
|
|
158
|
+
};
|
|
159
|
+
declare const imageContent: (input: MediaContentInput) => Promise<ImageContent>;
|
|
160
|
+
declare const audioContent: (input: MediaContentInput) => Promise<AudioContent>;
|
|
158
161
|
type Context<T extends FastMCPSessionAuth> = {
|
|
159
162
|
client: {
|
|
160
163
|
version: ReturnType<Server["getClientVersion"]>;
|
|
@@ -1054,4 +1057,4 @@ declare class FastMCP<T extends FastMCPSessionAuth = FastMCPSessionAuth> extends
|
|
|
1054
1057
|
stop(): Promise<void>;
|
|
1055
1058
|
}
|
|
1056
1059
|
|
|
1057
|
-
export { type AudioContent, AuthProvider, type Content, type ContentResult, type Context, DiscoveryDocumentCache, FastMCP, FastMCPError, type FastMCPEvents, type FastMCPRequest, type FastMCPResponse, FastMCPSession, type FastMCPSessionAuth, type FastMCPSessionEvents, type HTTPMethod, type ImageContent, type InputPrompt, type InputPromptArgument, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type Logger, type LoggingLevel, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceResult, type ResourceTemplate, type ResourceTemplateArgument, type RouteHandler, type RouteOptions, type SSEServer, type SerializableValue, type ServerOptions, ServerState, SessionError, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, audioContent, imageContent, jsonSchemaAdapter };
|
|
1060
|
+
export { type AudioContent, AuthProvider, type Content, type ContentResult, type Context, DiscoveryDocumentCache, FastMCP, FastMCPError, type FastMCPEvents, type FastMCPRequest, type FastMCPResponse, FastMCPSession, type FastMCPSessionAuth, type FastMCPSessionEvents, type HTTPMethod, type ImageContent, type InputPrompt, type InputPromptArgument, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type Logger, type LoggingLevel, MEDIA_FETCH_TIMEOUT_MS, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceResult, type ResourceTemplate, type ResourceTemplateArgument, type RouteHandler, type RouteOptions, type SSEServer, type SerializableValue, type ServerOptions, ServerState, SessionError, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, audioContent, imageContent, jsonSchemaAdapter };
|
package/dist/FastMCP.d.ts
CHANGED
|
@@ -141,20 +141,23 @@ type FastMCPSessionEvents = {
|
|
|
141
141
|
roots: Root[];
|
|
142
142
|
}) => void;
|
|
143
143
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Timeout for image/audio URL fetches (in milliseconds). The OAuth upstream
|
|
146
|
+
* fetches (#304) use 10s because they are short interactive exchanges; media
|
|
147
|
+
* downloads can be larger and slower, so 30s is the balance between hanging
|
|
148
|
+
* forever on an unresponsive server and false positives on slow connections.
|
|
149
|
+
*/
|
|
150
|
+
declare const MEDIA_FETCH_TIMEOUT_MS = 30000;
|
|
151
|
+
type MediaContentInput = {
|
|
152
152
|
buffer: Buffer;
|
|
153
153
|
} | {
|
|
154
154
|
path: string;
|
|
155
155
|
} | {
|
|
156
|
+
timeoutMs?: number;
|
|
156
157
|
url: string;
|
|
157
|
-
}
|
|
158
|
+
};
|
|
159
|
+
declare const imageContent: (input: MediaContentInput) => Promise<ImageContent>;
|
|
160
|
+
declare const audioContent: (input: MediaContentInput) => Promise<AudioContent>;
|
|
158
161
|
type Context<T extends FastMCPSessionAuth> = {
|
|
159
162
|
client: {
|
|
160
163
|
version: ReturnType<Server["getClientVersion"]>;
|
|
@@ -1054,4 +1057,4 @@ declare class FastMCP<T extends FastMCPSessionAuth = FastMCPSessionAuth> extends
|
|
|
1054
1057
|
stop(): Promise<void>;
|
|
1055
1058
|
}
|
|
1056
1059
|
|
|
1057
|
-
export { type AudioContent, AuthProvider, type Content, type ContentResult, type Context, DiscoveryDocumentCache, FastMCP, FastMCPError, type FastMCPEvents, type FastMCPRequest, type FastMCPResponse, FastMCPSession, type FastMCPSessionAuth, type FastMCPSessionEvents, type HTTPMethod, type ImageContent, type InputPrompt, type InputPromptArgument, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type Logger, type LoggingLevel, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceResult, type ResourceTemplate, type ResourceTemplateArgument, type RouteHandler, type RouteOptions, type SSEServer, type SerializableValue, type ServerOptions, ServerState, SessionError, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, audioContent, imageContent, jsonSchemaAdapter };
|
|
1060
|
+
export { type AudioContent, AuthProvider, type Content, type ContentResult, type Context, DiscoveryDocumentCache, FastMCP, FastMCPError, type FastMCPEvents, type FastMCPRequest, type FastMCPResponse, FastMCPSession, type FastMCPSessionAuth, type FastMCPSessionEvents, type HTTPMethod, type ImageContent, type InputPrompt, type InputPromptArgument, type JsonSchemaObject, type JsonSchemaStandardSchema, type LoadContext, type Logger, type LoggingLevel, MEDIA_FETCH_TIMEOUT_MS, OAuthSession, type Progress, type Prompt, type PromptArgument, type Resource, type ResourceContent, type ResourceResult, type ResourceTemplate, type ResourceTemplateArgument, type RouteHandler, type RouteOptions, type SSEServer, type SerializableValue, type ServerOptions, ServerState, SessionError, type TextContent, type Tool, type ToolParameters, UnexpectedStateError, UserError, audioContent, imageContent, jsonSchemaAdapter };
|
package/dist/FastMCP.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
FastMCP,
|
|
4
4
|
FastMCPError,
|
|
5
5
|
FastMCPSession,
|
|
6
|
+
MEDIA_FETCH_TIMEOUT_MS,
|
|
6
7
|
ServerState,
|
|
7
8
|
SessionError,
|
|
8
9
|
UnexpectedStateError,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
audioContent,
|
|
11
12
|
imageContent,
|
|
12
13
|
jsonSchemaAdapter
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-FKX5QBJV.js";
|
|
14
15
|
import {
|
|
15
16
|
AuthProvider,
|
|
16
17
|
AzureProvider,
|
|
@@ -33,6 +34,7 @@ export {
|
|
|
33
34
|
FastMCPSession,
|
|
34
35
|
GitHubProvider,
|
|
35
36
|
GoogleProvider,
|
|
37
|
+
MEDIA_FETCH_TIMEOUT_MS,
|
|
36
38
|
OAuthProvider,
|
|
37
39
|
ServerState,
|
|
38
40
|
SessionError,
|
|
@@ -197,12 +197,16 @@ function unwrapDefault(value) {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
// src/FastMCP.ts
|
|
200
|
+
var MEDIA_FETCH_TIMEOUT_MS = 3e4;
|
|
200
201
|
var imageContent = async (input) => {
|
|
201
202
|
let rawData;
|
|
202
203
|
try {
|
|
203
204
|
if ("url" in input) {
|
|
205
|
+
const timeoutMs = _nullishCoalesce(input.timeoutMs, () => ( MEDIA_FETCH_TIMEOUT_MS));
|
|
204
206
|
try {
|
|
205
|
-
const response = await _undici.fetch.call(void 0, input.url
|
|
207
|
+
const response = await _undici.fetch.call(void 0, input.url, {
|
|
208
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
209
|
+
});
|
|
206
210
|
if (!response.ok) {
|
|
207
211
|
throw new Error(
|
|
208
212
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
@@ -210,6 +214,11 @@ var imageContent = async (input) => {
|
|
|
210
214
|
}
|
|
211
215
|
rawData = Buffer.from(await response.arrayBuffer());
|
|
212
216
|
} catch (error) {
|
|
217
|
+
if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Failed to fetch image from URL (${input.url}): timed out after ${timeoutMs}ms`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
213
222
|
throw new Error(
|
|
214
223
|
`Failed to fetch image from URL (${input.url}): ${error instanceof Error ? error.message : String(error)}`
|
|
215
224
|
);
|
|
@@ -254,8 +263,11 @@ var audioContent = async (input) => {
|
|
|
254
263
|
let rawData;
|
|
255
264
|
try {
|
|
256
265
|
if ("url" in input) {
|
|
266
|
+
const timeoutMs = _nullishCoalesce(input.timeoutMs, () => ( MEDIA_FETCH_TIMEOUT_MS));
|
|
257
267
|
try {
|
|
258
|
-
const response = await _undici.fetch.call(void 0, input.url
|
|
268
|
+
const response = await _undici.fetch.call(void 0, input.url, {
|
|
269
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
270
|
+
});
|
|
259
271
|
if (!response.ok) {
|
|
260
272
|
throw new Error(
|
|
261
273
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
@@ -263,6 +275,11 @@ var audioContent = async (input) => {
|
|
|
263
275
|
}
|
|
264
276
|
rawData = Buffer.from(await response.arrayBuffer());
|
|
265
277
|
} catch (error) {
|
|
278
|
+
if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
|
|
279
|
+
throw new Error(
|
|
280
|
+
`Failed to fetch audio from URL (${input.url}): timed out after ${timeoutMs}ms`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
266
283
|
throw new Error(
|
|
267
284
|
`Failed to fetch audio from URL (${input.url}): ${error instanceof Error ? error.message : String(error)}`
|
|
268
285
|
);
|
|
@@ -2529,5 +2546,6 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2529
2546
|
|
|
2530
2547
|
|
|
2531
2548
|
|
|
2532
|
-
|
|
2533
|
-
|
|
2549
|
+
|
|
2550
|
+
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;
|
|
2551
|
+
//# sourceMappingURL=chunk-DD63MJG7.cjs.map
|