fastmcp 3.34.0 → 4.0.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/dist/FastMCP.cjs CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkXH5LGNWHcjs = require('./chunk-XH5LGNWH.cjs');
10
+ var _chunkJP7QSER3cjs = require('./chunk-JP7QSER3.cjs');
11
11
 
12
12
 
13
13
 
@@ -20,7 +20,7 @@ var _chunkXH5LGNWHcjs = require('./chunk-XH5LGNWH.cjs');
20
20
 
21
21
 
22
22
 
23
- var _chunk7UDY4VFQcjs = require('./chunk-7UDY4VFQ.cjs');
23
+ var _chunkSSVFQCSNcjs = require('./chunk-SSVFQCSN.cjs');
24
24
 
25
25
 
26
26
 
@@ -41,5 +41,5 @@ var _chunk7UDY4VFQcjs = require('./chunk-7UDY4VFQ.cjs');
41
41
 
42
42
 
43
43
 
44
- exports.AuthProvider = _chunk7UDY4VFQcjs.AuthProvider; exports.AzureProvider = _chunk7UDY4VFQcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkXH5LGNWHcjs.DiscoveryDocumentCache; exports.FastMCP = _chunkXH5LGNWHcjs.FastMCP; exports.FastMCPSession = _chunkXH5LGNWHcjs.FastMCPSession; exports.GitHubProvider = _chunk7UDY4VFQcjs.GitHubProvider; exports.GoogleProvider = _chunk7UDY4VFQcjs.GoogleProvider; exports.OAuthProvider = _chunk7UDY4VFQcjs.OAuthProvider; exports.ServerState = _chunkXH5LGNWHcjs.ServerState; exports.UnexpectedStateError = _chunkXH5LGNWHcjs.UnexpectedStateError; exports.UserError = _chunkXH5LGNWHcjs.UserError; exports.audioContent = _chunkXH5LGNWHcjs.audioContent; exports.getAuthSession = _chunk7UDY4VFQcjs.getAuthSession; exports.imageContent = _chunkXH5LGNWHcjs.imageContent; exports.requireAll = _chunk7UDY4VFQcjs.requireAll; exports.requireAny = _chunk7UDY4VFQcjs.requireAny; exports.requireAuth = _chunk7UDY4VFQcjs.requireAuth; exports.requireRole = _chunk7UDY4VFQcjs.requireRole; exports.requireScopes = _chunk7UDY4VFQcjs.requireScopes;
44
+ exports.AuthProvider = _chunkSSVFQCSNcjs.AuthProvider; exports.AzureProvider = _chunkSSVFQCSNcjs.AzureProvider; exports.DiscoveryDocumentCache = _chunkJP7QSER3cjs.DiscoveryDocumentCache; exports.FastMCP = _chunkJP7QSER3cjs.FastMCP; exports.FastMCPSession = _chunkJP7QSER3cjs.FastMCPSession; exports.GitHubProvider = _chunkSSVFQCSNcjs.GitHubProvider; exports.GoogleProvider = _chunkSSVFQCSNcjs.GoogleProvider; exports.OAuthProvider = _chunkSSVFQCSNcjs.OAuthProvider; exports.ServerState = _chunkJP7QSER3cjs.ServerState; exports.UnexpectedStateError = _chunkJP7QSER3cjs.UnexpectedStateError; exports.UserError = _chunkJP7QSER3cjs.UserError; exports.audioContent = _chunkJP7QSER3cjs.audioContent; exports.getAuthSession = _chunkSSVFQCSNcjs.getAuthSession; exports.imageContent = _chunkJP7QSER3cjs.imageContent; exports.requireAll = _chunkSSVFQCSNcjs.requireAll; exports.requireAny = _chunkSSVFQCSNcjs.requireAny; exports.requireAuth = _chunkSSVFQCSNcjs.requireAuth; exports.requireRole = _chunkSSVFQCSNcjs.requireRole; exports.requireScopes = _chunkSSVFQCSNcjs.requireScopes;
45
45
  //# sourceMappingURL=FastMCP.cjs.map
