@prefecthq/fastmcp-ts 1.7.0 → 1.7.2

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/client.js CHANGED
@@ -801,6 +801,21 @@ function buildHttpOptions(auth, extraHeaders = {}) {
801
801
  eventSourceInit: { headers: staticHeaders }
802
802
  };
803
803
  }
804
+ var STDIO_HINT = `To run a local server script over stdio, pass an explicit StdioTransport (e.g. new StdioTransport('node', ['server.js'])) or an mcpServers entry with a "command" key.`;
805
+ function parseHttpUrl(input) {
806
+ if (!URL.canParse(input)) {
807
+ throw new Error(
808
+ `"${input}" is not a valid URL. URL strings must be http: or https:. ${STDIO_HINT}`
809
+ );
810
+ }
811
+ const url = new URL(input);
812
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
813
+ throw new Error(
814
+ `"${input}" has unsupported scheme "${url.protocol}". URL strings must be http: or https:. ${STDIO_HINT}`
815
+ );
816
+ }
817
+ return url;
818
+ }
804
819
  var sseDeprecationWarned = false;
805
820
  function urlToTransport(url, auth, extraHeaders = {}, legacySSE = false) {
806
821
  const { requestInit, fetch: customFetch, eventSourceInit, authProvider } = buildHttpOptions(auth, extraHeaders);
@@ -844,6 +859,11 @@ function modernFetchTransport(entry) {
844
859
  });
845
860
  }
846
861
  async function resolveEntryTransport(entry, auth, options) {
862
+ if (typeof entry !== "object" || entry === null) {
863
+ throw new Error(
864
+ `mcpServers entry ${JSON.stringify(entry)} must be an object with a "url" or "command" key. ${STDIO_HINT}`
865
+ );
866
+ }
847
867
  if (isMcpServerLike(entry)) {
848
868
  if (isPinnedModern(options?.versionNegotiation) && entry._modernFetch) {
849
869
  return { transport: modernFetchTransport(entry) };
@@ -856,7 +876,7 @@ async function resolveEntryTransport(entry, auth, options) {
856
876
  }
857
877
  const entryAuth = resolveEntryAuth(entry.auth) ?? auth;
858
878
  if ("url" in entry) {
859
- const url = new URL(entry.url);
879
+ const url = parseHttpUrl(entry.url);
860
880
  const extraHeaders = entry.headers ?? {};
861
881
  return { transport: urlToTransport(url, entryAuth, extraHeaders, options?.legacySSE) };
862
882
  }
@@ -886,7 +906,7 @@ async function resolveTransport(input, auth, options) {
886
906
  };
887
907
  }
888
908
  if (typeof input === "string") {
889
- const url = new URL(input);
909
+ const url = parseHttpUrl(input);
890
910
  return { transport: urlToTransport(url, auth, {}, options?.legacySSE) };
891
911
  }
892
912
  if (typeof input === "object" && input !== null && "start" in input && typeof input.start === "function") {
@@ -941,7 +961,7 @@ function buildClientCapabilities(supplied, inferred) {
941
961
  // package.json
942
962
  var package_default = {
943
963
  name: "@prefecthq/fastmcp-ts",
944
- version: "1.7.0",
964
+ version: "1.7.2",
945
965
  description: "\u{1F3CE}\uFE0F The official FastMCP TypeScript library - build MCP servers and clients, fast \u{1F3CE}\uFE0F",
946
966
  type: "module",
947
967
  exports: {