fastmcp 4.21.2 → 4.22.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 +12 -2
- package/dist/FastMCP.cjs +3 -3
- package/dist/FastMCP.d.cts +2 -2
- package/dist/FastMCP.d.ts +2 -2
- package/dist/FastMCP.js +2 -2
- package/dist/{OAuthProvider-C4idKF29.d.cts → OAuthProvider-BcDb5bOz.d.cts} +8 -1
- package/dist/{OAuthProvider-C4idKF29.d.ts → OAuthProvider-BcDb5bOz.d.ts} +8 -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-QMRS4ZLD.js → chunk-43N2Q6ZI.js} +111 -10
- package/dist/chunk-43N2Q6ZI.js.map +1 -0
- package/dist/{chunk-C5VOVQPC.cjs → chunk-V4JBWBT4.cjs} +114 -13
- package/dist/chunk-V4JBWBT4.cjs.map +1 -0
- package/dist/{chunk-AR3LVWUF.js → chunk-XPKMA7DH.js} +22 -1
- package/dist/chunk-XPKMA7DH.js.map +1 -0
- package/dist/{chunk-GTPK7A57.cjs → chunk-YOBCXNFP.cjs} +22 -1
- package/dist/chunk-YOBCXNFP.cjs.map +1 -0
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/dist/openapi/index.cjs +24 -9
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +5 -3
- package/dist/openapi/index.d.ts +5 -3
- package/dist/openapi/index.js +20 -5
- package/dist/openapi/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-AR3LVWUF.js.map +0 -1
- package/dist/chunk-C5VOVQPC.cjs.map +0 -1
- package/dist/chunk-GTPK7A57.cjs.map +0 -1
- package/dist/chunk-QMRS4ZLD.js.map +0 -1
package/README.md
CHANGED
|
@@ -1280,6 +1280,12 @@ The `log` object has the following methods:
|
|
|
1280
1280
|
- `info(message: string, data?: SerializableValue)`
|
|
1281
1281
|
- `warn(message: string, data?: SerializableValue)`
|
|
1282
1282
|
|
|
1283
|
+
A client can raise the minimum level it wants with the `logging/setLevel`
|
|
1284
|
+
request, and FastMCP then drops anything less severe instead of sending it — so
|
|
1285
|
+
after `logging/setLevel` with `error`, `log.debug` and `log.info` reach nobody.
|
|
1286
|
+
Until a client asks, every level is sent. The level in force is readable as
|
|
1287
|
+
[`session.loggingLevel`](#logginglevel).
|
|
1288
|
+
|
|
1283
1289
|
#### Errors
|
|
1284
1290
|
|
|
1285
1291
|
The errors that are meant to be shown to the user should be thrown as `UserError` instances:
|
|
@@ -1617,7 +1623,9 @@ server.addResource({
|
|
|
1617
1623
|
await server.sendResourceUpdated("file:///logs/app.log");
|
|
1618
1624
|
```
|
|
1619
1625
|
|
|
1620
|
-
`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.
|
|
1626
|
+
`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 tools, resources and prompts and emits `notifications/tools/list_changed` / `notifications/resources/list_changed` / `notifications/prompts/list_changed` automatically when you add or remove tools, resources, resource templates, or prompts at runtime.
|
|
1627
|
+
|
|
1628
|
+
One session cannot be shown a kind of primitive it never negotiated. MCP settles capabilities during `initialize` and they hold for the life of the session, so a client that connected while the server had no resources at all will not see resources added later — FastMCP logs a warning naming the capability and leaves that session alone. Register one of each kind you intend to add before `start()`, or have the client reconnect; sessions that connect afterwards see everything.
|
|
1621
1629
|
|
|
1622
1630
|
### Resource templates
|
|
1623
1631
|
|
|
@@ -2632,7 +2640,9 @@ session.clientCapabilities;
|
|
|
2632
2640
|
|
|
2633
2641
|
### `loggingLevel`
|
|
2634
2642
|
|
|
2635
|
-
The `loggingLevel` property describes the logging level as set by the client.
|
|
2643
|
+
The `loggingLevel` property describes the logging level as set by the client. It
|
|
2644
|
+
reads `info` until the client sends `logging/setLevel`; messages less severe than
|
|
2645
|
+
the level the client did set are dropped rather than sent.
|
|
2636
2646
|
|
|
2637
2647
|
```ts
|
|
2638
2648
|
session.loggingLevel;
|
package/dist/FastMCP.cjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkV4JBWBT4cjs = require('./chunk-V4JBWBT4.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -24,7 +24,7 @@ var _chunkC5VOVQPCcjs = require('./chunk-C5VOVQPC.cjs');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkYOBCXNFPcjs = require('./chunk-YOBCXNFP.cjs');
|
|
28
28
|
require('./chunk-O22SYZMC.cjs');
|
|
29
29
|
|
|
30
30
|
|
|
@@ -50,5 +50,5 @@ require('./chunk-O22SYZMC.cjs');
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
exports.AuthProvider =
|
|
53
|
+
exports.AuthProvider = _chunkYOBCXNFPcjs.AuthProvider; exports.AzureProvider = _chunkYOBCXNFPcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkV4JBWBT4cjs.DiscoveryDocumentCache; exports.FastMCP = _chunkV4JBWBT4cjs.FastMCP; exports.FastMCPError = _chunkV4JBWBT4cjs.FastMCPError; exports.FastMCPSession = _chunkV4JBWBT4cjs.FastMCPSession; exports.GitHubProvider = _chunkYOBCXNFPcjs.GitHubProvider; exports.GoogleProvider = _chunkYOBCXNFPcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkV4JBWBT4cjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkYOBCXNFPcjs.OAuthProvider; exports.ServerState = _chunkV4JBWBT4cjs.ServerState; exports.SessionError = _chunkV4JBWBT4cjs.SessionError; exports.UnexpectedStateError = _chunkV4JBWBT4cjs.UnexpectedStateError; exports.UserError = _chunkV4JBWBT4cjs.UserError; exports.audioContent = _chunkV4JBWBT4cjs.audioContent; exports.getAuthSession = _chunkYOBCXNFPcjs.getAuthSession; exports.imageContent = _chunkV4JBWBT4cjs.imageContent; exports.jsonSchemaAdapter = _chunkV4JBWBT4cjs.jsonSchemaAdapter; exports.requireAll = _chunkYOBCXNFPcjs.requireAll; exports.requireAny = _chunkYOBCXNFPcjs.requireAny; exports.requireAuth = _chunkYOBCXNFPcjs.requireAuth; exports.requireRole = _chunkYOBCXNFPcjs.requireRole; exports.requireScopes = _chunkYOBCXNFPcjs.requireScopes;
|
|
54
54
|
//# sourceMappingURL=FastMCP.cjs.map
|
package/dist/FastMCP.d.cts
CHANGED
|
@@ -12,8 +12,8 @@ import { CorsOptions } from 'mcp-proxy';
|
|
|
12
12
|
export { CorsOptions } from 'mcp-proxy';
|
|
13
13
|
import { StrictEventEmitter } from 'strict-event-emitter-types';
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
-
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-
|
|
16
|
-
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-
|
|
15
|
+
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-BcDb5bOz.cjs';
|
|
16
|
+
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-BcDb5bOz.cjs';
|
|
17
17
|
import 'node:http';
|
|
18
18
|
|
|
19
19
|
declare class DiscoveryDocumentCache {
|
package/dist/FastMCP.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ import { CorsOptions } from 'mcp-proxy';
|
|
|
12
12
|
export { CorsOptions } from 'mcp-proxy';
|
|
13
13
|
import { StrictEventEmitter } from 'strict-event-emitter-types';
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
-
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-
|
|
16
|
-
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-
|
|
15
|
+
import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-BcDb5bOz.js';
|
|
16
|
+
export { j as AuthProviderConfig, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, d as OAuthProvider, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from './OAuthProvider-BcDb5bOz.js';
|
|
17
17
|
import 'node:http';
|
|
18
18
|
|
|
19
19
|
declare class DiscoveryDocumentCache {
|
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-43N2Q6ZI.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-XPKMA7DH.js";
|
|
28
28
|
import "./chunk-UMDUIBFW.js";
|
|
29
29
|
export {
|
|
30
30
|
AuthProvider,
|
|
@@ -746,7 +746,7 @@ declare class OAuthProxyError extends Error {
|
|
|
746
746
|
/**
|
|
747
747
|
* Configuration common to all OAuth providers.
|
|
748
748
|
*/
|
|
749
|
-
interface AuthProviderConfig {
|
|
749
|
+
interface AuthProviderConfig extends ForwardedProxyOptions {
|
|
750
750
|
/**
|
|
751
751
|
* Allow-list of redirect URI patterns accepted by Dynamic Client
|
|
752
752
|
* Registration. Required for any deployment that exposes /oauth/register
|
|
@@ -805,6 +805,8 @@ interface OAuthSession {
|
|
|
805
805
|
/** Scopes granted by the OAuth provider */
|
|
806
806
|
scopes?: string[];
|
|
807
807
|
}
|
|
808
|
+
/** OAuthProxy options that providers pass through unchanged. */
|
|
809
|
+
type ForwardedProxyOptions = Pick<OAuthProxyConfig, "allowPlainPkce" | "authorizationResponseIss" | "enableCimd">;
|
|
808
810
|
/**
|
|
809
811
|
* Abstract base class for OAuth providers.
|
|
810
812
|
* Encapsulates OAuthProxy creation, authenticate function, and oauth config.
|
|
@@ -813,6 +815,11 @@ interface OAuthSession {
|
|
|
813
815
|
*/
|
|
814
816
|
declare abstract class AuthProvider<TSession extends OAuthSession = OAuthSession> {
|
|
815
817
|
protected config: AuthProviderConfig;
|
|
818
|
+
/**
|
|
819
|
+
* The forwarded proxy options that are set. Unset ones are left out so the
|
|
820
|
+
* proxy's own defaults apply.
|
|
821
|
+
*/
|
|
822
|
+
protected get forwardedProxyOptions(): ForwardedProxyOptions;
|
|
816
823
|
/**
|
|
817
824
|
* Get the proxy, creating it lazily if needed.
|
|
818
825
|
*/
|
|
@@ -746,7 +746,7 @@ declare class OAuthProxyError extends Error {
|
|
|
746
746
|
/**
|
|
747
747
|
* Configuration common to all OAuth providers.
|
|
748
748
|
*/
|
|
749
|
-
interface AuthProviderConfig {
|
|
749
|
+
interface AuthProviderConfig extends ForwardedProxyOptions {
|
|
750
750
|
/**
|
|
751
751
|
* Allow-list of redirect URI patterns accepted by Dynamic Client
|
|
752
752
|
* Registration. Required for any deployment that exposes /oauth/register
|
|
@@ -805,6 +805,8 @@ interface OAuthSession {
|
|
|
805
805
|
/** Scopes granted by the OAuth provider */
|
|
806
806
|
scopes?: string[];
|
|
807
807
|
}
|
|
808
|
+
/** OAuthProxy options that providers pass through unchanged. */
|
|
809
|
+
type ForwardedProxyOptions = Pick<OAuthProxyConfig, "allowPlainPkce" | "authorizationResponseIss" | "enableCimd">;
|
|
808
810
|
/**
|
|
809
811
|
* Abstract base class for OAuth providers.
|
|
810
812
|
* Encapsulates OAuthProxy creation, authenticate function, and oauth config.
|
|
@@ -813,6 +815,11 @@ interface OAuthSession {
|
|
|
813
815
|
*/
|
|
814
816
|
declare abstract class AuthProvider<TSession extends OAuthSession = OAuthSession> {
|
|
815
817
|
protected config: AuthProviderConfig;
|
|
818
|
+
/**
|
|
819
|
+
* The forwarded proxy options that are set. Unset ones are left out so the
|
|
820
|
+
* proxy's own defaults apply.
|
|
821
|
+
*/
|
|
822
|
+
protected get forwardedProxyOptions(): ForwardedProxyOptions;
|
|
816
823
|
/**
|
|
817
824
|
* Get the proxy, creating it lazily if needed.
|
|
818
825
|
*/
|
package/dist/auth/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkYOBCXNFPcjs = require('../chunk-YOBCXNFP.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -51,5 +51,5 @@ var _chunkGTPK7A57cjs = require('../chunk-GTPK7A57.cjs');
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
exports.AuthProvider =
|
|
54
|
+
exports.AuthProvider = _chunkYOBCXNFPcjs.AuthProvider; exports.AzureProvider = _chunkYOBCXNFPcjs.AzureProvider; exports.ConsentManager = _chunkYOBCXNFPcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkYOBCXNFPcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkYOBCXNFPcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkYOBCXNFPcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkYOBCXNFPcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkYOBCXNFPcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkYOBCXNFPcjs.DiskStore; exports.EncryptedTokenStorage = _chunkYOBCXNFPcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkYOBCXNFPcjs.GitHubProvider; exports.GoogleProvider = _chunkYOBCXNFPcjs.GoogleProvider; exports.JWKSVerifier = _chunkYOBCXNFPcjs.JWKSVerifier; exports.JWTIssuer = _chunkYOBCXNFPcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkYOBCXNFPcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkYOBCXNFPcjs.OAuthProvider; exports.OAuthProxy = _chunkYOBCXNFPcjs.OAuthProxy; exports.OAuthProxyError = _chunkYOBCXNFPcjs.OAuthProxyError; exports.PKCEUtils = _chunkYOBCXNFPcjs.PKCEUtils; exports.getAuthSession = _chunkYOBCXNFPcjs.getAuthSession; exports.requireAll = _chunkYOBCXNFPcjs.requireAll; exports.requireAny = _chunkYOBCXNFPcjs.requireAny; exports.requireAuth = _chunkYOBCXNFPcjs.requireAuth; exports.requireRole = _chunkYOBCXNFPcjs.requireRole; exports.requireScopes = _chunkYOBCXNFPcjs.requireScopes;
|
|
55
55
|
//# sourceMappingURL=index.cjs.map
|
package/dist/auth/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-
|
|
2
|
-
export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-
|
|
1
|
+
import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-BcDb5bOz.cjs';
|
|
2
|
+
export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-BcDb5bOz.cjs';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-
|
|
2
|
-
export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-
|
|
1
|
+
import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-BcDb5bOz.js';
|
|
2
|
+
export { A as AuthProvider, j as AuthProviderConfig, y as AuthorizationParams, b as AzureProvider, k as AzureProviderConfig, l as AzureSession, z as ClientCode, B as DCRClientMetadata, E as DCRRequest, F as DCRResponse, D as DEFAULT_ACCESS_TOKEN_TTL, u as DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH, v as DEFAULT_AUTHORIZATION_CODE_TTL, w as DEFAULT_REFRESH_TOKEN_TTL, x as DEFAULT_TRANSACTION_TTL, m as GenericOAuthProviderConfig, G as GitHubProvider, n as GitHubSession, c as GoogleProvider, o as GoogleSession, H as OAuthError, d as OAuthProvider, I as OAuthProviderConfig, a as OAuthProxy, J as OAuthProxyConfig, t as OAuthProxyError, O as OAuthSession, K as ProxyDCRClient, R as RefreshRequest, L as TokenMapping, M as TokenRequest, N as TokenResponse, U as UpstreamTokenSet, g as getAuthSession, r as requireAll, e as requireAny, f as requireAuth, h as requireRole, i as requireScopes } from '../OAuthProvider-BcDb5bOz.js';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/auth/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cancelResponseBody
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XPKMA7DH.js";
|
|
4
4
|
import {
|
|
5
5
|
strictInputSchema
|
|
6
6
|
} from "./chunk-UMDUIBFW.js";
|
|
@@ -464,6 +464,17 @@ var capCompletionValues = (completion) => {
|
|
|
464
464
|
values: completion.values.slice(0, COMPLETION_VALUES_LIMIT)
|
|
465
465
|
};
|
|
466
466
|
};
|
|
467
|
+
var DEFAULT_LOGGING_LEVEL = "info";
|
|
468
|
+
var LOGGING_LEVEL_SEVERITY = {
|
|
469
|
+
alert: 6,
|
|
470
|
+
critical: 5,
|
|
471
|
+
debug: 0,
|
|
472
|
+
emergency: 7,
|
|
473
|
+
error: 4,
|
|
474
|
+
info: 1,
|
|
475
|
+
notice: 2,
|
|
476
|
+
warning: 3
|
|
477
|
+
};
|
|
467
478
|
var FastMCPSessionEventEmitterBase = EventEmitter;
|
|
468
479
|
var ServerState = /* @__PURE__ */ ((ServerState2) => {
|
|
469
480
|
ServerState2["Error"] = "error";
|
|
@@ -481,7 +492,7 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
481
492
|
return this.#connectionState === "ready";
|
|
482
493
|
}
|
|
483
494
|
get loggingLevel() {
|
|
484
|
-
return this.#loggingLevel;
|
|
495
|
+
return this.#loggingLevel ?? DEFAULT_LOGGING_LEVEL;
|
|
485
496
|
}
|
|
486
497
|
get roots() {
|
|
487
498
|
return this.#roots;
|
|
@@ -530,7 +541,11 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
530
541
|
#clientCapabilities;
|
|
531
542
|
#connectionState = "connecting";
|
|
532
543
|
#logger;
|
|
533
|
-
|
|
544
|
+
/**
|
|
545
|
+
* The minimum level the client asked for with `logging/setLevel`, or
|
|
546
|
+
* `undefined` while it has not asked. See {@link DEFAULT_LOGGING_LEVEL}.
|
|
547
|
+
*/
|
|
548
|
+
#loggingLevel;
|
|
534
549
|
#needsEventLoopFlush = false;
|
|
535
550
|
#onToolCall;
|
|
536
551
|
#pingConfig;
|
|
@@ -561,6 +576,12 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
561
576
|
*/
|
|
562
577
|
#subscriptions = /* @__PURE__ */ new Set();
|
|
563
578
|
#transportType;
|
|
579
|
+
/**
|
|
580
|
+
* Capabilities this session has already warned about in `#canRefresh`, so a
|
|
581
|
+
* server that registers a hundred resources at runtime logs one line rather
|
|
582
|
+
* than a hundred.
|
|
583
|
+
*/
|
|
584
|
+
#unnegotiatedWarnings = /* @__PURE__ */ new Set();
|
|
564
585
|
#utils;
|
|
565
586
|
constructor({
|
|
566
587
|
auth,
|
|
@@ -600,7 +621,7 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
600
621
|
this.#needsEventLoopFlush = transportType === "httpStream";
|
|
601
622
|
const supportsTools = hasTools ?? tools.length > 0;
|
|
602
623
|
if (supportsTools) {
|
|
603
|
-
this.#capabilities.tools = {};
|
|
624
|
+
this.#capabilities.tools = { listChanged: true };
|
|
604
625
|
}
|
|
605
626
|
if (resources.length || resourcesTemplates.length) {
|
|
606
627
|
this.#capabilities.resources = { listChanged: true, subscribe: true };
|
|
@@ -744,6 +765,9 @@ ${e instanceof Error ? e.stack : JSON.stringify(e)}`
|
|
|
744
765
|
}
|
|
745
766
|
}
|
|
746
767
|
promptsListChanged(prompts) {
|
|
768
|
+
if (!this.#canRefresh("prompts")) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
747
771
|
this.#prompts.clear();
|
|
748
772
|
for (const prompt of prompts) {
|
|
749
773
|
this.addPrompt(prompt);
|
|
@@ -758,6 +782,9 @@ ${e instanceof Error ? e.stack : JSON.stringify(e)}`
|
|
|
758
782
|
return this.#server.createMessage(message, options);
|
|
759
783
|
}
|
|
760
784
|
resourcesListChanged(resources) {
|
|
785
|
+
if (!this.#canRefresh("resources")) {
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
761
788
|
this.#resources.clear();
|
|
762
789
|
for (const resource of resources) {
|
|
763
790
|
this.addResource(resource);
|
|
@@ -766,6 +793,9 @@ ${e instanceof Error ? e.stack : JSON.stringify(e)}`
|
|
|
766
793
|
this.triggerListChangedNotification("notifications/resources/list_changed");
|
|
767
794
|
}
|
|
768
795
|
resourceTemplatesListChanged(resourceTemplates) {
|
|
796
|
+
if (!this.#canRefresh("resources")) {
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
769
799
|
this.#resourceTemplates.clear();
|
|
770
800
|
for (const resourceTemplate of resourceTemplates) {
|
|
771
801
|
this.addResourceTemplate(resourceTemplate);
|
|
@@ -795,6 +825,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
795
825
|
}
|
|
796
826
|
}
|
|
797
827
|
toolsListChanged(tools) {
|
|
828
|
+
if (!this.#canRefresh("tools")) {
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
798
831
|
this.setupToolHandlers(
|
|
799
832
|
toolsVisibleTo(tools, this.#auth, this.#authRequired)
|
|
800
833
|
);
|
|
@@ -857,6 +890,30 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
857
890
|
this.#abortController.abort(new SessionError("Session closed"));
|
|
858
891
|
}
|
|
859
892
|
}
|
|
893
|
+
/**
|
|
894
|
+
* Whether this session can be told about a primitive added at runtime.
|
|
895
|
+
*
|
|
896
|
+
* A session that connected before the server had any tool, resource or prompt
|
|
897
|
+
* of its own never advertised that capability, and MCP fixes capabilities
|
|
898
|
+
* during `initialize` for the life of the session. Registering the handler
|
|
899
|
+
* anyway makes the SDK throw `Server does not support <capability>` — out of
|
|
900
|
+
* `addTool()`, `addResource()`, `addResourceTemplate()` or `addPrompt()`,
|
|
901
|
+
* which are the public builder methods, and out of the middle of the loop
|
|
902
|
+
* over sessions, so the sessions after this one never heard about the change
|
|
903
|
+
* either. Warn once instead and let the rest of the loop run.
|
|
904
|
+
*/
|
|
905
|
+
#canRefresh(capability) {
|
|
906
|
+
if (this.#capabilities[capability]) {
|
|
907
|
+
return true;
|
|
908
|
+
}
|
|
909
|
+
if (!this.#unnegotiatedWarnings.has(capability)) {
|
|
910
|
+
this.#unnegotiatedWarnings.add(capability);
|
|
911
|
+
this.#logger.warn(
|
|
912
|
+
`[FastMCP warning] This session advertised no '${capability}' capability, because the server had none when the client connected, so it cannot be shown the ones registered since. Register one before start(), or reconnect the client; sessions that connect from now on do see them.`
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
860
917
|
/**
|
|
861
918
|
* Builds the context object passed as the third argument to
|
|
862
919
|
* `resource.load` / `resourceTemplate.load` / `prompt.load`.
|
|
@@ -917,6 +974,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
917
974
|
* disconnects mid-tool takes the server process down with it.
|
|
918
975
|
*/
|
|
919
976
|
#sendLog(level, message, context) {
|
|
977
|
+
if (this.#loggingLevel && LOGGING_LEVEL_SEVERITY[level] < LOGGING_LEVEL_SEVERITY[this.#loggingLevel]) {
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
920
980
|
this.#server.sendLoggingMessage({
|
|
921
981
|
data: {
|
|
922
982
|
context,
|
|
@@ -940,6 +1000,12 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
940
1000
|
* request's own stream, which is the only server-to-client route that exists
|
|
941
1001
|
* when running stateless.
|
|
942
1002
|
*
|
|
1003
|
+
* It is deliberately not filtered against the level the client set with
|
|
1004
|
+
* `logging/setLevel`, unlike the `log` object a tool is handed: its job is to
|
|
1005
|
+
* put bytes on the stream, and a client that asked for `error` only would
|
|
1006
|
+
* otherwise switch off a feature the server opted into. Raise
|
|
1007
|
+
* `streamKeepalive.logLevel` if the level it uses matters to you.
|
|
1008
|
+
*
|
|
943
1009
|
* @returns a function that stops the keepalive.
|
|
944
1010
|
*/
|
|
945
1011
|
#startStreamKeepalive(extra, toolName) {
|
|
@@ -1622,6 +1688,17 @@ function parseBasicAuthHeader(authHeader) {
|
|
|
1622
1688
|
return null;
|
|
1623
1689
|
}
|
|
1624
1690
|
}
|
|
1691
|
+
function protectedResourceMetadataUrl(resource) {
|
|
1692
|
+
let url;
|
|
1693
|
+
try {
|
|
1694
|
+
url = new URL(resource);
|
|
1695
|
+
} catch {
|
|
1696
|
+
return `${resource}/.well-known/oauth-protected-resource`;
|
|
1697
|
+
}
|
|
1698
|
+
const path = url.pathname === "/" ? "" : url.pathname;
|
|
1699
|
+
url.pathname = `/.well-known/oauth-protected-resource${path}`;
|
|
1700
|
+
return url.toString();
|
|
1701
|
+
}
|
|
1625
1702
|
var OAUTH_PROXY_MAX_BODY_SIZE = 1024 * 1024;
|
|
1626
1703
|
var OAUTH_CREDENTIAL_RESPONSE_HEADERS = {
|
|
1627
1704
|
"Cache-Control": "no-store",
|
|
@@ -1664,10 +1741,9 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1664
1741
|
this.#authenticate = options.authenticate;
|
|
1665
1742
|
}
|
|
1666
1743
|
if (!options.oauth) {
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
};
|
|
1744
|
+
const oauth = options.auth.getOAuthConfig();
|
|
1745
|
+
this.#providerResourceBase = oauth.protectedResource.resource;
|
|
1746
|
+
this.#options = { ...options, oauth };
|
|
1671
1747
|
}
|
|
1672
1748
|
} else {
|
|
1673
1749
|
this.#authenticate = options.authenticate;
|
|
@@ -1685,6 +1761,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1685
1761
|
#logger;
|
|
1686
1762
|
#options;
|
|
1687
1763
|
#prompts = [];
|
|
1764
|
+
/** The auth provider's base URL, when it supplied the OAuth config. */
|
|
1765
|
+
#providerResourceBase;
|
|
1688
1766
|
#resources = [];
|
|
1689
1767
|
#resourcesTemplates = [];
|
|
1690
1768
|
#serverState = "stopped" /* Stopped */;
|
|
@@ -2111,6 +2189,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2111
2189
|
httpConfig.basePath,
|
|
2112
2190
|
httpConfig.endpoint
|
|
2113
2191
|
);
|
|
2192
|
+
this.#useEndpointAsResource(httpConfig.endpoint);
|
|
2114
2193
|
if (httpConfig.stateless) {
|
|
2115
2194
|
this.#logger.info(
|
|
2116
2195
|
`[FastMCP info] Starting server in stateless mode on HTTP Stream at ${protocol}://${httpConfig.host}:${httpConfig.port}${streamEndpoint}`
|
|
@@ -2279,7 +2358,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2279
2358
|
];
|
|
2280
2359
|
if (resource) {
|
|
2281
2360
|
wwwAuthenticateParts.push(
|
|
2282
|
-
`resource_metadata="${resource}
|
|
2361
|
+
`resource_metadata="${protectedResourceMetadataUrl(resource)}"`
|
|
2283
2362
|
);
|
|
2284
2363
|
}
|
|
2285
2364
|
return new Response(
|
|
@@ -2930,6 +3009,28 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2930
3009
|
session.toolsListChanged(tools);
|
|
2931
3010
|
}
|
|
2932
3011
|
}
|
|
3012
|
+
/**
|
|
3013
|
+
* RFC 9728: the protected resource is the MCP endpoint clients connect to,
|
|
3014
|
+
* and the metadata served at `/.well-known/oauth-protected-resource<endpoint>`
|
|
3015
|
+
* must name it. An auth provider only knows its base URL, so the endpoint is
|
|
3016
|
+
* appended once the server knows it. An explicit `oauth` config is left as
|
|
3017
|
+
* it is.
|
|
3018
|
+
*/
|
|
3019
|
+
#useEndpointAsResource(endpoint) {
|
|
3020
|
+
const oauth = this.#options.oauth;
|
|
3021
|
+
if (this.#providerResourceBase === void 0 || !oauth?.protectedResource)
|
|
3022
|
+
return;
|
|
3023
|
+
this.#options = {
|
|
3024
|
+
...this.#options,
|
|
3025
|
+
oauth: {
|
|
3026
|
+
...oauth,
|
|
3027
|
+
protectedResource: {
|
|
3028
|
+
...oauth.protectedResource,
|
|
3029
|
+
resource: `${this.#providerResourceBase.replace(/\/+$/, "")}${normalizePath(endpoint)}`
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
};
|
|
3033
|
+
}
|
|
2933
3034
|
};
|
|
2934
3035
|
|
|
2935
3036
|
export {
|
|
@@ -2946,4 +3047,4 @@ export {
|
|
|
2946
3047
|
FastMCPSession,
|
|
2947
3048
|
FastMCP
|
|
2948
3049
|
};
|
|
2949
|
-
//# sourceMappingURL=chunk-
|
|
3050
|
+
//# sourceMappingURL=chunk-43N2Q6ZI.js.map
|