fastmcp 4.19.1 → 4.20.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/dist/FastMCP.cjs CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
 
13
13
 
14
- var _chunkKGXPEC7Jcjs = require('./chunk-KGXPEC7J.cjs');
14
+ var _chunkTMDXVX4Lcjs = require('./chunk-TMDXVX4L.cjs');
15
15
 
16
16
 
17
17
 
@@ -49,5 +49,5 @@ var _chunkYO76IUZ6cjs = require('./chunk-YO76IUZ6.cjs');
49
49
 
50
50
 
51
51
 
52
- exports.AuthProvider = _chunkYO76IUZ6cjs.AuthProvider; exports.AzureProvider = _chunkYO76IUZ6cjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkKGXPEC7Jcjs.DiscoveryDocumentCache; exports.FastMCP = _chunkKGXPEC7Jcjs.FastMCP; exports.FastMCPError = _chunkKGXPEC7Jcjs.FastMCPError; exports.FastMCPSession = _chunkKGXPEC7Jcjs.FastMCPSession; exports.GitHubProvider = _chunkYO76IUZ6cjs.GitHubProvider; exports.GoogleProvider = _chunkYO76IUZ6cjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkKGXPEC7Jcjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkYO76IUZ6cjs.OAuthProvider; exports.ServerState = _chunkKGXPEC7Jcjs.ServerState; exports.SessionError = _chunkKGXPEC7Jcjs.SessionError; exports.UnexpectedStateError = _chunkKGXPEC7Jcjs.UnexpectedStateError; exports.UserError = _chunkKGXPEC7Jcjs.UserError; exports.audioContent = _chunkKGXPEC7Jcjs.audioContent; exports.getAuthSession = _chunkYO76IUZ6cjs.getAuthSession; exports.imageContent = _chunkKGXPEC7Jcjs.imageContent; exports.jsonSchemaAdapter = _chunkKGXPEC7Jcjs.jsonSchemaAdapter; exports.requireAll = _chunkYO76IUZ6cjs.requireAll; exports.requireAny = _chunkYO76IUZ6cjs.requireAny; exports.requireAuth = _chunkYO76IUZ6cjs.requireAuth; exports.requireRole = _chunkYO76IUZ6cjs.requireRole; exports.requireScopes = _chunkYO76IUZ6cjs.requireScopes;
52
+ exports.AuthProvider = _chunkYO76IUZ6cjs.AuthProvider; exports.AzureProvider = _chunkYO76IUZ6cjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkTMDXVX4Lcjs.DiscoveryDocumentCache; exports.FastMCP = _chunkTMDXVX4Lcjs.FastMCP; exports.FastMCPError = _chunkTMDXVX4Lcjs.FastMCPError; exports.FastMCPSession = _chunkTMDXVX4Lcjs.FastMCPSession; exports.GitHubProvider = _chunkYO76IUZ6cjs.GitHubProvider; exports.GoogleProvider = _chunkYO76IUZ6cjs.GoogleProvider; exports.MEDIA_FETCH_TIMEOUT_MS = _chunkTMDXVX4Lcjs.MEDIA_FETCH_TIMEOUT_MS; exports.OAuthProvider = _chunkYO76IUZ6cjs.OAuthProvider; exports.ServerState = _chunkTMDXVX4Lcjs.ServerState; exports.SessionError = _chunkTMDXVX4Lcjs.SessionError; exports.UnexpectedStateError = _chunkTMDXVX4Lcjs.UnexpectedStateError; exports.UserError = _chunkTMDXVX4Lcjs.UserError; exports.audioContent = _chunkTMDXVX4Lcjs.audioContent; exports.getAuthSession = _chunkYO76IUZ6cjs.getAuthSession; exports.imageContent = _chunkTMDXVX4Lcjs.imageContent; exports.jsonSchemaAdapter = _chunkTMDXVX4Lcjs.jsonSchemaAdapter; exports.requireAll = _chunkYO76IUZ6cjs.requireAll; exports.requireAny = _chunkYO76IUZ6cjs.requireAny; exports.requireAuth = _chunkYO76IUZ6cjs.requireAuth; exports.requireRole = _chunkYO76IUZ6cjs.requireRole; exports.requireScopes = _chunkYO76IUZ6cjs.requireScopes;
53
53
  //# sourceMappingURL=FastMCP.cjs.map
package/dist/FastMCP.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  audioContent,
12
12
  imageContent,
13
13
  jsonSchemaAdapter
14
- } from "./chunk-XJWV6G5Q.js";
14
+ } from "./chunk-RGV6FTGL.js";
15
15
  import {
16
16
  AuthProvider,
17
17
  AzureProvider,
@@ -2097,13 +2097,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2097
2097
  enableJsonResponse: httpConfig.enableJsonResponse,
2098
2098
  eventStore: httpConfig.eventStore,
2099
2099
  host: httpConfig.host,
2100
- ...this.#options.oauth?.enabled && this.#options.oauth.protectedResource?.resource ? {
2101
- oauth: {
2102
- protectedResource: {
2103
- resource: this.#options.oauth.protectedResource.resource
2104
- }
2105
- }
2106
- } : {},
2100
+ ...this.#httpStreamOAuthConfig(),
2107
2101
  // In stateless mode, we don't track sessions
2108
2102
  onClose: async () => {
2109
2103
  },
@@ -2145,13 +2139,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2145
2139
  enableJsonResponse: httpConfig.enableJsonResponse,
2146
2140
  eventStore: httpConfig.eventStore,
2147
2141
  host: httpConfig.host,
2148
- ...this.#options.oauth?.enabled && this.#options.oauth.protectedResource?.resource ? {
2149
- oauth: {
2150
- protectedResource: {
2151
- resource: this.#options.oauth.protectedResource.resource
2152
- }
2153
- }
2154
- } : {},
2142
+ ...this.#httpStreamOAuthConfig(),
2155
2143
  onClose: async (session) => {
2156
2144
  const sessionIndex = this.#sessions.indexOf(session);
2157
2145
  if (sessionIndex !== -1) this.#sessions.splice(sessionIndex, 1);
@@ -2690,6 +2678,28 @@ var FastMCP = class extends FastMCPEventEmitter {
2690
2678
  }
2691
2679
  }
2692
2680
  };
2681
+ /**
2682
+ * mcp-proxy only emits `WWW-Authenticate` on 401 when `oauth` is set.
2683
+ * Custom `authenticate()` still needs that challenge with no OAuth metadata
2684
+ * configured (RFC 7235). Pass an empty oauth object in that case so the
2685
+ * header is present without advertising a resource_metadata URL that 404s.
2686
+ */
2687
+ #httpStreamOAuthConfig() {
2688
+ const resource = this.#options.oauth?.enabled ? this.#options.oauth.protectedResource?.resource : void 0;
2689
+ if (resource) {
2690
+ return {
2691
+ oauth: {
2692
+ protectedResource: {
2693
+ resource
2694
+ }
2695
+ }
2696
+ };
2697
+ }
2698
+ if (this.#authenticate) {
2699
+ return { oauth: {} };
2700
+ }
2701
+ return {};
2702
+ }
2693
2703
  /**
2694
2704
  * On `httpStream`, `authenticate` is handed to both mcp-proxy (which calls it
2695
2705
  * once per request to gate the 401) and this server's own `createServer`
@@ -2892,4 +2902,4 @@ export {
2892
2902
  FastMCPSession,
2893
2903
  FastMCP
2894
2904
  };
2895
- //# sourceMappingURL=chunk-XJWV6G5Q.js.map
2905
+ //# sourceMappingURL=chunk-RGV6FTGL.js.map