@t2000/cli 0.11.0 → 0.12.1
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/README.md +10 -1
- package/dist/chunk-D4HDZEJT.js +37 -0
- package/dist/chunk-D4HDZEJT.js.map +1 -0
- package/dist/dist-QVEFT4TY.js +21540 -0
- package/dist/dist-QVEFT4TY.js.map +1 -0
- package/dist/index.js +127 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import "./chunk-D4HDZEJT.js";
|
|
2
3
|
|
|
3
4
|
// src/program.ts
|
|
4
5
|
import { Command } from "commander";
|
|
@@ -1708,6 +1709,131 @@ function registerExchange(program2) {
|
|
|
1708
1709
|
});
|
|
1709
1710
|
}
|
|
1710
1711
|
|
|
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
|
+
}
|
|
1749
|
+
function registerMcp(program2) {
|
|
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-QVEFT4TY.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
|
+
}
|
|
1834
|
+
});
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1711
1837
|
// src/program.ts
|
|
1712
1838
|
var require2 = createRequire(import.meta.url);
|
|
1713
1839
|
var { version: CLI_VERSION } = require2("../package.json");
|
|
@@ -1742,6 +1868,7 @@ function createProgram() {
|
|
|
1742
1868
|
registerEarn(program2);
|
|
1743
1869
|
registerRebalance(program2);
|
|
1744
1870
|
registerExchange(program2);
|
|
1871
|
+
registerMcp(program2);
|
|
1745
1872
|
return program2;
|
|
1746
1873
|
}
|
|
1747
1874
|
|