fastmcp 4.30.2 → 4.30.3

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.
Files changed (39) hide show
  1. package/dist/FastMCP.cjs +4 -4
  2. package/dist/FastMCP.d.cts +2 -2
  3. package/dist/FastMCP.d.ts +2 -2
  4. package/dist/FastMCP.js +3 -3
  5. package/dist/{OAuthProvider-C2Z93xC5.d.cts → OAuthProvider-BuBMMpsX.d.cts} +18 -2
  6. package/dist/{OAuthProvider-C2Z93xC5.d.ts → OAuthProvider-BuBMMpsX.d.ts} +18 -2
  7. package/dist/auth/index.cjs +2 -2
  8. package/dist/auth/index.d.cts +2 -2
  9. package/dist/auth/index.d.ts +2 -2
  10. package/dist/auth/index.js +1 -1
  11. package/dist/{chunk-CZGQ2WTQ.cjs → chunk-F7XD3S4L.cjs} +54 -7
  12. package/dist/chunk-F7XD3S4L.cjs.map +1 -0
  13. package/dist/{chunk-LTBNX7PX.cjs → chunk-M3SNOHIM.cjs} +56 -13
  14. package/dist/chunk-M3SNOHIM.cjs.map +1 -0
  15. package/dist/{chunk-FBDPX4H2.cjs → chunk-NYV5TK43.cjs} +125 -2
  16. package/dist/chunk-NYV5TK43.cjs.map +1 -0
  17. package/dist/{chunk-XPTUOWUT.js → chunk-P4ZFER5I.js} +50 -3
  18. package/dist/chunk-P4ZFER5I.js.map +1 -0
  19. package/dist/{chunk-3JQE5IXF.js → chunk-UEEX3RD5.js} +51 -8
  20. package/dist/chunk-UEEX3RD5.js.map +1 -0
  21. package/dist/{chunk-JCKJRUCE.js → chunk-YEXAT4PO.js} +125 -2
  22. package/dist/chunk-YEXAT4PO.js.map +1 -0
  23. package/dist/edge/index.cjs +4 -4
  24. package/dist/edge/index.js +1 -1
  25. package/dist/examples/custom-routes.cjs +4 -4
  26. package/dist/examples/custom-routes.js +3 -3
  27. package/dist/openapi/index.cjs +13 -10
  28. package/dist/openapi/index.cjs.map +1 -1
  29. package/dist/openapi/index.d.cts +4 -3
  30. package/dist/openapi/index.d.ts +4 -3
  31. package/dist/openapi/index.js +7 -4
  32. package/dist/openapi/index.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-3JQE5IXF.js.map +0 -1
  35. package/dist/chunk-CZGQ2WTQ.cjs.map +0 -1
  36. package/dist/chunk-FBDPX4H2.cjs.map +0 -1
  37. package/dist/chunk-JCKJRUCE.js.map +0 -1
  38. package/dist/chunk-LTBNX7PX.cjs.map +0 -1
  39. package/dist/chunk-XPTUOWUT.js.map +0 -1
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  cancelResponseBody
3
- } from "./chunk-XPTUOWUT.js";
3
+ } from "./chunk-P4ZFER5I.js";
4
4
  import {
5
5
  objectRootSchema,
6
6
  strictInputSchema,
7
- zodInputSchema
8
- } from "./chunk-JCKJRUCE.js";
7
+ zodInputSchema,
8
+ zodOutputSchema
9
+ } from "./chunk-YEXAT4PO.js";
9
10
 
10
11
  // src/FastMCP.ts
11
12
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -1707,7 +1708,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1707
1708
  if (tool.outputSchema) {
1708
1709
  try {
1709
1710
  outputSchema = objectRootSchema(
1710
- await toJsonSchema(tool.outputSchema)
1711
+ tool.outputSchema["~standard"].vendor === "zod" && "_zod" in tool.outputSchema ? zodOutputSchema(tool.outputSchema, "draft-7") : await toJsonSchema(tool.outputSchema)
1711
1712
  );
1712
1713
  } catch (error) {
1713
1714
  this.#logger.warn(
@@ -2292,6 +2293,12 @@ var FastMCP = class extends FastMCPEventEmitter {
2292
2293
  #resources = [];
2293
2294
  #resourcesTemplates = [];
2294
2295
  #serverState = "stopped" /* Stopped */;
2296
+ /**
2297
+ * What each session was built from, until it is listed in `#sessions`. Only
2298
+ * listed sessions hear about a registration, so one made while a session is
2299
+ * still connecting is passed on when it is listed.
2300
+ */
2301
+ #sessionRegistrations = /* @__PURE__ */ new WeakMap();
2295
2302
  #sessions = [];
2296
2303
  #stdioSessions = /* @__PURE__ */ new Set();
2297
2304
  #tools = [];
@@ -2645,6 +2652,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2645
2652
  version: this.#options.version,
2646
2653
  websiteUrl: this.#options.websiteUrl
2647
2654
  });
2655
+ this.#sessionRegistrations.set(session, this.#registrations());
2648
2656
  let stdinClosed = false;
2649
2657
  const onStdinClose = () => {
2650
2658
  if (stdinClosed) return;
@@ -2779,7 +2787,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2779
2787
  });