@@ -10,8 +10,8 @@ import { Hono } from 'hono';
10
10
  import http from 'http';
11
11
  import { StrictEventEmitter } from 'strict-event-emitter-types';
12
12
  import { z } from 'zod';
13
- import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-R8buLRa8.cjs';
14
- 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-R8buLRa8.cjs';
13
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-BV6EpF_k.cjs';
14
+ 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-BV6EpF_k.cjs';
15
15
  import 'node:http';
16
16
 
17
17
  declare class DiscoveryDocumentCache {
@@ -534,6 +534,14 @@ type ServerOptions<T extends FastMCPSessionAuth> = {
534
534
  */
535
535
  proxy?: OAuthProxy;
536
536
  };
537
+ /**
538
+ * Callback invoked when a tool is called.
539
+ * Use this to log, audit, or track tool usage.
540
+ */
541
+ onToolCall?: (context: {
542
+ arguments: Record<string, unknown>;
543
+ toolName: string;
544
+ }) => Promise<void> | void;
537
545
  ping?: {
538
546
  /**
539
547
  * Whether ping should be enabled by default.
@@ -698,11 +706,12 @@ declare class FastMCPSession<T extends FastMCPSessionAuth = FastMCPSessionAuth>
698
706
  get server(): Server;
699
707
  get sessionId(): string | undefined;
700
708
  set sessionId(value: string | undefined);
701
- constructor({ auth, instructions, logger, name, ping, prompts, resources, resourcesTemplates, roots, sessionId, tools, transportType, utils, version, }: {
709
+ constructor({ auth, instructions, logger, name, onToolCall, ping, prompts, resources, resourcesTemplates, roots, sessionId, tools, transportType, utils, version, }: {
702
710
  auth?: T;
703
711
  instructions?: string;
704
712
  logger: Logger;
705
713
  name: string;
714
+ onToolCall?: ServerOptions<T>["onToolCall"];
706
715
  ping?: ServerOptions<T>["ping"];
707
716
  prompts: Prompt<T>[];
708
717
  resources: Resource<T>[];
package/dist/FastMCP.d.ts CHANGED
@@ -10,8 +10,8 @@ import { Hono } from 'hono';
10
10
  import http from 'http';
11
11
  import { StrictEventEmitter } from 'strict-event-emitter-types';
12
12
  import { z } from 'zod';
13
- import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-R8buLRa8.js';
14
- 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-R8buLRa8.js';
13
+ import { A as AuthProvider, O as OAuthSession, a as OAuthProxy } from './OAuthProvider-BV6EpF_k.js';
14
+ 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-BV6EpF_k.js';
15
15
  import 'node:http';
16
16
 
17
17
  declare class DiscoveryDocumentCache {
@@ -534,6 +534,14 @@ type ServerOptions<T extends FastMCPSessionAuth> = {
534
534
  */
535
535
  proxy?: OAuthProxy;
536
536
  };
537
+ /**
538
+ * Callback invoked when a tool is called.
539
+ * Use this to log, audit, or track tool usage.
540
+ */
541
+ onToolCall?: (context: {
542
+ arguments: Record<string, unknown>;
543
+ toolName: string;
544
+ }) => Promise<void> | void;
537
545
  ping?: {
538
546
  /**
539
547
  * Whether ping should be enabled by default.
@@ -698,11 +706,12 @@ declare class FastMCPSession<T extends FastMCPSessionAuth = FastMCPSessionAuth>
698
706
  get server(): Server;
699
707
  get sessionId(): string | undefined;
700
708
  set sessionId(value: string | undefined);
701
- constructor({ auth, instructions, logger, name, ping, prompts, resources, resourcesTemplates, roots, sessionId, tools, transportType, utils, version, }: {
709
+ constructor({ auth, instructions, logger, name, onToolCall, ping, prompts, resources, resourcesTemplates, roots, sessionId, tools, transportType, utils, version, }: {
702
710
  auth?: T;
703
711
  instructions?: string;
704
712
  logger: Logger;
705
713
  name: string;
714
+ onToolCall?: ServerOptions<T>["onToolCall"];
706
715
  ping?: ServerOptions<T>["ping"];
707
716
  prompts: Prompt<T>[];
708
717
  resources: Resource<T>[];
package/dist/FastMCP.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  UserError,
8
8
  audioContent,
9
9
  imageContent
10
- } from "./chunk-DMSZ2FEE.js";
10
+ } from "./chunk-UVX47AE5.js";
11
11
  import {
12
12
  AuthProvider,
13
13
  AzureProvider,
@@ -20,7 +20,7 @@ import {
20
20
  requireAuth,
21
21
  requireRole,
22
22
  requireScopes
23
- } from "./chunk-H4VC4YTC.js";
23
+ } from "./chunk-UN72PIH2.js";
24
24
  export {
25
25
  AuthProvider,
26
26
  AzureProvider,
@@ -185,7 +185,23 @@ interface OAuthProviderConfig {
185
185
  interface OAuthProxyConfig {
186
186
  /** Access token TTL in seconds (default: 3600) */
187
187
  accessTokenTtl?: number;
188
- /** Allowed redirect URI patterns for client registration */
188
+ /**
189
+ * Allow-list of redirect URI patterns accepted by Dynamic Client Registration.
190
+ *
191
+ * A client calling POST /oauth/register must present a `redirect_uri` that
192
+ * matches one of these patterns (exact string or glob with `*` / `?`);
193
+ * otherwise the registration is rejected with `invalid_redirect_uri`. Once
194
+ * registered, the same exact URI must be echoed back at /oauth/authorize —
195
+ * the proxy performs exact string comparison per RFC 6749 §3.1.2.3.
196
+ *
197
+ * Default: `[]` (DCR rejects everything — explicit opt-in required).
198
+ *
199
+ * Prior versions defaulted to `["https://*", "http://localhost:*"]` with an
200
+ * implicit fallback that allowed any https URL. This enabled CWE-601
201
+ * open-redirect / authorization-code theft: an attacker could DCR their own
202
+ * URL and then steal victim codes via /oauth/authorize. Do not loosen this
203
+ * default without understanding that threat model.
204
+ */
189
205
  allowedRedirectUriPatterns?: string[];
190
206
  /** Authorization code TTL in seconds (default: 300) */
191
207
  authorizationCodeTtl?: number;
@@ -548,7 +564,16 @@ declare class OAuthProxy {
548
564
  */
549
565
  private startCleanup;
550
566
  /**
551
- * Validate redirect URI against allowed patterns
567
+ * Validate a redirect URI against the configured allow-list.
568
+ *
569
+ * Returns `true` only if the URI is syntactically valid AND matches one of
570
+ * the explicitly configured `allowedRedirectUriPatterns`. An empty or unset
571
+ * pattern list means DCR will reject every URI — framework users must
572
+ * opt-in by listing the exact URIs (or wildcards) they trust.
573
+ *
574
+ * Prior versions also fell back to allowing any https URL or localhost,
575
+ * which enabled attackers to DCR an arbitrary URL and then abuse it via
576
+ * /oauth/authorize (CWE-601). Do not re-introduce that fallback.
552
577
  */
553
578
  private validateRedirectUri;
554
579
  }
@@ -573,7 +598,17 @@ declare class OAuthProxyError extends Error {
573
598
  * Configuration common to all OAuth providers.
574
599
  */
575
600
  interface AuthProviderConfig {
576
- /** Allowed redirect URI patterns (default: ["http://localhost:*", "https://*"]) */
601
+ /**
602
+ * Allow-list of redirect URI patterns accepted by Dynamic Client
603
+ * Registration. Required for any deployment that exposes /oauth/register
604
+ * or /oauth/authorize — an empty/unset list rejects every URI.
605
+ *
606
+ * Example: `["https://yourapp.example.com/*"]`
607
+ *
608
+ * Prior versions defaulted to `["http://localhost:*", "https://*"]`, which
609
+ * enabled CWE-601 open-redirect / authorization-code theft. See the
610
+ * SECURITY advisory before loosening this.
611
+ */
577
612
  allowedRedirectUriPatterns?: string[];
578
613
  /** Base URL where the MCP server is accessible */
579
614
  baseUrl: string;
@@ -185,7 +185,23 @@ interface OAuthProviderConfig {
185
185
  interface OAuthProxyConfig {
186
186
  /** Access token TTL in seconds (default: 3600) */
187
187
  accessTokenTtl?: number;
188
- /** Allowed redirect URI patterns for client registration */
188
+ /**
189
+ * Allow-list of redirect URI patterns accepted by Dynamic Client Registration.
190
+ *
191
+ * A client calling POST /oauth/register must present a `redirect_uri` that
192
+ * matches one of these patterns (exact string or glob with `*` / `?`);
193
+ * otherwise the registration is rejected with `invalid_redirect_uri`. Once
194
+ * registered, the same exact URI must be echoed back at /oauth/authorize —
195
+ * the proxy performs exact string comparison per RFC 6749 §3.1.2.3.
196
+ *
197
+ * Default: `[]` (DCR rejects everything — explicit opt-in required).
198
+ *
199
+ * Prior versions defaulted to `["https://*", "http://localhost:*"]` with an
200
+ * implicit fallback that allowed any https URL. This enabled CWE-601
201
+ * open-redirect / authorization-code theft: an attacker could DCR their own
202
+ * URL and then steal victim codes via /oauth/authorize. Do not loosen this
203
+ * default without understanding that threat model.
204
+ */
189
205
  allowedRedirectUriPatterns?: string[];
190
206
  /** Authorization code TTL in seconds (default: 300) */
191
207
  authorizationCodeTtl?: number;
@@ -548,7 +564,16 @@ declare class OAuthProxy {
548
564
  */
549
565
  private startCleanup;
550
566
  /**
551
- * Validate redirect URI against allowed patterns
567
+ * Validate a redirect URI against the configured allow-list.
568
+ *
569
+ * Returns `true` only if the URI is syntactically valid AND matches one of
570
+ * the explicitly configured `allowedRedirectUriPatterns`. An empty or unset
571
+ * pattern list means DCR will reject every URI — framework users must
572
+ * opt-in by listing the exact URIs (or wildcards) they trust.
573
+ *
574
+ * Prior versions also fell back to allowing any https URL or localhost,
575
+ * which enabled attackers to DCR an arbitrary URL and then abuse it via
576
+ * /oauth/authorize (CWE-601). Do not re-introduce that fallback.
552
577
  */
553
578
  private validateRedirectUri;
554
579
  }
@@ -573,7 +598,17 @@ declare class OAuthProxyError extends Error {
573
598
  * Configuration common to all OAuth providers.
574
599
  */
575
600
  interface AuthProviderConfig {
576
- /** Allowed redirect URI patterns (default: ["http://localhost:*", "https://*"]) */
601
+ /**
602
+ * Allow-list of redirect URI patterns accepted by Dynamic Client
603
+ * Registration. Required for any deployment that exposes /oauth/register
604
+ * or /oauth/authorize — an empty/unset list rejects every URI.
605
+ *
606
+ * Example: `["https://yourapp.example.com/*"]`
607
+ *
608
+ * Prior versions defaulted to `["http://localhost:*", "https://*"]`, which
609
+ * enabled CWE-601 open-redirect / authorization-code theft. See the
610
+ * SECURITY advisory before loosening this.
611
+ */
577
612
  allowedRedirectUriPatterns?: string[];
578
613
  /** Base URL where the MCP server is accessible */
579
614
  baseUrl: string;
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- var _chunk7UDY4VFQcjs = require('../chunk-7UDY4VFQ.cjs');
27
+ var _chunkSSVFQCSNcjs = require('../chunk-SSVFQCSN.cjs');
28
28
 
29
29
 
30
30
 
@@ -51,5 +51,5 @@ var _chunk7UDY4VFQcjs = require('../chunk-7UDY4VFQ.cjs');
51
51
 
52
52
 
53
53
 
54
- exports.AuthProvider = _chunk7UDY4VFQcjs.AuthProvider; exports.AzureProvider = _chunk7UDY4VFQcjs.AzureProvider; exports.ConsentManager = _chunk7UDY4VFQcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunk7UDY4VFQcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunk7UDY4VFQcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunk7UDY4VFQcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunk7UDY4VFQcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunk7UDY4VFQcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunk7UDY4VFQcjs.DiskStore; exports.EncryptedTokenStorage = _chunk7UDY4VFQcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunk7UDY4VFQcjs.GitHubProvider; exports.GoogleProvider = _chunk7UDY4VFQcjs.GoogleProvider; exports.JWKSVerifier = _chunk7UDY4VFQcjs.JWKSVerifier; exports.JWTIssuer = _chunk7UDY4VFQcjs.JWTIssuer; exports.MemoryTokenStorage = _chunk7UDY4VFQcjs.MemoryTokenStorage; exports.OAuthProvider = _chunk7UDY4VFQcjs.OAuthProvider; exports.OAuthProxy = _chunk7UDY4VFQcjs.OAuthProxy; exports.OAuthProxyError = _chunk7UDY4VFQcjs.OAuthProxyError; exports.PKCEUtils = _chunk7UDY4VFQcjs.PKCEUtils; exports.getAuthSession = _chunk7UDY4VFQcjs.getAuthSession; exports.requireAll = _chunk7UDY4VFQcjs.requireAll; exports.requireAny = _chunk7UDY4VFQcjs.requireAny; exports.requireAuth = _chunk7UDY4VFQcjs.requireAuth; exports.requireRole = _chunk7UDY4VFQcjs.requireRole; exports.requireScopes = _chunk7UDY4VFQcjs.requireScopes;
54
+ exports.AuthProvider = _chunkSSVFQCSNcjs.AuthProvider; exports.AzureProvider = _chunkSSVFQCSNcjs.AzureProvider; exports.ConsentManager = _chunkSSVFQCSNcjs.ConsentManager; exports.DEFAULT_ACCESS_TOKEN_TTL = _chunkSSVFQCSNcjs.DEFAULT_ACCESS_TOKEN_TTL; exports.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH = _chunkSSVFQCSNcjs.DEFAULT_ACCESS_TOKEN_TTL_NO_REFRESH; exports.DEFAULT_AUTHORIZATION_CODE_TTL = _chunkSSVFQCSNcjs.DEFAULT_AUTHORIZATION_CODE_TTL; exports.DEFAULT_REFRESH_TOKEN_TTL = _chunkSSVFQCSNcjs.DEFAULT_REFRESH_TOKEN_TTL; exports.DEFAULT_TRANSACTION_TTL = _chunkSSVFQCSNcjs.DEFAULT_TRANSACTION_TTL; exports.DiskStore = _chunkSSVFQCSNcjs.DiskStore; exports.EncryptedTokenStorage = _chunkSSVFQCSNcjs.EncryptedTokenStorage; exports.GitHubProvider = _chunkSSVFQCSNcjs.GitHubProvider; exports.GoogleProvider = _chunkSSVFQCSNcjs.GoogleProvider; exports.JWKSVerifier = _chunkSSVFQCSNcjs.JWKSVerifier; exports.JWTIssuer = _chunkSSVFQCSNcjs.JWTIssuer; exports.MemoryTokenStorage = _chunkSSVFQCSNcjs.MemoryTokenStorage; exports.OAuthProvider = _chunkSSVFQCSNcjs.OAuthProvider; exports.OAuthProxy = _chunkSSVFQCSNcjs.OAuthProxy; exports.OAuthProxyError = _chunkSSVFQCSNcjs.OAuthProxyError; exports.PKCEUtils = _chunkSSVFQCSNcjs.PKCEUtils; exports.getAuthSession = _chunkSSVFQCSNcjs.getAuthSession; exports.requireAll = _chunkSSVFQCSNcjs.requireAll; exports.requireAny = _chunkSSVFQCSNcjs.requireAny; exports.requireAuth = _chunkSSVFQCSNcjs.requireAuth; exports.requireRole = _chunkSSVFQCSNcjs.requireRole; exports.requireScopes = _chunkSSVFQCSNcjs.requireScopes;
55
55
  //# sourceMappingURL=index.cjs.map
@@ -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-R8buLRa8.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-R8buLRa8.cjs';
1
+ import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-BV6EpF_k.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-BV6EpF_k.cjs';
3
3
  import 'node:http';
4
4
 
5
5
  /**
@@ -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-R8buLRa8.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-R8buLRa8.js';
1
+ import { p as OAuthTransaction, C as ConsentData, T as TokenStorage, q as TokenVerifier, s as TokenVerificationResult, P as PKCEPair } from '../OAuthProvider-BV6EpF_k.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-BV6EpF_k.js';
3
3
  import 'node:http';
4
4
 
5
5
  /**
@@ -24,7 +24,7 @@ import {
24
24
  requireAuth,
25
25
  requireRole,
26
26
  requireScopes
27
- } from "../chunk-H4VC4YTC.js";
27
+ } from "../chunk-UN72PIH2.js";
28
28
  export {
29
29
  AuthProvider,
30
30
  AzureProvider,
@@ -341,6 +341,7 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
341
341
  #logger;
342
342
  #loggingLevel = "info";
343
343
  #needsEventLoopFlush = false;
344
+ #onToolCall;
344
345
  #pingConfig;
345
346
  #pingInterval = null;
346
347
  #prompts = /* @__PURE__ */ new Map();
@@ -360,6 +361,7 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
360
361
  instructions,
361
362
  logger,
362
363
  name,
364
+ onToolCall,
363
365
  ping,
364
366
  prompts,
365
367
  resources,
@@ -374,6 +376,7 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
374
376
  super();
375
377
  this.#auth = auth;
376
378
  this.#logger = logger;
379
+ this.#onToolCall = onToolCall;
377
380
  this.#pingConfig = ping;
378
381
  this.#rootsConfig = roots;
379
382
  this.#sessionId = sessionId;
@@ -1101,6 +1104,12 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1101
1104
  );
1102
1105
  }
1103
1106
  };
1107
+ if (this.#onToolCall) {
1108
+ await this.#onToolCall({
1109
+ arguments: _nullishCoalesce(args, () => ( {})),
1110
+ toolName: request.params.name
1111
+ });
1112
+ }
1104
1113
  const executeToolPromise = tool.execute(args, {
1105
1114
  client: {
1106
1115
  version: this.#server.getClientVersion()
@@ -1508,6 +1517,7 @@ var FastMCP = class extends FastMCPEventEmitter {
1508
1517
  instructions: this.#options.instructions,
1509
1518
  logger: this.#logger,
1510
1519
  name: this.#options.name,
1520
+ onToolCall: this.#options.onToolCall,
1511
1521
  ping: this.#options.ping,
1512
1522
  prompts: this.#prompts,
1513
1523
  resources: this.#resources,
@@ -1680,6 +1690,7 @@ var FastMCP = class extends FastMCPEventEmitter {
1680
1690
  instructions: this.#options.instructions,
1681
1691
  logger: this.#logger,
1682
1692
  name: this.#options.name,
1693
+ onToolCall: this.#options.onToolCall,
1683
1694
  ping: this.#options.ping,
1684
1695
  prompts: this.#prompts,
1685
1696
  resources: this.#resources,
@@ -2096,4 +2107,4 @@ var FastMCP = class extends FastMCPEventEmitter {
2096
2107
 
2097
2108
 
2098
2109
  exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.imageContent = imageContent; exports.audioContent = audioContent; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.ServerState = ServerState; exports.FastMCPSession = FastMCPSession; exports.FastMCP = FastMCP;
2099
- //# sourceMappingURL=chunk-XH5LGNWH.cjs.map
2110
+ //# sourceMappingURL=chunk-JP7QSER3.cjs.map