linkedin-relay-mcp 3.22.0 → 3.23.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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: linkedin-relay
3
- description: Research LinkedIn from the user's own account — find people by company, past company, school, place, title, degree or whose connections they are, search posts, companies, groups, events, courses, products, services and schools, hunt jobs with every filter LinkedIn has and collect their apply links, read profiles, read the chronological feed — and, through the lnrelay CLI, post (text, image or video), comment, reply, react, delete and edit the user's own profile (headline, About, roles, skills) under the approval mode the owner chose. Use when looking at the user's own network (connections, followers, who they follow, invitations they sent) or their saved items (saved posts, courses, the job tracker), when finding or evaluating people (who works or worked somewhere, alumni, people in a role or a city, someone's connections), companies, groups, events, courses, posts on a topic, roles or job openings on LinkedIn, when the user wants job listings or application links, when reading what the user's network is posting, when the user wants to read their LinkedIn messages or draft replies to them, or when the user asks to post, engage or update their profile on LinkedIn. Cannot send messages, connect, or apply to jobs: those do not exist.
3
+ description: Research LinkedIn from the user's own account — find people by company, past company, school, place, title, degree or whose connections they are, search posts, companies, groups, events, courses, products, services and schools, hunt jobs with every filter LinkedIn has and collect their apply links, read profiles, read the chronological feed — and, through the lnrelay CLI, post (text, image or video), comment, reply, react, delete and edit the user's own profile (headline, About, roles, skills) under the approval mode the owner chose. Use when looking at the user's own network (connections, followers, who they follow, invitations they sent, who viewed their profile) or their saved items (saved posts, courses, the job tracker), when finding or evaluating people (who works or worked somewhere, alumni, people in a role or a city, someone's connections), companies, groups, events, courses, posts on a topic, roles or job openings on LinkedIn, when the user wants job listings or application links, when reading what the user's network is posting, when the user wants to read their LinkedIn messages or draft replies to them, or when the user asks to post, engage or update their profile on LinkedIn. Cannot send messages, connect, or apply to jobs: those do not exist.
4
4
  ---
5
5
 
6
6
  # linkedin-relay
@@ -431,6 +431,19 @@ With a list, its rows, 50 a call: people (connections, following, followers) as
431
431
  does neither.
432
432
  - Not available: received invitations, newsletters, "people you may know".
433
433
 
434
+ ### `viewers` — 2 page calls. Who viewed the user's profile.
435
+ ```
436
+ viewers [compact]
437
+ ```
438
+ CLI: `lnrelay viewers [--compact]`. As the user's profile-views page shows it: `total` over
439
+ `period` (LinkedIn's words, past 90 days), `privateViewers` (private-mode viewers are a count, no
440
+ names), and `items`: named viewers as `name`, `id` (what `profile`, `messages` and `connectionOf`
441
+ take), `url`, `degree`, `headline`, `viewed` ("2d ago"); anonymous ones as `anonymous: true`,
442
+ `description` ("Founder in the Software industry from Budapest"), `viewed`, `searchUrl`.
443
+ - A free account is shown up to 3 viewers, so `meta.state` is `partial` whenever `total` is higher.
444
+ The rest is behind Premium; this does not get around that.
445
+ - Degree and times come in the session's language, which may not be English.
446
+
434
447
  ### `inbox` — 1 page call per 20 conversations. The user's messages.
