cotiv2-mcp
Version:
> A plug-and-play MCP tool server to **send COTI**, **transfer BEP-20 tokens**, **deploy tokens**, and **interact with smart contracts** on the **COTI v2 Network (COTI)** — built for **Claude Desktop**, **AI agents**, and **developers.**
39 lines (38 loc) • 1.45 kB
JavaScript
import fs from "fs-extra";
import path from "path";
import chalk from "chalk";
import { fileURLToPath } from "url";
// ESModule __dirname workaround
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const configPath = path.resolve(__dirname, "..", "config.json");
// Configure
export const configureStorage = async (config) => {
if (!fs.existsSync(configPath)) {
console.log(chalk.yellow("⚠️ Storage config not found. Creating a new one..."));
// Create a default configuration object
const defaultConfig = {};
// Write the default configuration to the file
await fs.writeJSON(configPath, defaultConfig, { spaces: 2 });
}
const jsonData = fs.readFileSync(configPath, "utf8");
let data = JSON.parse(jsonData);
data = {
...data,
...config,
};
await fs.writeJSON(configPath, data, { spaces: 2 });
return true;
};
export const getStorage = async () => {
if (!fs.existsSync(configPath)) {
console.log(chalk.yellow("⚠️ Storage config not found. Creating a new one..."));
// Create a default configuration object
const defaultConfig = {};
// Write the default configuration to the file
await fs.writeJSON(configPath, defaultConfig, { spaces: 2 });
}
const jsonData = fs.readFileSync(configPath, "utf8");
let data = JSON.parse(jsonData);
return data;
};