linkedin-relay-mcp 1.3.0 → 1.3.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/mcp-shim.js CHANGED
@@ -736,13 +736,16 @@ function classifyRedirect(location) {
736
736
  }
737
737
  return fail("FETCH_FAILED", `unexpected redirect to ${location || "(none)"}`);
738
738
  }
739
+ function challengeIn(body) {
740
+ if (!CHALLENGE_MARKERS.test(body.slice(0, 4e3))) return null;
741
+ return fail("CHALLENGE_DETECTED", "a challenge page was returned with status 200", {
742
+ cooldown: "CHALLENGE_DETECTED",
743
+ hint: CHALLENGE_HINT
744
+ });
745
+ }
739
746
  function classifyBody(body) {
740
- if (CHALLENGE_MARKERS.test(body.slice(0, 4e3))) {
741
- return fail("CHALLENGE_DETECTED", "a challenge page was returned with status 200", {
742
- cooldown: "CHALLENGE_DETECTED",
743
- hint: CHALLENGE_HINT
744
- });
745
- }
747
+ const challenge = challengeIn(body);
748
+ if (challenge !== null) return challenge;
746
749
  let json;
747
750
  try {
748
751
  json = JSON.parse(body);
@@ -765,7 +768,7 @@ function classifyBody(body) {
765
768
  }
766
769
  return { outcome: "ok", retry: false, json };
767
770
  }
768
- function classify(res) {
771
+ function classify(res, opts = {}) {
769
772
  const headers = res.headers ?? {};
770
773
  if (res.status >= 300 && res.status < 400) {
771
774
  return classifyRedirect(headers.location ?? "");
@@ -806,6 +809,15 @@ function classify(res) {
806
809
  return fail("FETCH_FAILED", `unexpected status ${res.status}`);
807
810
  }
808
811
  if (res.body.trim() === "") return { outcome: "ok", retry: false, json: null };
812
+ const challenge = challengeIn(res.body);
813
+ if (challenge !== null) return challenge;
814
+ if (opts.expectJson === false) {
815
+ try {
816
+ return { outcome: "ok", retry: false, json: JSON.parse(res.body) };
817
+ } catch {
818
+ return { outcome: "ok", retry: false, json: null };
819
+ }
820
+ }
809
821
  return classifyBody(res.body);
810
822
  }
811
823
  function referencesUrns(data) {
@@ -867,7 +879,8 @@ function createClient(session, deps) {
867
879
  if (raw === null) {
868
880
  return { ok: false, code: "FETCH_FAILED", message: "the request could not be completed" };
869
881
  }
870
- const classification = classify(raw);
882
+ const isRead = (spec.method ?? "GET") === "GET";
883
+ const classification = classify(raw, { expectJson: isRead });
871
884
  if (classification.cooldown !== void 0) {
872
885
  deps.saveCooldown(openCooldown(classification.cooldown, deps.now()));
873
886
  }