@notus-os/mcp 0.1.15 → 0.1.16
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 +327 -21
- 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({
|
|
@@ -41387,6 +41517,74 @@ var init_tools = __esm({
|
|
|
41387
41517
|
}
|
|
41388
41518
|
});
|
|
41389
41519
|
|
|
41520
|
+
// src/tool-result.ts
|
|
41521
|
+
function formatToolResult(result, maxChars = DEFAULT_MAX_TOOL_RESULT_CHARS) {
|
|
41522
|
+
const full = stringify(result);
|
|
41523
|
+
if (full.length <= maxChars) return full;
|
|
41524
|
+
const compacted = {
|
|
41525
|
+
_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.",
|
|
41526
|
+
_original_chars: full.length,
|
|
41527
|
+
result: compactValue(result)
|
|
41528
|
+
};
|
|
41529
|
+
const compact2 = stringify(compacted);
|
|
41530
|
+
if (compact2.length <= maxChars) return compact2;
|
|
41531
|
+
return `${compact2.slice(0, maxChars)}
|
|
41532
|
+
|
|
41533
|
+
...TRUNCATED_BY_NOTUSOS_MCP (${compact2.length} compacted chars; narrow the request and retry)`;
|
|
41534
|
+
}
|
|
41535
|
+
function stringify(value) {
|
|
41536
|
+
return JSON.stringify(value, null, 2);
|
|
41537
|
+
}
|
|
41538
|
+
function compactValue(value, depth = 0) {
|
|
41539
|
+
if (value === null || typeof value === "number" || typeof value === "boolean") return value;
|
|
41540
|
+
if (typeof value === "string") {
|
|
41541
|
+
if (value.length <= MAX_STRING_CHARS) return value;
|
|
41542
|
+
return `${value.slice(0, MAX_STRING_CHARS)}...TRUNCATED_STRING(${value.length} chars)`;
|
|
41543
|
+
}
|
|
41544
|
+
if (Array.isArray(value)) {
|
|
41545
|
+
return {
|
|
41546
|
+
_type: "array",
|
|
41547
|
+
_total: value.length,
|
|
41548
|
+
_shown: Math.min(value.length, ARRAY_PREVIEW_ITEMS),
|
|
41549
|
+
items: value.slice(0, ARRAY_PREVIEW_ITEMS).map((entry) => compactValue(entry, depth + 1)),
|
|
41550
|
+
...value.length > ARRAY_PREVIEW_ITEMS ? { _has_more: true } : {}
|
|
41551
|
+
};
|
|
41552
|
+
}
|
|
41553
|
+
if (typeof value === "object") {
|
|
41554
|
+
const entries = Object.entries(value);
|
|
41555
|
+
const shownEntries = entries.slice(0, MAX_OBJECT_KEYS);
|
|
41556
|
+
const output = {};
|
|
41557
|
+
for (const [key, entry] of shownEntries) {
|
|
41558
|
+
output[key] = depth >= 6 ? summarizeLeaf(entry) : compactValue(entry, depth + 1);
|
|
41559
|
+
}
|
|
41560
|
+
if (entries.length > MAX_OBJECT_KEYS) {
|
|
41561
|
+
output._truncated_keys = entries.length - MAX_OBJECT_KEYS;
|
|
41562
|
+
}
|
|
41563
|
+
return output;
|
|
41564
|
+
}
|
|
41565
|
+
return String(value);
|
|
41566
|
+
}
|
|
41567
|
+
function summarizeLeaf(value) {
|
|
41568
|
+
if (Array.isArray(value)) return { _type: "array", _total: value.length };
|
|
41569
|
+
if (typeof value === "string") {
|
|
41570
|
+
return value.length <= 500 ? value : `${value.slice(0, 500)}...TRUNCATED_STRING(${value.length} chars)`;
|
|
41571
|
+
}
|
|
41572
|
+
if (value && typeof value === "object") {
|
|
41573
|
+
return { _type: "object", _keys: Object.keys(value).length };
|
|
41574
|
+
}
|
|
41575
|
+
return value;
|
|
41576
|
+
}
|
|
41577
|
+
var DEFAULT_MAX_TOOL_RESULT_CHARS, ARRAY_PREVIEW_ITEMS, MAX_STRING_CHARS, MAX_OBJECT_KEYS;
|
|
41578
|
+
var init_tool_result = __esm({
|
|
41579
|
+
"src/tool-result.ts"() {
|
|
41580
|
+
"use strict";
|
|
41581
|
+
DEFAULT_MAX_TOOL_RESULT_CHARS = 6e4;
|
|
41582
|
+
ARRAY_PREVIEW_ITEMS = 25;
|
|
41583
|
+
MAX_STRING_CHARS = 8e3;
|
|
41584
|
+
MAX_OBJECT_KEYS = 80;
|
|
41585
|
+
}
|
|
41586
|
+
});
|
|
41587
|
+
|
|
41390
41588
|
// src/tools/permissions.ts
|
|
41391
41589
|
function getToolAccess(name) {
|
|
41392
41590
|
if (ADMIN_TOOL_NAMES.has(name)) return "admin";
|
|
@@ -41529,7 +41727,7 @@ async function createMcpProtocolServer(opts) {
|
|
|
41529
41727
|
const result = await tool.handler(parsed.data, ctx);
|
|
41530
41728
|
return {
|
|
41531
41729
|
content: [
|
|
41532
|
-
{ type: "text", text:
|
|
41730
|
+
{ type: "text", text: formatToolResult(result) }
|
|
41533
41731
|
]
|
|
41534
41732
|
};
|
|
41535
41733
|
} catch (err) {
|
|
@@ -41634,16 +41832,18 @@ var init_server3 = __esm({
|
|
|
41634
41832
|
init_api_client();
|
|
41635
41833
|
init_session();
|
|
41636
41834
|
init_tools();
|
|
41835
|
+
init_tool_result();
|
|
41637
41836
|
init_permissions();
|
|
41638
41837
|
init_logger();
|
|
41639
41838
|
SERVER_NAME = "notusos-mcp";
|
|
41640
|
-
SERVER_VERSION = true ? "0.1.
|
|
41839
|
+
SERVER_VERSION = true ? "0.1.16" : "dev";
|
|
41641
41840
|
}
|
|
41642
41841
|
});
|
|
41643
41842
|
|
|
41644
41843
|
// src/remote-server.ts
|
|
41645
41844
|
var remote_server_exports = {};
|
|
41646
41845
|
__export(remote_server_exports, {
|
|
41846
|
+
buildOAuthAuthorizationServerMetadata: () => buildOAuthAuthorizationServerMetadata,
|
|
41647
41847
|
getPathname: () => getPathname,
|
|
41648
41848
|
isAllowedMcpMethod: () => isAllowedMcpMethod,
|
|
41649
41849
|
isRequestTooLarge: () => isRequestTooLarge,
|
|
@@ -41678,7 +41878,57 @@ async function startRemoteServer(config2) {
|
|
|
41678
41878
|
});
|
|
41679
41879
|
return;
|
|
41680
41880
|
}
|
|
41681
|
-
if (pathname
|
|
41881
|
+
if (pathname === "/.well-known/oauth-authorization-server") {
|
|
41882
|
+
writeJson(res, 200, buildOAuthAuthorizationServerMetadata({ authBaseUrl, publicUrl }));
|
|
41883
|
+
return;
|
|
41884
|
+
}
|
|
41885
|
+
if (pathname === "/register") {
|
|
41886
|
+
if (req.method !== "POST") {
|
|
41887
|
+
writeJson(res, 405, { error: "Method not allowed" });
|
|
41888
|
+
return;
|
|
41889
|
+
}
|
|
41890
|
+
if (isRequestTooLarge(req, maxRequestBytes)) {
|
|
41891
|
+
writeJson(res, 413, { error: "Request too large" });
|
|
41892
|
+
return;
|
|
41893
|
+
}
|
|
41894
|
+
const body = await readJsonBody(req, maxRequestBytes);
|
|
41895
|
+
const requestedName = typeof body.client_name === "string" ? body.client_name : "Claude";
|
|
41896
|
+
writeJson(res, 201, {
|
|
41897
|
+
client_id: "https://claude.ai",
|
|
41898
|
+
client_name: requestedName,
|
|
41899
|
+
redirect_uris: ["https://claude.ai/api/mcp/auth_callback"],
|
|
41900
|
+
grant_types: ["authorization_code"],
|
|
41901
|
+
response_types: ["code"],
|
|
41902
|
+
token_endpoint_auth_method: "none",
|
|
41903
|
+
client_id_issued_at: Math.floor(Date.now() / 1e3)
|
|
41904
|
+
});
|
|
41905
|
+
return;
|
|
41906
|
+
}
|
|
41907
|
+
if (pathname === "/authorize") {
|
|
41908
|
+
if (req.method !== "GET") {
|
|
41909
|
+
writeJson(res, 405, { error: "Method not allowed" });
|
|
41910
|
+
return;
|
|
41911
|
+
}
|
|
41912
|
+
const target = new URL(`${authBaseUrl}/oauth/authorize`);
|
|
41913
|
+
const source = new URL(req.url || "/", publicUrl || "http://localhost");
|
|
41914
|
+
target.search = source.search;
|
|
41915
|
+
res.writeHead(302, { location: target.toString() });
|
|
41916
|
+
res.end();
|
|
41917
|
+
return;
|
|
41918
|
+
}
|
|
41919
|
+
if (pathname === "/token") {
|
|
41920
|
+
if (req.method !== "POST") {
|
|
41921
|
+
writeJson(res, 405, { error: "Method not allowed" });
|
|
41922
|
+
return;
|
|
41923
|
+
}
|
|
41924
|
+
if (isRequestTooLarge(req, maxRequestBytes)) {
|
|
41925
|
+
writeJson(res, 413, { error: "Request too large" });
|
|
41926
|
+
return;
|
|
41927
|
+
}
|
|
41928
|
+
await proxyTokenExchange(req, res, authBaseUrl, maxRequestBytes);
|
|
41929
|
+
return;
|
|
41930
|
+
}
|
|
41931
|
+
if (pathname !== "/mcp" && pathname !== "/") {
|
|
41682
41932
|
writeJson(res, 404, { error: "Not found" });
|
|
41683
41933
|
return;
|
|
41684
41934
|
}
|
|
@@ -41742,6 +41992,20 @@ function getPathname(req) {
|
|
|
41742
41992
|
return "/";
|
|
41743
41993
|
}
|
|
41744
41994
|
}
|
|
41995
|
+
function buildOAuthAuthorizationServerMetadata(options) {
|
|
41996
|
+
const endpointBase = options.publicUrl || options.authBaseUrl;
|
|
41997
|
+
return {
|
|
41998
|
+
issuer: endpointBase,
|
|
41999
|
+
authorization_endpoint: `${endpointBase}/authorize`,
|
|
42000
|
+
token_endpoint: `${endpointBase}/token`,
|
|
42001
|
+
registration_endpoint: `${endpointBase}/register`,
|
|
42002
|
+
response_types_supported: ["code"],
|
|
42003
|
+
grant_types_supported: ["authorization_code"],
|
|
42004
|
+
code_challenge_methods_supported: ["S256"],
|
|
42005
|
+
token_endpoint_auth_methods_supported: ["none"],
|
|
42006
|
+
scopes_supported: ["notusos:mcp"]
|
|
42007
|
+
};
|
|
42008
|
+
}
|
|
41745
42009
|
function extractBearerToken(req) {
|
|
41746
42010
|
const header = req.headers.authorization;
|
|
41747
42011
|
if (!header) return null;
|
|
@@ -41771,6 +42035,48 @@ function writeJson(res, status, body) {
|
|
|
41771
42035
|
res.writeHead(status, { "content-type": "application/json" });
|
|
41772
42036
|
res.end(JSON.stringify(body));
|
|
41773
42037
|
}
|
|
42038
|
+
async function readRequestBody(req, maxBytes) {
|
|
42039
|
+
const chunks = [];
|
|
42040
|
+
let totalBytes = 0;
|
|
42041
|
+
for await (const chunk of req) {
|
|
42042
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
42043
|
+
totalBytes += buffer.length;
|
|
42044
|
+
if (totalBytes > maxBytes) {
|
|
42045
|
+
throw new Error("Request too large");
|
|
42046
|
+
}
|
|
42047
|
+
chunks.push(buffer);
|
|
42048
|
+
}
|
|
42049
|
+
return Buffer.concat(chunks);
|
|
42050
|
+
}
|
|
42051
|
+
async function readJsonBody(req, maxBytes) {
|
|
42052
|
+
const body = await readRequestBody(req, maxBytes);
|
|
42053
|
+
if (body.length === 0) return {};
|
|
42054
|
+
try {
|
|
42055
|
+
const parsed = JSON.parse(body.toString("utf8"));
|
|
42056
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
42057
|
+
} catch {
|
|
42058
|
+
return {};
|
|
42059
|
+
}
|
|
42060
|
+
}
|
|
42061
|
+
async function proxyTokenExchange(req, res, authBaseUrl, maxBytes) {
|
|
42062
|
+
const body = await readRequestBody(req, maxBytes);
|
|
42063
|
+
const contentTypeHeader = req.headers["content-type"];
|
|
42064
|
+
const contentType = Array.isArray(contentTypeHeader) ? contentTypeHeader[0] : contentTypeHeader;
|
|
42065
|
+
const upstream = await fetch(`${authBaseUrl}/api/mcp/oauth/token`, {
|
|
42066
|
+
method: "POST",
|
|
42067
|
+
headers: {
|
|
42068
|
+
"content-type": contentType || "application/x-www-form-urlencoded",
|
|
42069
|
+
accept: "application/json"
|
|
42070
|
+
},
|
|
42071
|
+
body
|
|
42072
|
+
});
|
|
42073
|
+
const responseBody = await upstream.text();
|
|
42074
|
+
writeCors(res);
|
|
42075
|
+
res.writeHead(upstream.status, {
|
|
42076
|
+
"content-type": upstream.headers.get("content-type") || "application/json"
|
|
42077
|
+
});
|
|
42078
|
+
res.end(responseBody);
|
|
42079
|
+
}
|
|
41774
42080
|
var DEFAULT_PORT, DEFAULT_MAX_REQUEST_BYTES, MCP_METHODS;
|
|
41775
42081
|
var init_remote_server = __esm({
|
|
41776
42082
|
"src/remote-server.ts"() {
|
|
@@ -41804,7 +42110,7 @@ function loadConfig(env = process.env) {
|
|
|
41804
42110
|
// bin/notusos-mcp.ts
|
|
41805
42111
|
init_token_store();
|
|
41806
42112
|
init_logger();
|
|
41807
|
-
var MCP_VERSION = true ? "0.1.
|
|
42113
|
+
var MCP_VERSION = true ? "0.1.16" : "dev";
|
|
41808
42114
|
async function main() {
|
|
41809
42115
|
const [, , sub] = process.argv;
|
|
41810
42116
|
const config2 = loadConfig();
|