435
448
  ```
436
449
  inbox [folder:inbox|primary|other|archive|requests|spam] [unread] [limit:N] [compact]
package/README.md CHANGED
@@ -47,6 +47,7 @@ claude mcp add linkedin-relay -s user -- bun "$(npm root -g)/linkedin-relay-mcp/
47
47
  | `company` | a company page in full: about, website, industry, size, employees, followers, headquarters, specialties, locations, affiliated and showcase pages — and, with `--posts N`, its newest posts |
48
48
  | `events` · `event` | the events page's recommended and Premium events, and any event in full: when, where, attendees, organiser, its site |
49
49
  | `network` | your My Network: connections, following, followers, pages, events, groups, invitations sent — or the count of each |
50
+ | `viewers` | who viewed your profile: the total, the viewers LinkedIn names (3 on a free account), anonymous ones, the private-mode count |
50
51
  | `inbox` · `messages` · `draft` · `drafts` | read your messages without marking them read; draft replies locally — nothing is ever sent |
51
52
  | `sync` · `local` · `connections` · `my-posts` | fill a local cache, then query it for free |
52
53
  | `whoami` · `doctor` · `risk` · `budget` · `cache-status` | session, standing and spend |
package/dist/cli.js CHANGED
@@ -7305,6 +7305,15 @@ var COMMANDS = [
7305
7305
  risk: "read",
7306
7306
  implemented: true
7307
7307
  },
7308
+ {
7309
+ name: "viewers",
7310
+ cost: "2 page calls",
7311
+ summary: "Who viewed your profile, as your profile-views page shows it: the total for the period, the viewers LinkedIn names (up to 3 on a free account), anonymous ones as LinkedIn describes them, and how many looked in private mode.",
7312
+ usage: "lnrelay viewers [--compact | --fields a,b,c]",
7313
+ audience: ["cli", "mcp"],
7314
+ risk: "read",
7315
+ implemented: true
7316
+ },
7308
7317
  {
7309
7318
  name: "network",
7310
7319
  cost: "1 page call per 50 rows; the counts are 7 calls",
@@ -9727,6 +9736,208 @@ async function runSync(source, limit, force, now = Date.now()) {
9727
9736
  }
9728
9737
  }
9729
9738
 
9739
+ // src/engine/profile-views.ts
9740
+ var SERVER_REQUEST = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
9741
+ var VIEWERS_URL = `${SERVER_REQUEST}?sduiid=WvmpEntityList`;
9742
+ var VIEW_TOTALS_URL = `${SERVER_REQUEST}?sduiid=WvmpAnalytics`;
9743
+ var RANGE = "WvmpSearchFilterType_DATE_RANGE";
9744
+ var META = { $type: "proto.sdui.common.RequestMetadata" };
9745
+ function serverRequest(requestId, stateKey2, payload) {
9746
+ const state = {
9747
+ key: stateKey2,
9748
+ namespace: "MemoryNamespace",
9749
+ value: [],
9750
+ originalProtoCase: "stringListValue",
9751
+ protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: stateKey2 } }
9752
+ };
9753
+ const requestedArguments = {
9754
+ $type: "proto.sdui.actions.requests.RequestedArguments",
9755
+ requestedStateKeys: [{ key: { value: { $case: "id", id: stateKey2 } } }],
9756
+ payload: {
9757
+ ...payload,
9758
+ filterTypeList: [RANGE],
9759
+ dateRangeSelectionFilters: { key: stateKey2, namespace: "MemoryNamespace" }
9760
+ },
9761
+ requestMetadata: META
9762
+ };
9763
+ return {
9764
+ requestId,
9765
+ serverRequest: {
9766
+ requestId,
9767
+ requestedArguments,
9768
+ isApfcEnabled: false,
9769
+ isStreaming: false,
9770
+ rumPageKey: ""
9771
+ },
9772
+ states: [state],
9773
+ requestedArguments: {
9774
+ ...requestedArguments,
9775
+ states: [state],
9776
+ screenId: "com.linkedin.sdui.flagshipnav.home.Home",
9777
+ knownTemplateIds: []
9778
+ }
9779
+ };
9780
+ }
9781
+ function viewersBody() {
9782
+ return serverRequest("WvmpEntityList", `entityListQueryFilterPrefix${RANGE}`, {
9783
+ sortType: "ProfileViewSortType_TIME_DESCENDING"
9784
+ });
9785
+ }
9786
+ function viewTotalsBody() {
9787
+ return serverRequest("WvmpAnalytics", `analyticsFieldsFilterPrefix${RANGE}`, {
9788
+ highlightCardDimensions: [
9789
+ "DimensionType_LOCATION",
9790
+ "DimensionType_INDUSTRY",
9791
+ "DimensionType_ORGANIZATION"
9792
+ ],
9793
+ detailsCardDimensions: ["DimensionType_ORGANIZATION"],
9794
+ highlightCardResultCount: 4,
9795
+ detailsCardResultCount: 23
9796
+ });
9797
+ }
9798
+ var drift10 = (message) => ({ ok: false, code: "SCHEMA_DRIFT", message });
9799
+ var unquote3 = (s) => JSON.parse(`"${s}"`);
9800
+ var STR = '((?:[^"\\\\]|\\\\.)+)';
9801
+ var ITEM = /"viewName":"viewer-list-item"(?:,"impressionThresholds":\[[^\]]*\])?[^{}]*"semanticPosition"/;
9802
+ var TEXT_PROPS = /"textProps":\{"fontFamily":"[^"]*","fontSize":"(\w+)","fontStyle":"[^"]*","fontWeight":"(\w+)","lineHeight":"[^"]*","textAlign":"[^"]*","children":/g;
9803
+ var OWN_TEXT = new RegExp(`^\\["${STR}"\\]`);
9804
+ var NESTED_TEXT = new RegExp(`\\[null,"${STR}"`);
9805
+ var LINK2 = new RegExp(`"urlValue":\\{"\\$case":"url","url":"${STR}"`);
9806
+ var PROFILE_ID2 = /ACoA[A-Za-z0-9_-]{10,}/;
9807
+ var PLAIN_TEXT = new RegExp(`"children":\\["${STR}"\\]`, "g");
9808
+ function textsOf(row) {
9809
+ return [...row.matchAll(TEXT_PROPS)].flatMap((m) => {
9810
+ const after = row.slice((m.index ?? 0) + m[0].length, (m.index ?? 0) + m[0].length + 600);
9811
+ const raw = after.match(OWN_TEXT)?.[1] ?? after.match(NESTED_TEXT)?.[1];
9812
+ if (raw === void 0) return [];
9813
+ const text6 = unquote3(raw).trim();
9814
+ return text6 === "" ? [] : [{ size: m[1], weight: m[2], text: text6 }];
9815
+ });
9816
+ }
9817
+ function viewerOf(row, id) {
9818
+ const texts3 = textsOf(row);
9819
+ const at = texts3.findIndex((t) => t.size === "medium" && t.weight === "bold");
9820
+ const first = texts3[at]?.text;
9821
+ if (first === void 0) return void 0;
9822
+ const rest = texts3.slice(at + 1).map((t) => t.text);
9823
+ const degreeText = rest.find((t) => t.startsWith("\u2022"));
9824
+ const lines = rest.filter((t) => t !== degreeText);
9825
+ const viewed = lines.at(-1);
9826
+ const link = row.match(LINK2)?.[1];
9827
+ const url = link === void 0 ? void 0 : unquote3(link);
9828
+ if (url === void 0 || !/linkedin\.com\/in\//.test(url)) {
9829
+ const v = { anonymous: true, description: first };
9830
+ if (viewed !== void 0) v.viewed = viewed;
9831
+ if (url !== void 0) v.searchUrl = url;
9832
+ return v;
9833
+ }
9834
+ const degree = degreeText?.replace(/^•\s*/, "");
9835
+ const headline = lines.length > 1 ? lines[0] : void 0;
9836
+ return {
9837
+ name: first,
9838
+ ...id !== void 0 ? { id } : {},
9839
+ url,
9840
+ ...degree !== void 0 ? { degree } : {},
9841
+ ...headline !== void 0 ? { headline } : {},
9842
+ ...viewed !== void 0 ? { viewed } : {}
9843
+ };
9844
+ }
9845
+ var REF = /"\$[LQ]?([0-9a-f]+)"/g;
9846
+ function idUnder(rows, ref, items) {
9847
+ const seen = /* @__PURE__ */ new Set([ref]);
9848
+ const queue = [ref];
9849
+ while (queue.length > 0 && seen.size < 200) {
9850
+ const row = rows.byId.get(queue.shift()) ?? "";
9851
+ const id = row.match(PROFILE_ID2)?.[0];
9852
+ if (id !== void 0) return id;
9853
+ for (const m of row.matchAll(REF)) {
9854
+ const next = m[1];
9855
+ if (!seen.has(next) && !items.has(next) && rows.byId.has(next)) {
9856
+ seen.add(next);
9857
+ queue.push(next);
9858
+ }
9859
+ }
9860
+ }
9861
+ return void 0;
9862
+ }
9863
+ function idsByViewer(rows, items) {
9864
+ const ids = /* @__PURE__ */ new Map();
9865
+ for (const row of rows.byId.values()) {
9866
+ let current;
9867
+ for (const m of row.matchAll(REF)) {
9868
+ const ref = m[1];
9869
+ if (items.has(ref)) current = ref;
9870
+ else if (current !== void 0 && !ids.has(current)) {
9871
+ const id = idUnder(rows, ref, items);
9872
+ if (id !== void 0) ids.set(current, id);
9873
+ }
9874
+ }
9875
+ }
9876
+ return ids;
9877
+ }
9878
+ function parseViewers(stream) {
9879
+ if (!stream.includes('"viewName":"viewer-list"'))
9880
+ return drift10("the profile viewers answer was not the viewer list");
9881
+ const rows = new Rows(stream);
9882
+ const items = new Set([...rows.byId].filter(([, row]) => ITEM.test(row)).map(([id]) => id));
9883
+ const ids = idsByViewer(rows, items);
9884
+ const viewers = [...items].flatMap((id) => viewerOf(rows.byId.get(id) ?? "", ids.get(id)) ?? []);
9885
+ const shown = Math.max(items.size, (stream.match(new RegExp(ITEM, "g")) ?? []).length);
9886
+ if (shown > 0 && viewers.length === 0)
9887
+ return drift10(`${shown} profile viewers were shown but none could be read`);
9888
+ let privateViewers;
9889
+ for (const [id, row] of rows.byId) {
9890
+ if (items.has(id) || privateViewers !== void 0) continue;
9891
+ for (const m of row.matchAll(PLAIN_TEXT)) {
9892
+ const n = unquote3(m[1]).match(/^(\d[\d.,\s]*)\s+\D/)?.[1];
9893
+ if (n !== void 0) {
9894
+ privateViewers = Number(n.replace(/\D/g, ""));
9895
+ break;
9896
+ }
9897
+ }
9898
+ }
9899
+ return privateViewers === void 0 ? { ok: true, viewers } : { ok: true, viewers, privateViewers };
9900
+ }
9901
+ function parseViewTotals(stream) {
9902
+ const texts3 = [...stream.matchAll(PLAIN_TEXT)].map((m) => unquote3(m[1]).trim());
9903
+ const at = texts3.findIndex((t) => /^\d[\d.,\s]*$/.test(t));
9904
+ if (at === -1) return drift10("the profile view totals carried no number");
9905
+ const total = Number(texts3[at].replace(/\D/g, ""));
9906
+ const period = texts3[at + 1];
9907
+ return period === void 0 ? { ok: true, total } : { ok: true, total, period };
9908
+ }
9909
+
9910
+ // src/commands/viewers.ts
9911
+ function liveFetch9(quiet) {
9912
+ const session = loadSession();
9913
+ if (session.state !== "ok")
9914
+ return err("viewers", "AUTH_FAILED", "no LinkedIn session \u2014 run `lnrelay login`");
9915
+ const client = createLiveClient(session.session, void 0, quiet);
9916
+ return async (url, body, spendClass) => {
9917
+ const r = await client.request({ url, method: "POST", body, spendClass, operation: "viewers" });
9918
+ if (!r.ok) return r;
9919
+ return { ok: true, raw: r.classification.raw ?? "" };
9920
+ };
9921
+ }
9922
+ var compactViewer = (v) => "anonymous" in v ? line(["anonymous", v.description, v.viewed]) : line([v.name, v.degree, v.headline, v.viewed, v.url]);
9923
+ async function runViewers(opts = {}, fetch2) {
9924
+ const get = fetch2 ?? liveFetch9(opts.quiet === true);
9925
+ if (typeof get !== "function") return get;
9926
+ const totalsRes = await get(VIEW_TOTALS_URL, viewTotalsBody(), "page");
9927
+ const totals = totalsRes.ok ? parseViewTotals(totalsRes.raw) : totalsRes;
9928
+ const listRes = await get(VIEWERS_URL, viewersBody(), "page");
9929
+ const list2 = listRes.ok ? parseViewers(listRes.raw) : listRes;
9930
+ if (!list2.ok) return err("viewers", list2.code, list2.message, list2.hint);
9931
+ const shown = list2.viewers.length;
9932
+ const state = !totals.ok ? "unknown" : totals.total > shown ? "partial" : "complete";
9933
+ return ok("viewers", {
9934
+ ...totals.ok ? { total: totals.total, ...totals.period !== void 0 ? { period: totals.period } : {} } : { totalError: `${totals.code}: ${totals.message}` },
9935
+ ...list2.privateViewers !== void 0 ? { privateViewers: list2.privateViewers } : {},
9936
+ items: shape(list2.viewers, opts, compactViewer),
9937
+ meta: { state, operation: "viewers", returnedCount: shown }
9938
+ });
9939
+ }
9940
+
9730
9941
  // src/entry.ts
9731
9942
  import { realpathSync } from "fs";
9732
9943
  import { basename as basename2 } from "path";
@@ -10120,6 +10331,8 @@ async function dispatch(argv, now) {
10120
10331
  return runPeople(peopleRequest(args), output(args));
10121
10332
  case "people-filters":
10122
10333
  return runPeopleFilters(peopleRequest(args), output(args));
10334
+ case "viewers":
10335
+ return runViewers(output(args));
10123
10336
  case "events":
10124
10337
  case "event":
10125
10338
  case "company":