fastmcp 4.21.2 → 4.22.1
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-C5VOVQPC.cjs → chunk-RN2Z26T4.cjs} +118 -16
- package/dist/chunk-RN2Z26T4.cjs.map +1 -0
- package/dist/{chunk-QMRS4ZLD.js → chunk-XFUILY54.js} +115 -13
- package/dist/chunk-XFUILY54.js.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/edge/index.cjs +15 -12
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.js +7 -4
- 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 +165 -149
- 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 +155 -139
- 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 _chunkRN2Z26T4cjs = require('./chunk-RN2Z26T4.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 = _chunkRN2Z26T4cjs.DiscoveryDocumentCache; exports.FastMCP = _chunkRN2Z26T4cjs.FastMCP; exports.FastMCPError = _chunkRN2Z26T4cjs.FastMCPError; exports.FastMCPSession = _chunkRN2Z26T4cjs.FastMCPSession; exports.GitHubProvider = _chunkYOBCXNFPcjs.GitHubProvider; exports.GoogleProvider = _chunkYOBCXNFPcjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkRN2Z26T4cjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkYOBCXNFPcjs.OAuthProvider; exports.ServerState = _chunkRN2Z26T4cjs.ServerState; exports.SessionError = _chunkRN2Z26T4cjs.SessionError; exports.UnexpectedStateError = _chunkRN2Z26T4cjs.UnexpectedStateError; exports.UserError = _chunkRN2Z26T4cjs.UserError; exports.audioContent = _chunkRN2Z26T4cjs.audioContent; exports.getAuthSession = _chunkYOBCXNFPcjs.getAuthSession; exports.imageContent = _chunkRN2Z26T4cjs.imageContent; exports.jsonSchemaAdapter = _chunkRN2Z26T4cjs.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-XFUILY54.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
|
"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 _chunkYOBCXNFPcjs = require('./chunk-YOBCXNFP.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkO22SYZMCcjs = require('./chunk-O22SYZMC.cjs');
|
|
@@ -134,7 +134,7 @@ var DiscoveryDocumentCache = class {
|
|
|
134
134
|
throw error;
|
|
135
135
|
}
|
|
136
136
|
if (!res.ok) {
|
|
137
|
-
await
|
|
137
|
+
await _chunkYOBCXNFPcjs.cancelResponseBody.call(void 0, res);
|
|
138
138
|
throw new Error(
|
|
139
139
|
`Failed to fetch discovery document from ${url}: ${res.status} ${res.statusText}`
|
|
140
140
|
);
|
|
@@ -230,7 +230,7 @@ var imageContent = async (input) => {
|
|
|
230
230
|
signal: AbortSignal.timeout(timeoutMs)
|
|
231
231
|
});
|
|
232
232
|
if (!response.ok) {
|
|
233
|
-
await
|
|
233
|
+
await _chunkYOBCXNFPcjs.cancelResponseBody.call(void 0, response);
|
|
234
234
|
throw new Error(
|
|
235
235
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
236
236
|
);
|
|
@@ -292,7 +292,7 @@ var audioContent = async (input) => {
|
|
|
292
292
|
signal: AbortSignal.timeout(timeoutMs)
|
|
293
293
|
});
|
|
294
294
|
if (!response.ok) {
|
|
295
|
-
await
|
|
295
|
+
await _chunkYOBCXNFPcjs.cancelResponseBody.call(void 0, response);
|
|
296
296
|
throw new Error(
|
|
297
297
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
298
298
|
);
|
|
@@ -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 = _events.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 _nullishCoalesce(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 = _nullishCoalesce(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) {
|
|
@@ -1258,8 +1324,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1258
1324
|
};
|
|
1259
1325
|
}
|
|
1260
1326
|
throw new (0, _typesjs.McpError)(
|
|
1261
|
-
_typesjs.ErrorCode.
|
|
1262
|
-
`Resource not found: '${request.params.uri}'. Available resources: ${Array.from(this.#resources.values()).map((r) => r.uri).join(", ") || "none"}
|
|
1327
|
+
_typesjs.ErrorCode.InvalidParams,
|
|
1328
|
+
`Resource not found: '${request.params.uri}'. Available resources: ${Array.from(this.#resources.values()).map((r) => r.uri).join(", ") || "none"}`,
|
|
1329
|
+
{ uri: request.params.uri }
|
|
1263
1330
|
);
|
|
1264
1331
|
}
|
|
1265
1332
|
if (!("uri" in resource)) {
|
|
@@ -1408,7 +1475,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1408
1475
|
const tool = toolsMap.get(request.params.name);
|
|
1409
1476
|
if (!tool) {
|
|
1410
1477
|
throw new (0, _typesjs.McpError)(
|
|
1411
|
-
_typesjs.ErrorCode.
|
|
1478
|
+
_typesjs.ErrorCode.InvalidParams,
|
|
1412
1479
|
`Unknown tool: ${request.params.name}`
|
|
1413
1480
|
);
|
|
1414
1481
|
}
|
|
@@ -1622,6 +1689,17 @@ function parseBasicAuthHeader(authHeader) {
|
|
|
1622
1689
|
return null;
|
|
1623
1690
|
}
|
|
1624
1691
|
}
|
|
1692
|
+
function protectedResourceMetadataUrl(resource) {
|
|
1693
|
+
let url;
|
|
1694
|
+
try {
|
|
1695
|
+
url = new URL(resource);
|
|
1696
|
+
} catch (e6) {
|
|
1697
|
+
return `${resource}/.well-known/oauth-protected-resource`;
|
|
1698
|
+
}
|
|
1699
|
+
const path = url.pathname === "/" ? "" : url.pathname;
|
|
1700
|
+
url.pathname = `/.well-known/oauth-protected-resource${path}`;
|
|
1701
|
+
return url.toString();
|
|
1702
|
+
}
|
|
1625
1703
|
var OAUTH_PROXY_MAX_BODY_SIZE = 1024 * 1024;
|
|
1626
1704
|
var OAUTH_CREDENTIAL_RESPONSE_HEADERS = {
|
|
1627
1705
|
"Cache-Control": "no-store",
|
|
@@ -1664,10 +1742,9 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1664
1742
|
this.#authenticate = options.authenticate;
|
|
1665
1743
|
}
|
|
1666
1744
|
if (!options.oauth) {
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
};
|
|
1745
|
+
const oauth = options.auth.getOAuthConfig();
|
|
1746
|
+
this.#providerResourceBase = oauth.protectedResource.resource;
|
|
1747
|
+
this.#options = { ...options, oauth };
|
|
1671
1748
|
}
|
|
1672
1749
|
} else {
|
|
1673
1750
|
this.#authenticate = options.authenticate;
|
|
@@ -1685,6 +1762,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1685
1762
|
#logger;
|
|
1686
1763
|
#options;
|
|
1687
1764
|
#prompts = [];
|
|
1765
|
+
/** The auth provider's base URL, when it supplied the OAuth config. */
|
|
1766
|
+
#providerResourceBase;
|
|
1688
1767
|
#resources = [];
|
|
1689
1768
|
#resourcesTemplates = [];
|
|
1690
1769
|
#serverState = "stopped" /* Stopped */;
|
|
@@ -2111,6 +2190,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2111
2190
|
httpConfig.basePath,
|
|
2112
2191
|
httpConfig.endpoint
|
|
2113
2192
|
);
|
|
2193
|
+
this.#useEndpointAsResource(httpConfig.endpoint);
|
|
2114
2194
|
if (httpConfig.stateless) {
|
|
2115
2195
|
this.#logger.info(
|
|
2116
2196
|
`[FastMCP info] Starting server in stateless mode on HTTP Stream at ${protocol}://${httpConfig.host}:${httpConfig.port}${streamEndpoint}`
|
|
@@ -2279,7 +2359,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2279
2359
|
];
|
|
2280
2360
|
if (resource) {
|
|
2281
2361
|
wwwAuthenticateParts.push(
|
|
2282
|
-
`resource_metadata="${resource}
|
|
2362
|
+
`resource_metadata="${protectedResourceMetadataUrl(resource)}"`
|
|
2283
2363
|
);
|
|
2284
2364
|
}
|
|
2285
2365
|
return new Response(
|
|
@@ -2930,6 +3010,28 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2930
3010
|
session.toolsListChanged(tools);
|
|
2931
3011
|
}
|
|
2932
3012
|
}
|
|
3013
|
+
/**
|
|
3014
|
+
* RFC 9728: the protected resource is the MCP endpoint clients connect to,
|
|
3015
|
+
* and the metadata served at `/.well-known/oauth-protected-resource<endpoint>`
|
|
3016
|
+
* must name it. An auth provider only knows its base URL, so the endpoint is
|
|
3017
|
+
* appended once the server knows it. An explicit `oauth` config is left as
|
|
3018
|
+
* it is.
|
|
3019
|
+
*/
|
|
3020
|
+
#useEndpointAsResource(endpoint) {
|
|
3021
|
+
const oauth = this.#options.oauth;
|
|
3022
|
+
if (this.#providerResourceBase === void 0 || !_optionalChain([oauth, 'optionalAccess', _96 => _96.protectedResource]))
|
|
3023
|
+
return;
|
|
3024
|
+
this.#options = {
|
|
3025
|
+
...this.#options,
|
|
3026
|
+
oauth: {
|
|
3027
|
+
...oauth,
|
|
3028
|
+
protectedResource: {
|
|
3029
|
+
...oauth.protectedResource,
|
|
3030
|
+
resource: `${this.#providerResourceBase.replace(/\/+$/, "")}${normalizePath(endpoint)}`
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
};
|
|
3034
|
+
}
|
|
2933
3035
|
};
|
|
2934
3036
|
|
|
2935
3037
|
|
|
@@ -2946,4 +3048,4 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2946
3048
|
|
|
2947
3049
|
|
|
2948
3050
|
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;
|
|
2949
|
-
//# sourceMappingURL=chunk-
|
|
3051
|
+
//# sourceMappingURL=chunk-RN2Z26T4.cjs.map
|