linkedin-relay-mcp 1.2.0 → 1.2.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/cli.js +47 -26
- package/dist/cli.js.map +1 -1
- package/dist/mcp-shim.js +39 -18
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -389,10 +389,16 @@ function shapeSearchRow(node) {
|
|
|
389
389
|
url: cleanUrl(node.navigationUrl)
|
|
390
390
|
});
|
|
391
391
|
}
|
|
392
|
-
function
|
|
392
|
+
function postUrn(node) {
|
|
393
393
|
const meta = node.updateMetadata;
|
|
394
|
+
if (typeof meta?.urn === "string") return meta.urn;
|
|
395
|
+
const entityUrn = node.entityUrn;
|
|
396
|
+
if (typeof entityUrn !== "string") return void 0;
|
|
397
|
+
return /urn:li:(activity|ugcPost|share):\d+/.exec(entityUrn)?.[0];
|
|
398
|
+
}
|
|
399
|
+
function shapePost(node, index) {
|
|
394
400
|
const actor = node.actor;
|
|
395
|
-
const urn =
|
|
401
|
+
const urn = postUrn(node);
|
|
396
402
|
const social = deref(node, "*socialDetail", index);
|
|
397
403
|
const counts = social === void 0 ? void 0 : deref(social, "*totalSocialActivityCounts", index);
|
|
398
404
|
return defined({
|
|
@@ -896,9 +902,10 @@ function classify(res) {
|
|
|
896
902
|
if (res.status === 404) {
|
|
897
903
|
return fail("NOT_FOUND", "no such resource");
|
|
898
904
|
}
|
|
899
|
-
if (res.status
|
|
905
|
+
if (res.status < 200 || res.status >= 300) {
|
|
900
906
|
return fail("FETCH_FAILED", `unexpected status ${res.status}`);
|
|
901
907
|
}
|
|
908
|
+
if (res.body.trim() === "") return { outcome: "ok", retry: false, json: null };
|
|
902
909
|
return classifyBody(res.body);
|
|
903
910
|
}
|
|
904
911
|
function referencesUrns(data) {
|
|
@@ -1074,6 +1081,16 @@ var CONTRACTS = {
|
|
|
1074
1081
|
},
|
|
1075
1082
|
// The member's own posts. Verified 200; returns an empty collection on an
|
|
1076
1083
|
// account with no posts, which is a true empty rather than a failure.
|
|
1084
|
+
// Needs the `fsd_profile` namespace, NOT the `fs_miniProfile` urn `whoami`
|
|
1085
|
+
// returns — the legacy form answers 200 with an empty result rather than an
|
|
1086
|
+
// error. That was invisible until the account had a post to return, and is
|
|
1087
|
+
// why engine.myPosts canonicalises the urn before sending it.
|
|
1088
|
+
//
|
|
1089
|
+
// KNOWN INCOMPLETE (2026-08-13): with the namespace fixed this returns the
|
|
1090
|
+
// owner's posts, but a post created minutes earlier did not appear here, nor
|
|
1091
|
+
// in `feed`, over ~1.5 hours. Whether that is an indexing lag or a coverage
|
|
1092
|
+
// limit of this projection is UNRESOLVED — do not treat this endpoint as an
|
|
1093
|
+
// authoritative "all my posts" until it is settled.
|
|
1077
1094
|
myPosts: {
|
|
1078
1095
|
name: "myPosts",
|
|
1079
1096
|
transport: "voyager-graphql",
|
|
@@ -1401,7 +1418,11 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1401
1418
|
async myPosts(profileUrn, limit) {
|
|
1402
1419
|
const contract = contractFor("myPosts");
|
|
1403
1420
|
if (contract === void 0) return missingContract("myPosts");
|
|
1404
|
-
const variables = encodeVariables({
|
|
1421
|
+
const variables = encodeVariables({
|
|
1422
|
+
count: Math.min(limit, 100),
|
|
1423
|
+
start: 0,
|
|
1424
|
+
profileUrn: canonicalUrn(profileUrn)
|
|
1425
|
+
});
|
|
1405
1426
|
const url = `${contract.path}?includeWebMetadata=true&variables=${variables}&queryId=${contract.queryId}`;
|
|
1406
1427
|
const res = await client.request({ url, spendClass: "page", operation: "myPosts" });
|
|
1407
1428
|
if (!res.ok) return res;
|
|
@@ -1452,13 +1473,13 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1452
1473
|
const envelope = res.json;
|
|
1453
1474
|
return { ok: true, value: { parsed, index: indexIncluded(envelope.included) } };
|
|
1454
1475
|
},
|
|
1455
|
-
async post(
|
|
1476
|
+
async post(postUrn2, limit) {
|
|
1456
1477
|
const contract = contractFor("comments");
|
|
1457
1478
|
if (contract === void 0) return missingContract("comments");
|
|
1458
1479
|
const variables = encodeVariables({
|
|
1459
1480
|
count: Math.min(limit, 100),
|
|
1460
1481
|
numReplies: 1,
|
|
1461
|
-
socialDetailUrn: socialDetailUrn(
|
|
1482
|
+
socialDetailUrn: socialDetailUrn(postUrn2),
|
|
1462
1483
|
sortOrder: "RELEVANCE",
|
|
1463
1484
|
start: 0
|
|
1464
1485
|
});
|
|
@@ -1474,13 +1495,13 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1474
1495
|
const envelope = res.json;
|
|
1475
1496
|
return { ok: true, value: { parsed, index: indexIncluded(envelope.included) } };
|
|
1476
1497
|
},
|
|
1477
|
-
async reactions(
|
|
1498
|
+
async reactions(postUrn2, limit) {
|
|
1478
1499
|
const contract = contractFor("reactions");
|
|
1479
1500
|
if (contract === void 0) return missingContract("reactions");
|
|
1480
1501
|
const variables = encodeVariables({
|
|
1481
1502
|
count: Math.min(limit, 100),
|
|
1482
1503
|
start: 0,
|
|
1483
|
-
threadUrn:
|
|
1504
|
+
threadUrn: postUrn2
|
|
1484
1505
|
});
|
|
1485
1506
|
const url = `${contract.path}?includeWebMetadata=true&variables=${variables}&queryId=${contract.queryId}`;
|
|
1486
1507
|
const res = await client.request({ url, spendClass: "page", operation: "reactions" });
|
|
@@ -1523,8 +1544,8 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1523
1544
|
}
|
|
1524
1545
|
};
|
|
1525
1546
|
}
|
|
1526
|
-
function socialDetailUrn(
|
|
1527
|
-
return `urn:li:fsd_socialDetail:(${
|
|
1547
|
+
function socialDetailUrn(postUrn2) {
|
|
1548
|
+
return `urn:li:fsd_socialDetail:(${postUrn2},${postUrn2},urn:li:highlightedReply:-)`;
|
|
1528
1549
|
}
|
|
1529
1550
|
function totalResultCount(json) {
|
|
1530
1551
|
const found = JSON.stringify(json ?? {}).match(/"totalResultCount":(\d+)/);
|
|
@@ -1952,8 +1973,8 @@ async function runSearch(kind, query, limit, opts = {}) {
|
|
|
1952
1973
|
return ok("search", { query, kind, ...collection(result.value, opts) });
|
|
1953
1974
|
}
|
|
1954
1975
|
async function runPost(urn, limit, opts = {}) {
|
|
1955
|
-
const
|
|
1956
|
-
if (
|
|
1976
|
+
const postUrn2 = normalisePostUrn(urn);
|
|
1977
|
+
if (postUrn2 === void 0) {
|
|
1957
1978
|
return err(
|
|
1958
1979
|
"post",
|
|
1959
1980
|
"INVALID_INPUT",
|
|
@@ -1963,20 +1984,20 @@ async function runPost(urn, limit, opts = {}) {
|
|
|
1963
1984
|
}
|
|
1964
1985
|
const ctx = withSession("post", opts.quiet === true);
|
|
1965
1986
|
if ("ok" in ctx) return ctx;
|
|
1966
|
-
const result = await ctx.engine.post(
|
|
1987
|
+
const result = await ctx.engine.post(postUrn2, limit);
|
|
1967
1988
|
if (!result.ok) return toEnvelope("post", result);
|
|
1968
|
-
return ok("post", { urn:
|
|
1989
|
+
return ok("post", { urn: postUrn2, ...collection(result.value, opts) });
|
|
1969
1990
|
}
|
|
1970
1991
|
async function runReactions(urn, limit, opts = {}) {
|
|
1971
|
-
const
|
|
1972
|
-
if (
|
|
1992
|
+
const postUrn2 = normalisePostUrn(urn);
|
|
1993
|
+
if (postUrn2 === void 0) {
|
|
1973
1994
|
return err("reactions", "INVALID_INPUT", "a post urn or feed URL is required");
|
|
1974
1995
|
}
|
|
1975
1996
|
const ctx = withSession("reactions", opts.quiet === true);
|
|
1976
1997
|
if ("ok" in ctx) return ctx;
|
|
1977
|
-
const result = await ctx.engine.reactions(
|
|
1998
|
+
const result = await ctx.engine.reactions(postUrn2, limit);
|
|
1978
1999
|
if (!result.ok) return toEnvelope("reactions", result);
|
|
1979
|
-
return ok("reactions", { urn:
|
|
2000
|
+
return ok("reactions", { urn: postUrn2, ...collection(result.value, opts) });
|
|
1980
2001
|
}
|
|
1981
2002
|
function normalisePostUrn(input) {
|
|
1982
2003
|
if (input === void 0 || input === "") return void 0;
|
|
@@ -3001,8 +3022,8 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
|
|
|
3001
3022
|
note: "note" in result ? result.note : ctx.note
|
|
3002
3023
|
});
|
|
3003
3024
|
}
|
|
3004
|
-
async function runComment(
|
|
3005
|
-
if (
|
|
3025
|
+
async function runComment(postUrn2, text2, now = Date.now(), deps = terminalDeps()) {
|
|
3026
|
+
if (postUrn2 === void 0 || text2 === void 0 || text2.trim() === "") {
|
|
3006
3027
|
return err(
|
|
3007
3028
|
"comment",
|
|
3008
3029
|
"INVALID_INPUT",
|
|
@@ -3016,8 +3037,8 @@ async function runComment(postUrn, text2, now = Date.now(), deps = terminalDeps(
|
|
|
3016
3037
|
if (unsupported !== null) return unsupported;
|
|
3017
3038
|
const plan = {
|
|
3018
3039
|
action: "comment on a post",
|
|
3019
|
-
payload: { postUrn, text: text2 },
|
|
3020
|
-
summary: [authorLine(ctx.transport), `on ${
|
|
3040
|
+
payload: { postUrn: postUrn2, text: text2 },
|
|
3041
|
+
summary: [authorLine(ctx.transport), `on ${postUrn2}`, `content "${text2}"`],
|
|
3021
3042
|
reversibility: "deletable from the LinkedIn UI; the author is notified immediately",
|
|
3022
3043
|
transport: "oauth"
|
|
3023
3044
|
};
|
|
@@ -3030,9 +3051,9 @@ async function runComment(postUrn, text2, now = Date.now(), deps = terminalDeps(
|
|
|
3030
3051
|
return result.ok ? ok("comment", { id: result.id }) : err("comment", result.code, result.message, result.hint);
|
|
3031
3052
|
}
|
|
3032
3053
|
var REACTIONS = ["LIKE", "PRAISE", "EMPATHY", "INTEREST", "APPRECIATION", "ENTERTAINMENT"];
|
|
3033
|
-
async function runReact(
|
|
3054
|
+
async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps()) {
|
|
3034
3055
|
const reaction = type.toUpperCase();
|
|
3035
|
-
if (
|
|
3056
|
+
if (postUrn2 === void 0) {
|
|
3036
3057
|
return err(
|
|
3037
3058
|
"react",
|
|
3038
3059
|
"INVALID_INPUT",
|
|
@@ -3054,8 +3075,8 @@ async function runReact(postUrn, type, now = Date.now(), deps = terminalDeps())
|
|
|
3054
3075
|
if (unsupported !== null) return unsupported;
|
|
3055
3076
|
const plan = {
|
|
3056
3077
|
action: "react to a post",
|
|
3057
|
-
payload: { postUrn, type: reaction },
|
|
3058
|
-
summary: [authorLine(ctx.transport), `on ${
|
|
3078
|
+
payload: { postUrn: postUrn2, type: reaction },
|
|
3079
|
+
summary: [authorLine(ctx.transport), `on ${postUrn2}`, `reaction ${reaction}`],
|
|
3059
3080
|
reversibility: "removable from the LinkedIn UI; the author is notified immediately",
|
|
3060
3081
|
transport: "oauth"
|
|
3061
3082
|
};
|