fastmcp 4.23.9 → 4.23.11

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.
@@ -985,7 +985,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
985
985
  };
986
986
  }
987
987
  /**
988
- * Fetches the client's roots if it advertised `roots.listChanged`.
988
+ * Fetches the client's roots if it advertised the `roots` capability.
989
989
  *
990
990
  * Over Streamable HTTP a server-initiated request travels on the client's
991
991
  * standalone GET stream, which the client opens only after initialization,
@@ -993,7 +993,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
993
993
  * is bounded and retried, and the result is announced with `rootsChanged`.
994
994
  */
995
995
  async #loadRoots(streamableHttp) {
996
- if (this.#rootsConfig?.enabled === false || !this.#clientCapabilities?.roots?.listChanged || typeof this.#server.listRoots !== "function") {
996
+ if (this.#rootsConfig?.enabled === false || !this.#clientCapabilities?.roots || typeof this.#server.listRoots !== "function") {
997
997
  return;
998
998
  }
999
999
  const maxAttempts = streamableHttp ? 5 : 1;
@@ -1451,7 +1451,6 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1451
1451
  if (!match) {
1452
1452
  continue;
1453
1453
  }
1454
- const uri = uriTemplate.fill(match);
1455
1454
  const result = await resourceTemplate.load(
1456
1455
  match,
1457
1456
  this.#auth,
@@ -1468,7 +1467,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1468
1467
  description: resourceTemplate.description,
1469
1468
  mimeType: resource2.mimeType ?? resourceTemplate.mimeType,
1470
1469
  name: resourceTemplate.name,
1471
- uri: resource2.uri ?? uri
1470
+ // The URI asked for. Refilling the template from `match` can
1471
+ // spell it differently: `{path}` refills `a,b` as `a%2Cb`.
1472
+ uri: resource2.uri ?? request.params.uri
1472
1473
  }))
1473
1474
  };
1474
1475
  }
@@ -1879,6 +1880,19 @@ function matchUriTemplate(template, uri) {
1879
1880
  if (!match) {
1880
1881
  return void 0;
1881
1882
  }
1883
+ const scalarNames = new Set(template.varNames);
1884
+ for (const [expression] of template.template.matchAll(/\{[^}]*\}/g)) {
1885
+ if (/^\{[?&]/.test(expression) || expression.includes("*")) {
1886
+ for (const name of parseURITemplate(expression).varNames) {
1887
+ scalarNames.delete(name);
1888
+ }
1889
+ }
1890
+ }
1891
+ for (const [name, value] of Object.entries(match)) {
1892
+ if (scalarNames.has(name) && Array.isArray(value)) {
1893
+ match[name] = value.join(",");
1894
+ }
1895
+ }
1882
1896
  const checksQuery = !/\{[?&]/.test(template.template);
1883
1897
  const checksFragment = !template.template.includes("{#");
1884
1898
  const shape = (value) => [
@@ -3341,4 +3355,4 @@ export {
3341
3355
  FastMCPSession,
3342
3356
  FastMCP
3343
3357
  };
3344
- //# sourceMappingURL=chunk-75ZLE5AS.js.map
3358
+ //# sourceMappingURL=chunk-XUUJOVC7.js.map