2780
2788
  },
2781
2789
  onConnect: async (session) => {
2782
- this.#sessions.push(session);
2790
+ this.#addSession(session);
2783
2791
  this.#logger.info(`[FastMCP info] HTTP Stream session established`);
2784
2792
  this.emit("connect", {
2785
2793
  session
@@ -2827,6 +2835,31 @@ var FastMCP = class extends FastMCPEventEmitter {
2827
2835
  }
2828
2836
  this.#serverState = "stopped" /* Stopped */;
2829
2837
  }
2838
+ /**
2839
+ * Lists a connected session in `sessions`, first passing on whatever was
2840
+ * registered or removed since it was built.
2841
+ */
2842
+ #addSession(session) {
2843
+ this.#sessions.push(session);
2844
+ const built = this.#sessionRegistrations.get(session);
2845
+ const current = this.#registrations();
2846
+ this.#sessionRegistrations.delete(session);
2847
+ if (!built) {
2848
+ return;
2849
+ }
2850
+ if (built.tools !== current.tools) {
2851
+ session.toolsListChanged(current.tools);
2852
+ }
2853
+ if (built.resources !== current.resources) {
2854
+ session.resourcesListChanged(current.resources);
2855
+ }
2856
+ if (built.resourcesTemplates !== current.resourcesTemplates) {
2857
+ session.resourceTemplatesListChanged(current.resourcesTemplates);
2858
+ }
2859
+ if (built.prompts !== current.prompts) {
2860
+ session.promptsListChanged(current.prompts);
2861
+ }
2862
+ }
2830
2863
  /**
2831
2864
  * mcp-proxy's `beforeDispatch`: answers a `tools/call` the session's token
2832
2865
  * lacks scopes for with MCP's 403 scope challenge. It runs for every message
@@ -2862,7 +2895,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2862
2895
  if (closed) {
2863
2896
  return;
2864
2897
  }
2865
- this.#sessions.push(session);
2898
+ this.#addSession(session);
2866
2899
  session.once("error", () => {
2867
2900
  this.#removeSession(session);
2868
2901
  });
@@ -2928,7 +2961,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2928
2961
  throw this.#createUnauthorizedResponse(errorMessage);
2929
2962
  }
2930
2963
  const authRequired = this.#authenticate !== void 0;
2931
- return new FastMCPSession({
2964
+ const session = new FastMCPSession({
2932
2965
  auth,
2933
2966
  authRequired,
2934
2967
  enableJsonResponse,
@@ -2953,6 +2986,8 @@ var FastMCP = class extends FastMCPEventEmitter {
2953
2986
  version: this.#options.version,
2954
2987
  websiteUrl: this.#options.websiteUrl
2955
2988
  });
2989
+ this.#sessionRegistrations.set(session, this.#registrations());
2990
+ return session;
2956
2991
  }
2957
2992
  /**
2958
2993
  * Builds a 401 Unauthorized HTTP Response for authentication failures.
@@ -3635,6 +3670,14 @@ var FastMCP = class extends FastMCPEventEmitter {
3635
3670
  session.promptsListChanged(prompts);
3636
3671
  }
3637
3672
  }
3673
+ #registrations() {
3674
+ return {
3675
+ prompts: this.#prompts,
3676
+ resources: this.#resources,
3677
+ resourcesTemplates: this.#resourcesTemplates,
3678
+ tools: this.#tools
3679
+ };
3680
+ }
3638
3681
  #removeSession(session) {
3639
3682
  const sessionIndex = this.#sessions.indexOf(session);
3640
3683
  if (sessionIndex !== -1) {
@@ -3727,4 +3770,4 @@ export {
3727
3770
  FastMCPSession,
3728
3771
  FastMCP
3729
3772
  };
3730
- //# sourceMappingURL=chunk-3JQE5IXF.js.map
3773
+ //# sourceMappingURL=chunk-UEEX3RD5.js.map