@hasna/mcps 0.0.20 → 0.0.22
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/bin/index.js +3961 -3256
- package/bin/mcp.js +65 -74
- package/dist/index.js +57 -59
- package/dist/mcp/index.js +65 -74
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -60,13 +60,13 @@ import { join, relative } from "path";
|
|
|
60
60
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
|
|
61
61
|
import { homedir as homedir2 } from "os";
|
|
62
62
|
import { join as join2 } from "path";
|
|
63
|
-
import { readdirSync as
|
|
64
|
-
import { join as
|
|
63
|
+
import { readdirSync as readdirSync3, existsSync as existsSync6 } from "fs";
|
|
64
|
+
import { join as join6 } from "path";
|
|
65
|
+
import { homedir as homedir5 } from "os";
|
|
65
66
|
import { homedir as homedir3 } from "os";
|
|
66
|
-
import {
|
|
67
|
-
import { join as
|
|
68
|
-
import {
|
|
69
|
-
import { homedir as homedir5, platform } from "os";
|
|
67
|
+
import { join as join3 } from "path";
|
|
68
|
+
import { join as join5, dirname } from "path";
|
|
69
|
+
import { homedir as homedir4, platform } from "os";
|
|
70
70
|
function __accessProp2(key) {
|
|
71
71
|
return this[key];
|
|
72
72
|
}
|
|
@@ -937,11 +937,11 @@ function isSyncExcludedTable(table) {
|
|
|
937
937
|
return SYNC_EXCLUDED_TABLE_PATTERNS.some((p) => p.test(table));
|
|
938
938
|
}
|
|
939
939
|
function discoverServices() {
|
|
940
|
-
const dataDir =
|
|
941
|
-
if (!
|
|
940
|
+
const dataDir = join6(homedir5(), ".hasna");
|
|
941
|
+
if (!existsSync6(dataDir))
|
|
942
942
|
return [];
|
|
943
943
|
try {
|
|
944
|
-
const entries =
|
|
944
|
+
const entries = readdirSync3(dataDir, { withFileTypes: true });
|
|
945
945
|
return entries.filter((e) => {
|
|
946
946
|
if (!e.isDirectory())
|
|
947
947
|
return false;
|
|
@@ -953,30 +953,30 @@ function discoverServices() {
|
|
|
953
953
|
return [];
|
|
954
954
|
}
|
|
955
955
|
}
|
|
956
|
-
function
|
|
956
|
+
function discoverSyncableServices2() {
|
|
957
957
|
const local = discoverServices();
|
|
958
958
|
const pgSet = new Set(KNOWN_PG_SERVICES);
|
|
959
959
|
return local.filter((s) => pgSet.has(s));
|
|
960
960
|
}
|
|
961
961
|
function getServiceDbPath(service) {
|
|
962
|
-
const dataDir =
|
|
963
|
-
if (!
|
|
962
|
+
const dataDir = join6(homedir5(), ".hasna", service);
|
|
963
|
+
if (!existsSync6(dataDir))
|
|
964
964
|
return null;
|
|
965
965
|
const candidates = [
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
966
|
+
join6(dataDir, `${service}.db`),
|
|
967
|
+
join6(dataDir, "data.db"),
|
|
968
|
+
join6(dataDir, "database.db")
|
|
969
969
|
];
|
|
970
970
|
try {
|
|
971
|
-
const files =
|
|
971
|
+
const files = readdirSync3(dataDir);
|
|
972
972
|
for (const f of files) {
|
|
973
973
|
if (f.endsWith(".db") && !f.endsWith("-wal") && !f.endsWith("-shm")) {
|
|
974
|
-
candidates.push(
|
|
974
|
+
candidates.push(join6(dataDir, f));
|
|
975
975
|
}
|
|
976
976
|
}
|
|
977
977
|
} catch {}
|
|
978
978
|
for (const p of candidates) {
|
|
979
|
-
if (
|
|
979
|
+
if (existsSync6(p))
|
|
980
980
|
return p;
|
|
981
981
|
}
|
|
982
982
|
return null;
|
|
@@ -9353,7 +9353,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
9353
9353
|
__export2(exports_discover, {
|
|
9354
9354
|
isSyncExcludedTable: () => isSyncExcludedTable,
|
|
9355
9355
|
getServiceDbPath: () => getServiceDbPath,
|
|
9356
|
-
discoverSyncableServices: () =>
|
|
9356
|
+
discoverSyncableServices: () => discoverSyncableServices2,
|
|
9357
9357
|
discoverServices: () => discoverServices,
|
|
9358
9358
|
SYNC_EXCLUDED_TABLE_PATTERNS: () => SYNC_EXCLUDED_TABLE_PATTERNS,
|
|
9359
9359
|
KNOWN_PG_SERVICES: () => KNOWN_PG_SERVICES
|
|
@@ -9408,15 +9408,13 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
9408
9408
|
init_config();
|
|
9409
9409
|
init_config();
|
|
9410
9410
|
init_dotfile();
|
|
9411
|
-
init_adapter();
|
|
9412
9411
|
init_config();
|
|
9413
|
-
|
|
9414
|
-
AUTO_SYNC_CONFIG_PATH = join4(homedir4(), ".hasna", "cloud", "config.json");
|
|
9412
|
+
AUTO_SYNC_CONFIG_PATH = join3(homedir3(), ".hasna", "cloud", "config.json");
|
|
9415
9413
|
init_config();
|
|
9416
9414
|
init_adapter();
|
|
9417
9415
|
init_dotfile();
|
|
9418
9416
|
init_config();
|
|
9419
|
-
CONFIG_DIR2 =
|
|
9417
|
+
CONFIG_DIR2 = join5(homedir4(), ".hasna", "cloud");
|
|
9420
9418
|
init_adapter();
|
|
9421
9419
|
init_config();
|
|
9422
9420
|
init_discover();
|
|
@@ -9430,17 +9428,17 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
9430
9428
|
});
|
|
9431
9429
|
|
|
9432
9430
|
// src/lib/config.ts
|
|
9433
|
-
import { join as
|
|
9431
|
+
import { join as join4 } from "path";
|
|
9434
9432
|
import { homedir as homedir6 } from "os";
|
|
9435
|
-
import { existsSync as
|
|
9433
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, cpSync } from "fs";
|
|
9436
9434
|
function resolveMcpsDir() {
|
|
9437
9435
|
const explicit = process.env.HASNA_MCPS_DATA_DIR ?? process.env.MCPS_DATA_DIR;
|
|
9438
9436
|
if (explicit)
|
|
9439
9437
|
return explicit;
|
|
9440
|
-
const newDir =
|
|
9441
|
-
const oldDir =
|
|
9442
|
-
if (!
|
|
9443
|
-
mkdirSync3(
|
|
9438
|
+
const newDir = join4(homedir6(), ".hasna", "mcps");
|
|
9439
|
+
const oldDir = join4(homedir6(), ".mcps");
|
|
9440
|
+
if (!existsSync3(newDir) && existsSync3(oldDir)) {
|
|
9441
|
+
mkdirSync3(join4(homedir6(), ".hasna"), { recursive: true });
|
|
9444
9442
|
cpSync(oldDir, newDir, { recursive: true });
|
|
9445
9443
|
}
|
|
9446
9444
|
return newDir;
|
|
@@ -9448,7 +9446,7 @@ function resolveMcpsDir() {
|
|
|
9448
9446
|
var MCPS_DIR, DB_PATH, REGISTRY_API_URL = "https://registry.modelcontextprotocol.io/v0/servers", TOOL_PREFIX_SEPARATOR = "__";
|
|
9449
9447
|
var init_config2 = __esm(() => {
|
|
9450
9448
|
MCPS_DIR = resolveMcpsDir();
|
|
9451
|
-
DB_PATH = process.env.HASNA_MCPS_DB_PATH ?? process.env.MCPS_DB_PATH ??
|
|
9449
|
+
DB_PATH = process.env.HASNA_MCPS_DB_PATH ?? process.env.MCPS_DB_PATH ?? join4(MCPS_DIR, "registry.db");
|
|
9452
9450
|
});
|
|
9453
9451
|
|
|
9454
9452
|
// src/lib/provider-profile-seeds.ts
|
|
@@ -17005,10 +17003,10 @@ __export(exports_sources, {
|
|
|
17005
17003
|
clearCache: () => clearCache,
|
|
17006
17004
|
addSource: () => addSource
|
|
17007
17005
|
});
|
|
17008
|
-
import { mkdirSync as mkdirSync6, existsSync as existsSync7, readFileSync as readFileSync3, writeFileSync as writeFileSync2, readdirSync as
|
|
17009
|
-
import { join as
|
|
17006
|
+
import { mkdirSync as mkdirSync6, existsSync as existsSync7, readFileSync as readFileSync3, writeFileSync as writeFileSync2, readdirSync as readdirSync2, unlinkSync } from "fs";
|
|
17007
|
+
import { join as join9 } from "path";
|
|
17010
17008
|
function getCacheFile(sourceId) {
|
|
17011
|
-
return
|
|
17009
|
+
return join9(CACHE_DIR, `${sourceId}.json`);
|
|
17012
17010
|
}
|
|
17013
17011
|
function readCache(sourceId) {
|
|
17014
17012
|
try {
|
|
@@ -17031,13 +17029,13 @@ function clearCache(sourceId) {
|
|
|
17031
17029
|
try {
|
|
17032
17030
|
if (!existsSync7(CACHE_DIR))
|
|
17033
17031
|
return;
|
|
17034
|
-
const files =
|
|
17032
|
+
const files = readdirSync2(CACHE_DIR);
|
|
17035
17033
|
for (const file of files) {
|
|
17036
17034
|
if (!file.endsWith(".json"))
|
|
17037
17035
|
continue;
|
|
17038
17036
|
if (!sourceId || file.startsWith(`${sourceId}.`)) {
|
|
17039
17037
|
try {
|
|
17040
|
-
unlinkSync(
|
|
17038
|
+
unlinkSync(join9(CACHE_DIR, file));
|
|
17041
17039
|
} catch {}
|
|
17042
17040
|
}
|
|
17043
17041
|
}
|
|
@@ -17283,7 +17281,7 @@ var CACHE_DIR, DEFAULT_TTL_MS;
|
|
|
17283
17281
|
var init_sources = __esm(() => {
|
|
17284
17282
|
init_db();
|
|
17285
17283
|
init_config2();
|
|
17286
|
-
CACHE_DIR =
|
|
17284
|
+
CACHE_DIR = join9(MCPS_DIR, "cache");
|
|
17287
17285
|
DEFAULT_TTL_MS = 10 * 60 * 1000;
|
|
17288
17286
|
});
|
|
17289
17287
|
|
|
@@ -17292,7 +17290,7 @@ init_db();
|
|
|
17292
17290
|
|
|
17293
17291
|
// src/lib/credentials.ts
|
|
17294
17292
|
init_config2();
|
|
17295
|
-
import { existsSync as
|
|
17293
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
|
|
17296
17294
|
import { join as join7 } from "path";
|
|
17297
17295
|
|
|
17298
17296
|
class CredentialReferenceError extends Error {
|
|
@@ -17392,7 +17390,7 @@ function redactServerCredentials(server) {
|
|
|
17392
17390
|
}
|
|
17393
17391
|
function readLocalVault() {
|
|
17394
17392
|
const path = process.env.HASNA_MCPS_CREDENTIAL_VAULT_PATH ?? join7(MCPS_DIR, "credentials.local.json");
|
|
17395
|
-
if (!
|
|
17393
|
+
if (!existsSync5(path))
|
|
17396
17394
|
return {};
|
|
17397
17395
|
const parsed = JSON.parse(readFileSync2(path, "utf-8"));
|
|
17398
17396
|
if (!isRecord(parsed))
|
|
@@ -26577,8 +26575,8 @@ init_provider_profile_seeds();
|
|
|
26577
26575
|
|
|
26578
26576
|
// src/lib/install.ts
|
|
26579
26577
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
26580
|
-
import { existsSync as
|
|
26581
|
-
import { join as
|
|
26578
|
+
import { existsSync as existsSync9, readFileSync as readFileSync4, writeFileSync as writeFileSync3, mkdirSync as mkdirSync7 } from "fs";
|
|
26579
|
+
import { join as join10 } from "path";
|
|
26582
26580
|
import { homedir as homedir8 } from "os";
|
|
26583
26581
|
function installToClaude(entry) {
|
|
26584
26582
|
try {
|
|
@@ -26602,9 +26600,9 @@ function installToClaude(entry) {
|
|
|
26602
26600
|
}
|
|
26603
26601
|
function installToCodex(entry) {
|
|
26604
26602
|
try {
|
|
26605
|
-
const configDir =
|
|
26606
|
-
const configPath =
|
|
26607
|
-
if (!
|
|
26603
|
+
const configDir = join10(homedir8(), ".codex");
|
|
26604
|
+
const configPath = join10(configDir, "config.toml");
|
|
26605
|
+
if (!existsSync9(configDir)) {
|
|
26608
26606
|
mkdirSync7(configDir, { recursive: true });
|
|
26609
26607
|
}
|
|
26610
26608
|
const block = `
|
|
@@ -26612,7 +26610,7 @@ function installToCodex(entry) {
|
|
|
26612
26610
|
` + `command = ${JSON.stringify(entry.command)}
|
|
26613
26611
|
` + `args = [${entry.args.map((a) => JSON.stringify(a)).join(", ")}]
|
|
26614
26612
|
`;
|
|
26615
|
-
const existing =
|
|
26613
|
+
const existing = existsSync9(configPath) ? readFileSync4(configPath, "utf-8") : "";
|
|
26616
26614
|
if (existing.includes(`[mcp_servers.${entry.id}]`)) {
|
|
26617
26615
|
return { agent: "codex", success: true };
|
|
26618
26616
|
}
|
|
@@ -26624,13 +26622,13 @@ function installToCodex(entry) {
|
|
|
26624
26622
|
}
|
|
26625
26623
|
function installToGemini(entry) {
|
|
26626
26624
|
try {
|
|
26627
|
-
const configDir =
|
|
26628
|
-
const configPath =
|
|
26629
|
-
if (!
|
|
26625
|
+
const configDir = join10(homedir8(), ".gemini");
|
|
26626
|
+
const configPath = join10(configDir, "settings.json");
|
|
26627
|
+
if (!existsSync9(configDir)) {
|
|
26630
26628
|
mkdirSync7(configDir, { recursive: true });
|
|
26631
26629
|
}
|
|
26632
26630
|
let settings = {};
|
|
26633
|
-
if (
|
|
26631
|
+
if (existsSync9(configPath)) {
|
|
26634
26632
|
settings = JSON.parse(readFileSync4(configPath, "utf-8"));
|
|
26635
26633
|
}
|
|
26636
26634
|
if (!settings.mcpServers)
|
|
@@ -26893,11 +26891,11 @@ function seedDefaultMachines() {
|
|
|
26893
26891
|
// src/lib/fleet.ts
|
|
26894
26892
|
init_config2();
|
|
26895
26893
|
import { spawn as spawn2 } from "child_process";
|
|
26896
|
-
import { existsSync as
|
|
26897
|
-
import { join as
|
|
26894
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync8, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
26895
|
+
import { join as join11 } from "path";
|
|
26898
26896
|
var NPM_SEARCH_URL = "https://registry.npmjs.org/-/v1/search";
|
|
26899
26897
|
var NPM_REGISTRY_URL = "https://registry.npmjs.org";
|
|
26900
|
-
var CATALOG_CACHE_PATH =
|
|
26898
|
+
var CATALOG_CACHE_PATH = join11(MCPS_DIR, "cache", "hasna-catalog.json");
|
|
26901
26899
|
var DEFAULT_CATALOG_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
26902
26900
|
var DEFAULT_REMOTE_TIMEOUT_MS = 180000;
|
|
26903
26901
|
var DEFAULT_HANDSHAKE_TIMEOUT_MS = 2500;
|
|
@@ -26907,7 +26905,7 @@ function normalizeQueryList(values) {
|
|
|
26907
26905
|
}
|
|
26908
26906
|
function readCatalogCache(maxAgeMs) {
|
|
26909
26907
|
try {
|
|
26910
|
-
if (!
|
|
26908
|
+
if (!existsSync10(CATALOG_CACHE_PATH))
|
|
26911
26909
|
return null;
|
|
26912
26910
|
const parsed = JSON.parse(readFileSync5(CATALOG_CACHE_PATH, "utf-8"));
|
|
26913
26911
|
if (!parsed.cachedAt || !Array.isArray(parsed.entries))
|
|
@@ -26921,7 +26919,7 @@ function readCatalogCache(maxAgeMs) {
|
|
|
26921
26919
|
}
|
|
26922
26920
|
function writeCatalogCache(entries) {
|
|
26923
26921
|
try {
|
|
26924
|
-
mkdirSync8(
|
|
26922
|
+
mkdirSync8(join11(MCPS_DIR, "cache"), { recursive: true });
|
|
26925
26923
|
writeFileSync4(CATALOG_CACHE_PATH, JSON.stringify({ cachedAt: Date.now(), entries }, null, 2), "utf-8");
|
|
26926
26924
|
} catch {}
|
|
26927
26925
|
}
|
|
@@ -27592,19 +27590,19 @@ async function runFleetInstall(options = {}, dependencies = {}) {
|
|
|
27592
27590
|
}));
|
|
27593
27591
|
}
|
|
27594
27592
|
// src/lib/version.ts
|
|
27595
|
-
import { existsSync as
|
|
27596
|
-
import { dirname as dirname3, join as
|
|
27593
|
+
import { existsSync as existsSync11, readFileSync as readFileSync6 } from "fs";
|
|
27594
|
+
import { dirname as dirname3, join as join12 } from "path";
|
|
27597
27595
|
import { fileURLToPath } from "url";
|
|
27598
27596
|
var FALLBACK_VERSION = "0.0.1";
|
|
27599
27597
|
function readPackageVersion(moduleUrl, fallback = FALLBACK_VERSION) {
|
|
27600
27598
|
const baseDir = dirname3(fileURLToPath(moduleUrl));
|
|
27601
27599
|
const candidates = [
|
|
27602
|
-
|
|
27603
|
-
|
|
27604
|
-
|
|
27600
|
+
join12(baseDir, "..", "..", "package.json"),
|
|
27601
|
+
join12(baseDir, "..", "package.json"),
|
|
27602
|
+
join12(baseDir, "package.json")
|
|
27605
27603
|
];
|
|
27606
27604
|
for (const candidate of candidates) {
|
|
27607
|
-
if (!
|
|
27605
|
+
if (!existsSync11(candidate))
|
|
27608
27606
|
continue;
|
|
27609
27607
|
try {
|
|
27610
27608
|
const pkg = JSON.parse(readFileSync6(candidate, "utf-8"));
|