@notus-os/mcp 0.1.15 → 0.1.18
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/bin/notusos-mcp.js +451 -27
- package/package.json +1 -1
package/dist/bin/notusos-mcp.js
CHANGED
|
@@ -1036,7 +1036,7 @@ var require_util = __commonJS({
|
|
|
1036
1036
|
var net = __require("node:net");
|
|
1037
1037
|
var { Blob: Blob2 } = __require("node:buffer");
|
|
1038
1038
|
var nodeUtil = __require("node:util");
|
|
1039
|
-
var { stringify } = __require("node:querystring");
|
|
1039
|
+
var { stringify: stringify2 } = __require("node:querystring");
|
|
1040
1040
|
var { EventEmitter: EE } = __require("node:events");
|
|
1041
1041
|
var { InvalidArgumentError } = require_errors();
|
|
1042
1042
|
var { headerNameLowerCasedRecord } = require_constants();
|
|
@@ -1096,7 +1096,7 @@ var require_util = __commonJS({
|
|
|
1096
1096
|
if (url.includes("?") || url.includes("#")) {
|
|
1097
1097
|
throw new Error('Query params cannot be passed when url already contains "?" or "#".');
|
|
1098
1098
|
}
|
|
1099
|
-
const stringified =
|
|
1099
|
+
const stringified = stringify2(queryParams);
|
|
1100
1100
|
if (stringified) {
|
|
1101
1101
|
url += "?" + stringified;
|
|
1102
1102
|
}
|
|
@@ -13404,7 +13404,7 @@ var require_fetch = __commonJS({
|
|
|
13404
13404
|
function handleFetchDone(response) {
|
|
13405
13405
|
finalizeAndReportTiming(response, "fetch");
|
|
13406
13406
|
}
|
|
13407
|
-
function
|
|
13407
|
+
function fetch2(input, init = void 0) {
|
|
13408
13408
|
webidl.argumentLengthCheck(arguments, 1, "globalThis.fetch");
|
|
13409
13409
|
let p = createDeferredPromise();
|
|
13410
13410
|
let requestObject;
|
|
@@ -14361,7 +14361,7 @@ var require_fetch = __commonJS({
|
|
|
14361
14361
|
}
|
|
14362
14362
|
}
|
|
14363
14363
|
module.exports = {
|
|
14364
|
-
fetch,
|
|
14364
|
+
fetch: fetch2,
|
|
14365
14365
|
Fetch,
|
|
14366
14366
|
fetching,
|
|
14367
14367
|
finalizeAndReportTiming
|
|
@@ -16001,7 +16001,7 @@ var require_util6 = __commonJS({
|
|
|
16001
16001
|
throw new Error("Invalid cookie max-age");
|
|
16002
16002
|
}
|
|
16003
16003
|
}
|
|
16004
|
-
function
|
|
16004
|
+
function stringify2(cookie) {
|
|
16005
16005
|
if (cookie.name.length === 0) {
|
|
16006
16006
|
return null;
|
|
16007
16007
|
}
|
|
@@ -16055,7 +16055,7 @@ var require_util6 = __commonJS({
|
|
|
16055
16055
|
validateCookiePath,
|
|
16056
16056
|
validateCookieValue,
|
|
16057
16057
|
toIMFDate,
|
|
16058
|
-
stringify
|
|
16058
|
+
stringify: stringify2
|
|
16059
16059
|
};
|
|
16060
16060
|
}
|
|
16061
16061
|
});
|
|
@@ -16205,7 +16205,7 @@ var require_cookies = __commonJS({
|
|
|
16205
16205
|
"node_modules/undici/lib/web/cookies/index.js"(exports, module) {
|
|
16206
16206
|
"use strict";
|
|
16207
16207
|
var { parseSetCookie } = require_parse();
|
|
16208
|
-
var { stringify } = require_util6();
|
|
16208
|
+
var { stringify: stringify2 } = require_util6();
|
|
16209
16209
|
var { webidl } = require_webidl();
|
|
16210
16210
|
var { Headers: Headers2 } = require_headers();
|
|
16211
16211
|
function getCookies(headers) {
|
|
@@ -16248,7 +16248,7 @@ var require_cookies = __commonJS({
|
|
|
16248
16248
|
webidl.argumentLengthCheck(arguments, 2, "setCookie");
|
|
16249
16249
|
webidl.brandCheck(headers, Headers2, { strict: false });
|
|
16250
16250
|
cookie = webidl.converters.Cookie(cookie);
|
|
16251
|
-
const str =
|
|
16251
|
+
const str = stringify2(cookie);
|
|
16252
16252
|
if (str) {
|
|
16253
16253
|
headers.append("Set-Cookie", str);
|
|
16254
16254
|
}
|
|
@@ -18656,7 +18656,7 @@ var require_undici = __commonJS({
|
|
|
18656
18656
|
module.exports.setGlobalDispatcher = setGlobalDispatcher;
|
|
18657
18657
|
module.exports.getGlobalDispatcher = getGlobalDispatcher;
|
|
18658
18658
|
var fetchImpl = require_fetch().fetch;
|
|
18659
|
-
module.exports.fetch = async function
|
|
18659
|
+
module.exports.fetch = async function fetch2(init, options = void 0) {
|
|
18660
18660
|
try {
|
|
18661
18661
|
return await fetchImpl(init, options);
|
|
18662
18662
|
} catch (err) {
|
|
@@ -25833,7 +25833,7 @@ var init_streamableHttp = __esm({
|
|
|
25833
25833
|
// src/session.ts
|
|
25834
25834
|
async function resolveMcpAccessMode(api) {
|
|
25835
25835
|
const profile = await api.get("/api/profile");
|
|
25836
|
-
return profile.is_admin === true ? "full" : "read_only";
|
|
25836
|
+
return profile.user?.is_admin === true || profile.is_admin === true ? "full" : "read_only";
|
|
25837
25837
|
}
|
|
25838
25838
|
var init_session = __esm({
|
|
25839
25839
|
"src/session.ts"() {
|
|
@@ -31542,10 +31542,10 @@ var require_code = __commonJS({
|
|
|
31542
31542
|
function interpolate(x) {
|
|
31543
31543
|
return typeof x == "number" || typeof x == "boolean" || x === null ? x : safeStringify(Array.isArray(x) ? x.join(",") : x);
|
|
31544
31544
|
}
|
|
31545
|
-
function
|
|
31545
|
+
function stringify2(x) {
|
|
31546
31546
|
return new _Code(safeStringify(x));
|
|
31547
31547
|
}
|
|
31548
|
-
exports.stringify =
|
|
31548
|
+
exports.stringify = stringify2;
|
|
31549
31549
|
function safeStringify(x) {
|
|
31550
31550
|
return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
31551
31551
|
}
|
|
@@ -39022,6 +39022,62 @@ __export(clients_exports, {
|
|
|
39022
39022
|
get_client_detail: () => get_client_detail,
|
|
39023
39023
|
list_clients: () => list_clients
|
|
39024
39024
|
});
|
|
39025
|
+
function matchesClientSearch(client, rawNeedle) {
|
|
39026
|
+
const needle = normalizeSearchText(rawNeedle);
|
|
39027
|
+
if (!needle) return true;
|
|
39028
|
+
return normalizeSearchText(JSON.stringify([
|
|
39029
|
+
getString(client, "id"),
|
|
39030
|
+
getString(client, "email"),
|
|
39031
|
+
getString(client, "full_name"),
|
|
39032
|
+
getString(client, "title"),
|
|
39033
|
+
getString(client, "organizationId"),
|
|
39034
|
+
getString(client, "organizationName"),
|
|
39035
|
+
getString(client, "slack_channel_id"),
|
|
39036
|
+
getNestedString(client, ["assignment", "strategist", "full_name"]),
|
|
39037
|
+
getNestedString(client, ["assignment", "strategist", "email"])
|
|
39038
|
+
])).includes(needle);
|
|
39039
|
+
}
|
|
39040
|
+
function compactClient(client) {
|
|
39041
|
+
return {
|
|
39042
|
+
id: getString(client, "id"),
|
|
39043
|
+
email: getString(client, "email"),
|
|
39044
|
+
full_name: getString(client, "full_name"),
|
|
39045
|
+
title: getString(client, "title"),
|
|
39046
|
+
organizationId: getString(client, "organizationId"),
|
|
39047
|
+
organizationName: getString(client, "organizationName"),
|
|
39048
|
+
onboardingStage: getString(client, "onboardingStage"),
|
|
39049
|
+
unresolvedComments: getNumber(client, "unresolvedComments"),
|
|
39050
|
+
setupProgress: getRecord(client, "setupProgress"),
|
|
39051
|
+
churnRisk: getRecord(client, "churnRisk"),
|
|
39052
|
+
daysSinceLastPublishedPost: getNumber(client, "daysSinceLastPublishedPost"),
|
|
39053
|
+
assignedStrategist: getRecord(getRecord(client, "assignment"), "strategist"),
|
|
39054
|
+
slack_channel_id: getString(client, "slack_channel_id"),
|
|
39055
|
+
slack_channel_inherited_from: getString(client, "slack_channel_inherited_from"),
|
|
39056
|
+
feedback_summary: getRecord(client, "feedback_summary")
|
|
39057
|
+
};
|
|
39058
|
+
}
|
|
39059
|
+
function normalizeSearchText(value) {
|
|
39060
|
+
return value.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "");
|
|
39061
|
+
}
|
|
39062
|
+
function getRecord(value, key) {
|
|
39063
|
+
const target = key ? value?.[key] : value;
|
|
39064
|
+
return target && typeof target === "object" && !Array.isArray(target) ? target : null;
|
|
39065
|
+
}
|
|
39066
|
+
function getString(value, key) {
|
|
39067
|
+
const entry = value?.[key];
|
|
39068
|
+
return typeof entry === "string" ? entry : null;
|
|
39069
|
+
}
|
|
39070
|
+
function getNestedString(value, path) {
|
|
39071
|
+
let current = value;
|
|
39072
|
+
for (const key of path) {
|
|
39073
|
+
current = current?.[key];
|
|
39074
|
+
}
|
|
39075
|
+
return typeof current === "string" ? current : null;
|
|
39076
|
+
}
|
|
39077
|
+
function getNumber(value, key) {
|
|
39078
|
+
const entry = value?.[key];
|
|
39079
|
+
return typeof entry === "number" ? entry : null;
|
|
39080
|
+
}
|
|
39025
39081
|
var listClientsSchema, list_clients, getClientDetailSchema, get_client_detail, getCareerHistorySchema, get_career_history;
|
|
39026
39082
|
var init_clients = __esm({
|
|
39027
39083
|
"src/tools/clients.ts"() {
|
|
@@ -39030,17 +39086,39 @@ var init_clients = __esm({
|
|
|
39030
39086
|
init_tools();
|
|
39031
39087
|
listClientsSchema = external_exports.object({
|
|
39032
39088
|
scope: external_exports.enum(["mine", "all", "global", "assigned"]).optional(),
|
|
39033
|
-
includeFeedbackSummary: external_exports.boolean().optional()
|
|
39089
|
+
includeFeedbackSummary: external_exports.boolean().optional(),
|
|
39090
|
+
search: external_exports.string().min(1).max(120).optional(),
|
|
39091
|
+
limit: external_exports.number().int().min(1).max(100).optional(),
|
|
39092
|
+
offset: external_exports.number().int().min(0).optional(),
|
|
39093
|
+
includeDetails: external_exports.boolean().optional()
|
|
39034
39094
|
});
|
|
39035
39095
|
list_clients = {
|
|
39036
39096
|
name: "list_clients",
|
|
39037
|
-
description: "List clients visible through this MCP session. Non-admin/read-only sessions should omit `scope` or use `assigned`; they only receive clients where they are the assigned Content Strategist (`profiles.assigned_strategist_id`). Admin sessions can use the full scope set.
|
|
39097
|
+
description: "List clients visible through this MCP session as a compact, paginated index. Use `search` to find a specific client by name, email, title, organization, strategist, or Slack channel before calling detail tools. Non-admin/read-only sessions should omit `scope` or use `assigned`; they only receive clients where they are the assigned Content Strategist (`profiles.assigned_strategist_id`). Admin sessions can use the full scope set. Scopes: 'assigned' returns ONLY clients where you are the explicitly assigned CS; 'mine' returns assigned plus unassigned clients; 'all' returns every client in strategist orgs; 'global' is admin-only and returns every client across every org you can access. Defaults to `limit: 25`; max `limit` is 100. Set `includeDetails: true` only when a larger raw page is explicitly needed; prefer `get_client_detail` for one client.",
|
|
39038
39098
|
inputSchema: listClientsSchema,
|
|
39039
39099
|
handler: async (args, ctx) => {
|
|
39040
39100
|
const query = {};
|
|
39041
39101
|
if (args.scope) query.scope = args.scope;
|
|
39042
39102
|
if (args.includeFeedbackSummary) query.include = "feedback_summary";
|
|
39043
|
-
|
|
39103
|
+
const response = await ctx.api.get("/api/strategist/clients", { query });
|
|
39104
|
+
const clients = Array.isArray(response.clients) ? response.clients : [];
|
|
39105
|
+
const searched = args.search ? clients.filter((client) => matchesClientSearch(client, args.search)) : clients;
|
|
39106
|
+
const offset = args.offset ?? 0;
|
|
39107
|
+
const limit = args.limit ?? 25;
|
|
39108
|
+
const page = searched.slice(offset, offset + limit);
|
|
39109
|
+
const compactClients = args.includeDetails ? page : page.map(compactClient);
|
|
39110
|
+
return {
|
|
39111
|
+
scope: response.scope ?? args.scope ?? null,
|
|
39112
|
+
total: clients.length,
|
|
39113
|
+
matched: searched.length,
|
|
39114
|
+
offset,
|
|
39115
|
+
limit,
|
|
39116
|
+
has_more: offset + limit < searched.length,
|
|
39117
|
+
next_offset: offset + limit < searched.length ? offset + limit : null,
|
|
39118
|
+
search: args.search ?? null,
|
|
39119
|
+
clients: compactClients,
|
|
39120
|
+
note: args.includeDetails ? "Full list page returned. Prefer get_client_detail for one client when possible." : "Compact list page returned. Use search to narrow results, next_offset for pagination, and get_client_detail with id + organizationId for full client data."
|
|
39121
|
+
};
|
|
39044
39122
|
}
|
|
39045
39123
|
};
|
|
39046
39124
|
getClientDetailSchema = external_exports.object({
|
|
@@ -39210,6 +39288,57 @@ __export(posts_exports, {
|
|
|
39210
39288
|
list_posts: () => list_posts,
|
|
39211
39289
|
update_post: () => update_post
|
|
39212
39290
|
});
|
|
39291
|
+
function compactPostsResponse(response) {
|
|
39292
|
+
const posts = extractPosts(response);
|
|
39293
|
+
if (!posts) return response;
|
|
39294
|
+
const compactPosts = posts.map(compactPost);
|
|
39295
|
+
if (Array.isArray(response)) {
|
|
39296
|
+
return {
|
|
39297
|
+
total: posts.length,
|
|
39298
|
+
posts: compactPosts,
|
|
39299
|
+
note: "Post index returned with 100-character previews. Use get_post with a post id for the full body."
|
|
39300
|
+
};
|
|
39301
|
+
}
|
|
39302
|
+
return {
|
|
39303
|
+
...response,
|
|
39304
|
+
posts: compactPosts,
|
|
39305
|
+
items: Array.isArray(response.items) ? compactPosts : void 0,
|
|
39306
|
+
note: "Post index returned with 100-character previews. Use get_post with a post id for the full body."
|
|
39307
|
+
};
|
|
39308
|
+
}
|
|
39309
|
+
function extractPosts(response) {
|
|
39310
|
+
if (Array.isArray(response)) return response;
|
|
39311
|
+
if (!response || typeof response !== "object") return null;
|
|
39312
|
+
const record2 = response;
|
|
39313
|
+
if (Array.isArray(record2.posts)) return record2.posts;
|
|
39314
|
+
if (Array.isArray(record2.items)) return record2.items;
|
|
39315
|
+
return null;
|
|
39316
|
+
}
|
|
39317
|
+
function compactPost(post) {
|
|
39318
|
+
const body = getString2(post, "body") ?? getString2(post, "content") ?? "";
|
|
39319
|
+
return {
|
|
39320
|
+
id: getString2(post, "id"),
|
|
39321
|
+
status: getString2(post, "status"),
|
|
39322
|
+
source_type: getString2(post, "source_type"),
|
|
39323
|
+
title: getString2(post, "title"),
|
|
39324
|
+
pillars: getUnknown(post, "pillars"),
|
|
39325
|
+
image_urls: getUnknown(post, "image_urls"),
|
|
39326
|
+
content_piece_id: getString2(post, "content_piece_id"),
|
|
39327
|
+
conversation_id: getString2(post, "conversation_id"),
|
|
39328
|
+
scheduled_at: getString2(post, "scheduled_at"),
|
|
39329
|
+
published_at: getString2(post, "published_at") ?? getString2(post, "linkedin_posted_at"),
|
|
39330
|
+
updated_at: getString2(post, "updated_at"),
|
|
39331
|
+
body_chars: body.length,
|
|
39332
|
+
preview: body.length > 100 ? `${body.slice(0, 100)}...` : body
|
|
39333
|
+
};
|
|
39334
|
+
}
|
|
39335
|
+
function getString2(value, key) {
|
|
39336
|
+
const entry = value?.[key];
|
|
39337
|
+
return typeof entry === "string" ? entry : null;
|
|
39338
|
+
}
|
|
39339
|
+
function getUnknown(value, key) {
|
|
39340
|
+
return value?.[key] ?? null;
|
|
39341
|
+
}
|
|
39213
39342
|
var listPostsSchema, list_posts, getPostSchema, get_post, createPostSchema, create_post, updatePostSchema, update_post, deletePostSchema, delete_post, getPostVersionsSchema, get_post_versions, generatePostSchema, generate_post;
|
|
39214
39343
|
var init_posts = __esm({
|
|
39215
39344
|
"src/tools/posts.ts"() {
|
|
@@ -39224,14 +39353,15 @@ var init_posts = __esm({
|
|
|
39224
39353
|
});
|
|
39225
39354
|
list_posts = {
|
|
39226
39355
|
name: "list_posts",
|
|
39227
|
-
description: "List posts for a client, optionally filtered by status. Returns
|
|
39356
|
+
description: "List posts for a client as an index, optionally filtered by status. Returns IDs, status, dates, pillars, source_type, body length, and the first 100 characters only. Use get_post with a returned ID to fetch the full body for one post.",
|
|
39228
39357
|
inputSchema: listPostsSchema,
|
|
39229
39358
|
handler: async (args, ctx) => {
|
|
39230
39359
|
const { clientUserId, clientOrganizationId, appMode, ...q } = args;
|
|
39231
|
-
|
|
39360
|
+
const response = await ctx.api.get("/api/posts", {
|
|
39232
39361
|
query: compact(q),
|
|
39233
39362
|
clientContext: toClientContext({ clientUserId, clientOrganizationId, appMode })
|
|
39234
39363
|
});
|
|
39364
|
+
return compactPostsResponse(response);
|
|
39235
39365
|
}
|
|
39236
39366
|
};
|
|
39237
39367
|
getPostSchema = external_exports.object({
|
|
@@ -39538,7 +39668,7 @@ var init_resources = __esm({
|
|
|
39538
39668
|
listResourcesSchema = external_exports.object({ ...clientTarget });
|
|
39539
39669
|
list_resources = {
|
|
39540
39670
|
name: "list_resources",
|
|
39541
|
-
description: "All strategy docs, brand guides, and content pillars enabled in a client's library. Returns id, name, resource_type,
|
|
39671
|
+
description: "All strategy docs, brand guides, and content pillars enabled in a client's library. Returns id, name, resource_type, enabled, timestamps. Use get_resource with an id to fetch the content body.",
|
|
39542
39672
|
inputSchema: listResourcesSchema,
|
|
39543
39673
|
handler: async (args, ctx) => {
|
|
39544
39674
|
return ctx.api.get("/api/resources", { clientContext: toClientContext(args) });
|
|
@@ -40606,6 +40736,7 @@ var init_feedback = __esm({
|
|
|
40606
40736
|
var analytics_deep_exports = {};
|
|
40607
40737
|
__export(analytics_deep_exports, {
|
|
40608
40738
|
get_analytics_deep_dive: () => get_analytics_deep_dive,
|
|
40739
|
+
get_analytics_posts: () => get_analytics_posts,
|
|
40609
40740
|
get_icp_contacts: () => get_icp_contacts,
|
|
40610
40741
|
get_icp_post_engagement: () => get_icp_post_engagement,
|
|
40611
40742
|
get_linkedin_analytics: () => get_linkedin_analytics,
|
|
@@ -40614,7 +40745,27 @@ __export(analytics_deep_exports, {
|
|
|
40614
40745
|
sync_icp_contacts: () => sync_icp_contacts,
|
|
40615
40746
|
sync_icp_contacts_all: () => sync_icp_contacts_all
|
|
40616
40747
|
});
|
|
40617
|
-
|
|
40748
|
+
function compactAnalyticsPostsResponse(response) {
|
|
40749
|
+
if (!response || typeof response !== "object") return response;
|
|
40750
|
+
const record2 = response;
|
|
40751
|
+
if (!Array.isArray(record2.posts)) return response;
|
|
40752
|
+
return {
|
|
40753
|
+
...record2,
|
|
40754
|
+
posts: record2.posts.map((post) => {
|
|
40755
|
+
if (!post || typeof post !== "object") return post;
|
|
40756
|
+
const postRecord = post;
|
|
40757
|
+
const text = postRecord.text;
|
|
40758
|
+
if (typeof text !== "string" || text.length <= MCP_POST_TEXT_PREVIEW_CHARS) {
|
|
40759
|
+
return post;
|
|
40760
|
+
}
|
|
40761
|
+
return {
|
|
40762
|
+
...postRecord,
|
|
40763
|
+
text: `${text.slice(0, MCP_POST_TEXT_PREVIEW_CHARS)}...TRUNCATED_TEXT(${text.length} chars)`
|
|
40764
|
+
};
|
|
40765
|
+
})
|
|
40766
|
+
};
|
|
40767
|
+
}
|
|
40768
|
+
var getAnalyticsDeepDiveSchema, get_analytics_deep_dive, getAnalyticsPostsSchema, MCP_POST_TEXT_PREVIEW_CHARS, get_analytics_posts, getLinkedinAnalyticsSchema, get_linkedin_analytics, getIcpContactsSchema, get_icp_contacts, syncIcpContactsSchema, sync_icp_contacts, syncIcpContactsAllSchema, sync_icp_contacts_all, listGojiberryCampaignsSchema, list_gojiberry_campaigns, setGojiberryCampaignSchema, set_gojiberry_campaign, getIcpPostSchema, get_icp_post_engagement;
|
|
40618
40769
|
var init_analytics_deep = __esm({
|
|
40619
40770
|
"src/tools/analytics-deep.ts"() {
|
|
40620
40771
|
"use strict";
|
|
@@ -40651,6 +40802,48 @@ var init_analytics_deep = __esm({
|
|
|
40651
40802
|
return Object.fromEntries(entries);
|
|
40652
40803
|
}
|
|
40653
40804
|
};
|
|
40805
|
+
getAnalyticsPostsSchema = external_exports.object({
|
|
40806
|
+
...clientTarget,
|
|
40807
|
+
days: external_exports.number().int().min(1).max(730).optional(),
|
|
40808
|
+
startDate: external_exports.string().optional(),
|
|
40809
|
+
endDate: external_exports.string().optional(),
|
|
40810
|
+
page: external_exports.number().int().min(1).optional(),
|
|
40811
|
+
limit: external_exports.number().int().min(1).max(25).optional(),
|
|
40812
|
+
sortBy: external_exports.enum(["posted_at", "score", "impressions", "likes", "comments", "reposts"]).optional()
|
|
40813
|
+
});
|
|
40814
|
+
MCP_POST_TEXT_PREVIEW_CHARS = 1200;
|
|
40815
|
+
get_analytics_posts = {
|
|
40816
|
+
name: "get_analytics_posts",
|
|
40817
|
+
description: "Paginated LinkedIn analytics posts for a client. Returns up to 25 posts per call with metrics, text preview, Shield-style score fields, total, page, has_more, and next_page. Use this instead of get_analytics_deep_dive when you need more than the first compacted post preview, such as a six-month post export.",
|
|
40818
|
+
inputSchema: getAnalyticsPostsSchema,
|
|
40819
|
+
handler: async (args, ctx) => {
|
|
40820
|
+
const {
|
|
40821
|
+
clientUserId,
|
|
40822
|
+
clientOrganizationId,
|
|
40823
|
+
appMode,
|
|
40824
|
+
days,
|
|
40825
|
+
startDate,
|
|
40826
|
+
endDate,
|
|
40827
|
+
page = 1,
|
|
40828
|
+
limit = 25,
|
|
40829
|
+
sortBy = "posted_at"
|
|
40830
|
+
} = args;
|
|
40831
|
+
const offset = (page - 1) * limit;
|
|
40832
|
+
const query = compact({
|
|
40833
|
+
days: startDate || endDate ? void 0 : days ?? 180,
|
|
40834
|
+
startDate,
|
|
40835
|
+
endDate,
|
|
40836
|
+
limit,
|
|
40837
|
+
offset,
|
|
40838
|
+
sortBy
|
|
40839
|
+
});
|
|
40840
|
+
const response = await ctx.api.get("/api/analytics/posts", {
|
|
40841
|
+
query,
|
|
40842
|
+
clientContext: toClientContext({ clientUserId, clientOrganizationId, appMode })
|
|
40843
|
+
});
|
|
40844
|
+
return compactAnalyticsPostsResponse(response);
|
|
40845
|
+
}
|
|
40846
|
+
};
|
|
40654
40847
|
getLinkedinAnalyticsSchema = external_exports.object({
|
|
40655
40848
|
...clientTarget,
|
|
40656
40849
|
days: external_exports.number().int().min(1).max(730).optional()
|
|
@@ -40761,6 +40954,7 @@ var init_analytics_deep = __esm({
|
|
|
40761
40954
|
};
|
|
40762
40955
|
registerTools(
|
|
40763
40956
|
get_analytics_deep_dive,
|
|
40957
|
+
get_analytics_posts,
|
|
40764
40958
|
get_linkedin_analytics,
|
|
40765
40959
|
get_icp_contacts,
|
|
40766
40960
|
sync_icp_contacts,
|
|
@@ -41387,6 +41581,74 @@ var init_tools = __esm({
|
|
|
41387
41581
|
}
|
|
41388
41582
|
});
|
|
41389
41583
|
|
|
41584
|
+
// src/tool-result.ts
|
|
41585
|
+
function formatToolResult(result, maxChars = DEFAULT_MAX_TOOL_RESULT_CHARS) {
|
|
41586
|
+
const full = stringify(result);
|
|
41587
|
+
if (full.length <= maxChars) return full;
|
|
41588
|
+
const compacted = {
|
|
41589
|
+
_notusos_mcp_notice: "Tool result was too large for Claude context and has been compacted. Re-run with narrower filters, search, pagination, or a detail tool for a specific item.",
|
|
41590
|
+
_original_chars: full.length,
|
|
41591
|
+
result: compactValue(result)
|
|
41592
|
+
};
|
|
41593
|
+
const compact2 = stringify(compacted);
|
|
41594
|
+
if (compact2.length <= maxChars) return compact2;
|
|
41595
|
+
return `${compact2.slice(0, maxChars)}
|
|
41596
|
+
|
|
41597
|
+
...TRUNCATED_BY_NOTUSOS_MCP (${compact2.length} compacted chars; narrow the request and retry)`;
|
|
41598
|
+
}
|
|
41599
|
+
function stringify(value) {
|
|
41600
|
+
return JSON.stringify(value, null, 2);
|
|
41601
|
+
}
|
|
41602
|
+
function compactValue(value, depth = 0) {
|
|
41603
|
+
if (value === null || typeof value === "number" || typeof value === "boolean") return value;
|
|
41604
|
+
if (typeof value === "string") {
|
|
41605
|
+
if (value.length <= MAX_STRING_CHARS) return value;
|
|
41606
|
+
return `${value.slice(0, MAX_STRING_CHARS)}...TRUNCATED_STRING(${value.length} chars)`;
|
|
41607
|
+
}
|
|
41608
|
+
if (Array.isArray(value)) {
|
|
41609
|
+
return {
|
|
41610
|
+
_type: "array",
|
|
41611
|
+
_total: value.length,
|
|
41612
|
+
_shown: Math.min(value.length, ARRAY_PREVIEW_ITEMS),
|
|
41613
|
+
items: value.slice(0, ARRAY_PREVIEW_ITEMS).map((entry) => compactValue(entry, depth + 1)),
|
|
41614
|
+
...value.length > ARRAY_PREVIEW_ITEMS ? { _has_more: true } : {}
|
|
41615
|
+
};
|
|
41616
|
+
}
|
|
41617
|
+
if (typeof value === "object") {
|
|
41618
|
+
const entries = Object.entries(value);
|
|
41619
|
+
const shownEntries = entries.slice(0, MAX_OBJECT_KEYS);
|
|
41620
|
+
const output = {};
|
|
41621
|
+
for (const [key, entry] of shownEntries) {
|
|
41622
|
+
output[key] = depth >= 6 ? summarizeLeaf(entry) : compactValue(entry, depth + 1);
|
|
41623
|
+
}
|
|
41624
|
+
if (entries.length > MAX_OBJECT_KEYS) {
|
|
41625
|
+
output._truncated_keys = entries.length - MAX_OBJECT_KEYS;
|
|
41626
|
+
}
|
|
41627
|
+
return output;
|
|
41628
|
+
}
|
|
41629
|
+
return String(value);
|
|
41630
|
+
}
|
|
41631
|
+
function summarizeLeaf(value) {
|
|
41632
|
+
if (Array.isArray(value)) return { _type: "array", _total: value.length };
|
|
41633
|
+
if (typeof value === "string") {
|
|
41634
|
+
return value.length <= 500 ? value : `${value.slice(0, 500)}...TRUNCATED_STRING(${value.length} chars)`;
|
|
41635
|
+
}
|
|
41636
|
+
if (value && typeof value === "object") {
|
|
41637
|
+
return { _type: "object", _keys: Object.keys(value).length };
|
|
41638
|
+
}
|
|
41639
|
+
return value;
|
|
41640
|
+
}
|
|
41641
|
+
var DEFAULT_MAX_TOOL_RESULT_CHARS, ARRAY_PREVIEW_ITEMS, MAX_STRING_CHARS, MAX_OBJECT_KEYS;
|
|
41642
|
+
var init_tool_result = __esm({
|
|
41643
|
+
"src/tool-result.ts"() {
|
|
41644
|
+
"use strict";
|
|
41645
|
+
DEFAULT_MAX_TOOL_RESULT_CHARS = 6e4;
|
|
41646
|
+
ARRAY_PREVIEW_ITEMS = 25;
|
|
41647
|
+
MAX_STRING_CHARS = 8e3;
|
|
41648
|
+
MAX_OBJECT_KEYS = 80;
|
|
41649
|
+
}
|
|
41650
|
+
});
|
|
41651
|
+
|
|
41390
41652
|
// src/tools/permissions.ts
|
|
41391
41653
|
function getToolAccess(name) {
|
|
41392
41654
|
if (ADMIN_TOOL_NAMES.has(name)) return "admin";
|
|
@@ -41397,7 +41659,13 @@ function isToolAllowed(name, accessMode) {
|
|
|
41397
41659
|
if (accessMode === "full") return true;
|
|
41398
41660
|
return getToolAccess(name) === "read";
|
|
41399
41661
|
}
|
|
41400
|
-
|
|
41662
|
+
function isToolReadOnly(name) {
|
|
41663
|
+
return !WRITE_TOOL_NAMES.has(name) && !DESTRUCTIVE_TOOL_NAMES.has(name) && name !== "sync_icp_contacts_all";
|
|
41664
|
+
}
|
|
41665
|
+
function isToolDestructive(name) {
|
|
41666
|
+
return DESTRUCTIVE_TOOL_NAMES.has(name);
|
|
41667
|
+
}
|
|
41668
|
+
var WRITE_TOOL_NAMES, ADMIN_TOOL_NAMES, DESTRUCTIVE_TOOL_NAMES;
|
|
41401
41669
|
var init_permissions = __esm({
|
|
41402
41670
|
"src/tools/permissions.ts"() {
|
|
41403
41671
|
"use strict";
|
|
@@ -41456,6 +41724,19 @@ var init_permissions = __esm({
|
|
|
41456
41724
|
"manage_exclusions",
|
|
41457
41725
|
"sync_icp_contacts_all"
|
|
41458
41726
|
]);
|
|
41727
|
+
DESTRUCTIVE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
41728
|
+
"delete_client_resource",
|
|
41729
|
+
"delete_comment",
|
|
41730
|
+
"delete_content_piece",
|
|
41731
|
+
"delete_content_source",
|
|
41732
|
+
"delete_conversation",
|
|
41733
|
+
"delete_image",
|
|
41734
|
+
"delete_image_folder",
|
|
41735
|
+
"delete_post",
|
|
41736
|
+
"delete_report",
|
|
41737
|
+
"delete_resource",
|
|
41738
|
+
"manage_exclusions"
|
|
41739
|
+
]);
|
|
41459
41740
|
}
|
|
41460
41741
|
});
|
|
41461
41742
|
|
|
@@ -41494,7 +41775,14 @@ async function createMcpProtocolServer(opts) {
|
|
|
41494
41775
|
tools: visibleTools.map((t) => ({
|
|
41495
41776
|
name: t.name,
|
|
41496
41777
|
description: t.description,
|
|
41497
|
-
inputSchema: zodToJsonSchemaStub(t.inputSchema)
|
|
41778
|
+
inputSchema: zodToJsonSchemaStub(t.inputSchema),
|
|
41779
|
+
annotations: {
|
|
41780
|
+
title: t.name,
|
|
41781
|
+
readOnlyHint: isToolReadOnly(t.name),
|
|
41782
|
+
destructiveHint: isToolDestructive(t.name),
|
|
41783
|
+
idempotentHint: getToolAccess(t.name) !== "write" && !isToolDestructive(t.name),
|
|
41784
|
+
openWorldHint: true
|
|
41785
|
+
}
|
|
41498
41786
|
}))
|
|
41499
41787
|
}));
|
|
41500
41788
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
@@ -41529,7 +41817,7 @@ async function createMcpProtocolServer(opts) {
|
|
|
41529
41817
|
const result = await tool.handler(parsed.data, ctx);
|
|
41530
41818
|
return {
|
|
41531
41819
|
content: [
|
|
41532
|
-
{ type: "text", text:
|
|
41820
|
+
{ type: "text", text: formatToolResult(result) }
|
|
41533
41821
|
]
|
|
41534
41822
|
};
|
|
41535
41823
|
} catch (err) {
|
|
@@ -41634,17 +41922,20 @@ var init_server3 = __esm({
|
|
|
41634
41922
|
init_api_client();
|
|
41635
41923
|
init_session();
|
|
41636
41924
|
init_tools();
|
|
41925
|
+
init_tool_result();
|
|
41637
41926
|
init_permissions();
|
|
41638
41927
|
init_logger();
|
|
41639
41928
|
SERVER_NAME = "notusos-mcp";
|
|
41640
|
-
SERVER_VERSION = true ? "0.1.
|
|
41929
|
+
SERVER_VERSION = true ? "0.1.18" : "dev";
|
|
41641
41930
|
}
|
|
41642
41931
|
});
|
|
41643
41932
|
|
|
41644
41933
|
// src/remote-server.ts
|
|
41645
41934
|
var remote_server_exports = {};
|
|
41646
41935
|
__export(remote_server_exports, {
|
|
41936
|
+
buildOAuthAuthorizationServerMetadata: () => buildOAuthAuthorizationServerMetadata,
|
|
41647
41937
|
getPathname: () => getPathname,
|
|
41938
|
+
isAllowedConnectorRedirectUri: () => isAllowedConnectorRedirectUri,
|
|
41648
41939
|
isAllowedMcpMethod: () => isAllowedMcpMethod,
|
|
41649
41940
|
isRequestTooLarge: () => isRequestTooLarge,
|
|
41650
41941
|
startRemoteServer: () => startRemoteServer
|
|
@@ -41667,18 +41958,73 @@ async function startRemoteServer(config2) {
|
|
|
41667
41958
|
writeJson(res, 200, { ok: true });
|
|
41668
41959
|
return;
|
|
41669
41960
|
}
|
|
41670
|
-
if (pathname === "/.well-known/oauth-protected-resource") {
|
|
41961
|
+
if (pathname === "/.well-known/oauth-protected-resource" || pathname === "/.well-known/oauth-protected-resource/mcp") {
|
|
41671
41962
|
const resource = publicUrl ? `${publicUrl}/mcp` : "/mcp";
|
|
41672
41963
|
writeJson(res, 200, {
|
|
41673
41964
|
resource,
|
|
41674
|
-
authorization_servers: [authBaseUrl],
|
|
41965
|
+
authorization_servers: [publicUrl || authBaseUrl],
|
|
41675
41966
|
bearer_methods_supported: ["header"],
|
|
41676
41967
|
scopes_supported: ["notusos:mcp"],
|
|
41677
41968
|
resource_name: "notusOS MCP"
|
|
41678
41969
|
});
|
|
41679
41970
|
return;
|
|
41680
41971
|
}
|
|
41681
|
-
if (pathname
|
|
41972
|
+
if (pathname === "/.well-known/oauth-authorization-server" || pathname === "/.well-known/oauth-authorization-server/mcp" || pathname === "/.well-known/openid-configuration" || pathname === "/.well-known/openid-configuration/mcp") {
|
|
41973
|
+
writeJson(res, 200, buildOAuthAuthorizationServerMetadata({ authBaseUrl, publicUrl }));
|
|
41974
|
+
return;
|
|
41975
|
+
}
|
|
41976
|
+
if (pathname === "/register") {
|
|
41977
|
+
if (req.method !== "POST") {
|
|
41978
|
+
writeJson(res, 405, { error: "Method not allowed" });
|
|
41979
|
+
return;
|
|
41980
|
+
}
|
|
41981
|
+
if (isRequestTooLarge(req, maxRequestBytes)) {
|
|
41982
|
+
writeJson(res, 413, { error: "Request too large" });
|
|
41983
|
+
return;
|
|
41984
|
+
}
|
|
41985
|
+
const body = await readJsonBody(req, maxRequestBytes);
|
|
41986
|
+
const requestedName = typeof body.client_name === "string" ? body.client_name : "MCP connector";
|
|
41987
|
+
const requestedRedirectUris = Array.isArray(body.redirect_uris) ? body.redirect_uris.filter((uri) => typeof uri === "string" && isAllowedConnectorRedirectUri(uri)) : [];
|
|
41988
|
+
writeJson(res, 201, {
|
|
41989
|
+
client_id: typeof body.client_id === "string" ? body.client_id : "notusos-mcp-cloud",
|
|
41990
|
+
client_name: requestedName,
|
|
41991
|
+
redirect_uris: requestedRedirectUris.length > 0 ? requestedRedirectUris : [
|
|
41992
|
+
"https://claude.ai/api/mcp/auth_callback",
|
|
41993
|
+
"https://claude.com/api/mcp/auth_callback",
|
|
41994
|
+
"https://chatgpt.com/connector_platform_oauth_redirect"
|
|
41995
|
+
],
|
|
41996
|
+
grant_types: ["authorization_code"],
|
|
41997
|
+
response_types: ["code"],
|
|
41998
|
+
token_endpoint_auth_method: "none",
|
|
41999
|
+
client_id_issued_at: Math.floor(Date.now() / 1e3)
|
|
42000
|
+
});
|
|
42001
|
+
return;
|
|
42002
|
+
}
|
|
42003
|
+
if (pathname === "/authorize") {
|
|
42004
|
+
if (req.method !== "GET") {
|
|
42005
|
+
writeJson(res, 405, { error: "Method not allowed" });
|
|
42006
|
+
return;
|
|
42007
|
+
}
|
|
42008
|
+
const target = new URL(`${authBaseUrl}/oauth/authorize`);
|
|
42009
|
+
const source = new URL(req.url || "/", publicUrl || "http://localhost");
|
|
42010
|
+
target.search = source.search;
|
|
42011
|
+
res.writeHead(302, { location: target.toString() });
|
|
42012
|
+
res.end();
|
|
42013
|
+
return;
|
|
42014
|
+
}
|
|
42015
|
+
if (pathname === "/token") {
|
|
42016
|
+
if (req.method !== "POST") {
|
|
42017
|
+
writeJson(res, 405, { error: "Method not allowed" });
|
|
42018
|
+
return;
|
|
42019
|
+
}
|
|
42020
|
+
if (isRequestTooLarge(req, maxRequestBytes)) {
|
|
42021
|
+
writeJson(res, 413, { error: "Request too large" });
|
|
42022
|
+
return;
|
|
42023
|
+
}
|
|
42024
|
+
await proxyTokenExchange(req, res, authBaseUrl, maxRequestBytes);
|
|
42025
|
+
return;
|
|
42026
|
+
}
|
|
42027
|
+
if (pathname !== "/mcp" && pathname !== "/") {
|
|
41682
42028
|
writeJson(res, 404, { error: "Not found" });
|
|
41683
42029
|
return;
|
|
41684
42030
|
}
|
|
@@ -41742,6 +42088,42 @@ function getPathname(req) {
|
|
|
41742
42088
|
return "/";
|
|
41743
42089
|
}
|
|
41744
42090
|
}
|
|
42091
|
+
function buildOAuthAuthorizationServerMetadata(options) {
|
|
42092
|
+
const endpointBase = options.publicUrl || options.authBaseUrl;
|
|
42093
|
+
return {
|
|
42094
|
+
issuer: endpointBase,
|
|
42095
|
+
authorization_endpoint: `${endpointBase}/authorize`,
|
|
42096
|
+
token_endpoint: `${endpointBase}/token`,
|
|
42097
|
+
registration_endpoint: `${endpointBase}/register`,
|
|
42098
|
+
response_types_supported: ["code"],
|
|
42099
|
+
grant_types_supported: ["authorization_code"],
|
|
42100
|
+
client_id_metadata_document_supported: true,
|
|
42101
|
+
code_challenge_methods_supported: ["S256"],
|
|
42102
|
+
token_endpoint_auth_methods_supported: ["none"],
|
|
42103
|
+
scopes_supported: ["notusos:mcp"]
|
|
42104
|
+
};
|
|
42105
|
+
}
|
|
42106
|
+
function isAllowedConnectorRedirectUri(uri) {
|
|
42107
|
+
try {
|
|
42108
|
+
const parsed = new URL(uri);
|
|
42109
|
+
if (parsed.protocol !== "https:") return isLoopbackCallbackUri(parsed);
|
|
42110
|
+
if (parsed.hostname === "claude.ai" || parsed.hostname === "claude.com") {
|
|
42111
|
+
return parsed.pathname === "/api/mcp/auth_callback";
|
|
42112
|
+
}
|
|
42113
|
+
if (parsed.hostname === "chatgpt.com") {
|
|
42114
|
+
return parsed.pathname === "/connector_platform_oauth_redirect" || /^\/connector\/oauth\/[A-Za-z0-9_-]+$/.test(parsed.pathname);
|
|
42115
|
+
}
|
|
42116
|
+
return false;
|
|
42117
|
+
} catch {
|
|
42118
|
+
return false;
|
|
42119
|
+
}
|
|
42120
|
+
}
|
|
42121
|
+
function isLoopbackCallbackUri(parsed) {
|
|
42122
|
+
if (parsed.protocol !== "http:") return false;
|
|
42123
|
+
if (parsed.hostname !== "127.0.0.1" && parsed.hostname !== "localhost") return false;
|
|
42124
|
+
if (!parsed.port) return false;
|
|
42125
|
+
return parsed.pathname === "/callback";
|
|
42126
|
+
}
|
|
41745
42127
|
function extractBearerToken(req) {
|
|
41746
42128
|
const header = req.headers.authorization;
|
|
41747
42129
|
if (!header) return null;
|
|
@@ -41771,6 +42153,48 @@ function writeJson(res, status, body) {
|
|
|
41771
42153
|
res.writeHead(status, { "content-type": "application/json" });
|
|
41772
42154
|
res.end(JSON.stringify(body));
|
|
41773
42155
|
}
|
|
42156
|
+
async function readRequestBody(req, maxBytes) {
|
|
42157
|
+
const chunks = [];
|
|
42158
|
+
let totalBytes = 0;
|
|
42159
|
+
for await (const chunk of req) {
|
|
42160
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
42161
|
+
totalBytes += buffer.length;
|
|
42162
|
+
if (totalBytes > maxBytes) {
|
|
42163
|
+
throw new Error("Request too large");
|
|
42164
|
+
}
|
|
42165
|
+
chunks.push(buffer);
|
|
42166
|
+
}
|
|
42167
|
+
return Buffer.concat(chunks);
|
|
42168
|
+
}
|
|
42169
|
+
async function readJsonBody(req, maxBytes) {
|
|
42170
|
+
const body = await readRequestBody(req, maxBytes);
|
|
42171
|
+
if (body.length === 0) return {};
|
|
42172
|
+
try {
|
|
42173
|
+
const parsed = JSON.parse(body.toString("utf8"));
|
|
42174
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
42175
|
+
} catch {
|
|
42176
|
+
return {};
|
|
42177
|
+
}
|
|
42178
|
+
}
|
|
42179
|
+
async function proxyTokenExchange(req, res, authBaseUrl, maxBytes) {
|
|
42180
|
+
const body = await readRequestBody(req, maxBytes);
|
|
42181
|
+
const contentTypeHeader = req.headers["content-type"];
|
|
42182
|
+
const contentType = Array.isArray(contentTypeHeader) ? contentTypeHeader[0] : contentTypeHeader;
|
|
42183
|
+
const upstream = await fetch(`${authBaseUrl}/api/mcp/oauth/token`, {
|
|
42184
|
+
method: "POST",
|
|
42185
|
+
headers: {
|
|
42186
|
+
"content-type": contentType || "application/x-www-form-urlencoded",
|
|
42187
|
+
accept: "application/json"
|
|
42188
|
+
},
|
|
42189
|
+
body
|
|
42190
|
+
});
|
|
42191
|
+
const responseBody = await upstream.text();
|
|
42192
|
+
writeCors(res);
|
|
42193
|
+
res.writeHead(upstream.status, {
|
|
42194
|
+
"content-type": upstream.headers.get("content-type") || "application/json"
|
|
42195
|
+
});
|
|
42196
|
+
res.end(responseBody);
|
|
42197
|
+
}
|
|
41774
42198
|
var DEFAULT_PORT, DEFAULT_MAX_REQUEST_BYTES, MCP_METHODS;
|
|
41775
42199
|
var init_remote_server = __esm({
|
|
41776
42200
|
"src/remote-server.ts"() {
|
|
@@ -41804,7 +42228,7 @@ function loadConfig(env = process.env) {
|
|
|
41804
42228
|
// bin/notusos-mcp.ts
|
|
41805
42229
|
init_token_store();
|
|
41806
42230
|
init_logger();
|
|
41807
|
-
var MCP_VERSION = true ? "0.1.
|
|
42231
|
+
var MCP_VERSION = true ? "0.1.18" : "dev";
|
|
41808
42232
|
async function main() {
|
|
41809
42233
|
const [, , sub] = process.argv;
|
|
41810
42234
|
const config2 = loadConfig();
|