@t2000/cli 0.12.0 → 0.12.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/index.js
CHANGED
|
@@ -1710,10 +1710,127 @@ function registerExchange(program2) {
|
|
|
1710
1710
|
}
|
|
1711
1711
|
|
|
1712
1712
|
// src/commands/mcp.ts
|
|
1713
|
+
import { readFile as readFile3, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
1714
|
+
import { join as join4, dirname } from "path";
|
|
1715
|
+
import { homedir as homedir6 } from "os";
|
|
1716
|
+
import { existsSync as existsSync3 } from "fs";
|
|
1717
|
+
var MCP_CONFIG = {
|
|
1718
|
+
command: "t2000",
|
|
1719
|
+
args: ["mcp"]
|
|
1720
|
+
};
|
|
1721
|
+
function getPlatformConfigs() {
|
|
1722
|
+
const home = homedir6();
|
|
1723
|
+
return [
|
|
1724
|
+
{
|
|
1725
|
+
name: "Claude Desktop",
|
|
1726
|
+
path: join4(home, "Library", "Application Support", "Claude", "claude_desktop_config.json")
|
|
1727
|
+
},
|
|
1728
|
+
{
|
|
1729
|
+
name: "Cursor (global)",
|
|
1730
|
+
path: join4(home, ".cursor", "mcp.json")
|
|
1731
|
+
}
|
|
1732
|
+
];
|
|
1733
|
+
}
|
|
1734
|
+
async function readJsonFile(path) {
|
|
1735
|
+
try {
|
|
1736
|
+
const content = await readFile3(path, "utf-8");
|
|
1737
|
+
return JSON.parse(content);
|
|
1738
|
+
} catch {
|
|
1739
|
+
return {};
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
async function writeJsonFile(path, data) {
|
|
1743
|
+
const dir = dirname(path);
|
|
1744
|
+
if (!existsSync3(dir)) {
|
|
1745
|
+
await mkdir3(dir, { recursive: true });
|
|
1746
|
+
}
|
|
1747
|
+
await writeFile3(path, JSON.stringify(data, null, 2) + "\n", "utf-8");
|
|
1748
|
+
}
|
|
1713
1749
|
function registerMcp(program2) {
|
|
1714
|
-
program2.command("mcp").description("
|
|
1715
|
-
|
|
1716
|
-
|
|
1750
|
+
const mcp = program2.command("mcp").description("MCP server for AI platforms");
|
|
1751
|
+
mcp.command("start", { isDefault: true }).description("Start MCP server (stdio transport)").option("--key <path>", "Key file path").action(async (opts) => {
|
|
1752
|
+
let mod;
|
|
1753
|
+
try {
|
|
1754
|
+
mod = await import("./dist-4S75H6SM.js");
|
|
1755
|
+
} catch {
|
|
1756
|
+
console.error(
|
|
1757
|
+
"MCP server not installed. Run:\n npm install -g @t2000/mcp"
|
|
1758
|
+
);
|
|
1759
|
+
process.exit(1);
|
|
1760
|
+
}
|
|
1761
|
+
await mod.startMcpServer({ keyPath: opts.key });
|
|
1762
|
+
});
|
|
1763
|
+
mcp.command("install").description("Auto-configure MCP in Claude Desktop and Cursor").action(async () => {
|
|
1764
|
+
try {
|
|
1765
|
+
const platforms = getPlatformConfigs();
|
|
1766
|
+
const results = [];
|
|
1767
|
+
for (const platform of platforms) {
|
|
1768
|
+
const config = await readJsonFile(platform.path);
|
|
1769
|
+
if (config.mcpServers && config.mcpServers["t2000"]) {
|
|
1770
|
+
results.push({ name: platform.name, status: "exists" });
|
|
1771
|
+
continue;
|
|
1772
|
+
}
|
|
1773
|
+
config.mcpServers = {
|
|
1774
|
+
...config.mcpServers ?? {},
|
|
1775
|
+
t2000: MCP_CONFIG
|
|
1776
|
+
};
|
|
1777
|
+
await writeJsonFile(platform.path, config);
|
|
1778
|
+
results.push({ name: platform.name, status: "added" });
|
|
1779
|
+
}
|
|
1780
|
+
if (isJsonMode()) {
|
|
1781
|
+
printJson({ installed: results });
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
printBlank();
|
|
1785
|
+
for (const r of results) {
|
|
1786
|
+
if (r.status === "exists") {
|
|
1787
|
+
printInfo(`${r.name} already configured`);
|
|
1788
|
+
} else {
|
|
1789
|
+
printSuccess(`${r.name} configured`);
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
printBlank();
|
|
1793
|
+
printInfo("Restart your AI platform to activate.");
|
|
1794
|
+
printInfo(`Then ask: "what's my t2000 balance?"`);
|
|
1795
|
+
printBlank();
|
|
1796
|
+
} catch (error) {
|
|
1797
|
+
handleError(error);
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1800
|
+
mcp.command("uninstall").description("Remove t2000 MCP config from Claude Desktop and Cursor").action(async () => {
|
|
1801
|
+
try {
|
|
1802
|
+
const platforms = getPlatformConfigs();
|
|
1803
|
+
const results = [];
|
|
1804
|
+
for (const platform of platforms) {
|
|
1805
|
+
if (!existsSync3(platform.path)) {
|
|
1806
|
+
results.push({ name: platform.name, removed: false });
|
|
1807
|
+
continue;
|
|
1808
|
+
}
|
|
1809
|
+
const config = await readJsonFile(platform.path);
|
|
1810
|
+
if (!config.mcpServers || !config.mcpServers["t2000"]) {
|
|
1811
|
+
results.push({ name: platform.name, removed: false });
|
|
1812
|
+
continue;
|
|
1813
|
+
}
|
|
1814
|
+
delete config.mcpServers["t2000"];
|
|
1815
|
+
await writeJsonFile(platform.path, config);
|
|
1816
|
+
results.push({ name: platform.name, removed: true });
|
|
1817
|
+
}
|
|
1818
|
+
if (isJsonMode()) {
|
|
1819
|
+
printJson({ uninstalled: results });
|
|
1820
|
+
return;
|
|
1821
|
+
}
|
|
1822
|
+
printBlank();
|
|
1823
|
+
for (const r of results) {
|
|
1824
|
+
if (r.removed) {
|
|
1825
|
+
printSuccess(`${r.name} removed`);
|
|
1826
|
+
} else {
|
|
1827
|
+
printInfo(`${r.name} not configured (skipped)`);
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
printBlank();
|
|
1831
|
+
} catch (error) {
|
|
1832
|
+
handleError(error);
|
|
1833
|
+
}
|
|
1717
1834
|
});
|
|
1718
1835
|
}
|
|
1719
1836
|
|