uniderp-mcp
Version:
> A plug-and-play MCP tool server to **send ETH**, **transfer ERC-20 tokens**, **deploy tokens**, and **interact with smart contracts** on the **UNICHAIN** — built for **Claude Desktop**, **AI agents**, and **developers.**
51 lines (50 loc) • 1.82 kB
JavaScript
import { z } from "zod";
import { getAccount } from "../config.js";
import { buildTxUrl, checkTransactionHash } from "../util.js";
import { uniswapTrade } from "../functions/uniswapTradeTool.js";
export function registerUniswapTrade(server) {
server.tool("Uniswap_Trade", "💱 Trade tokens using UniSwap (requires wallet check first)", {
inputToken: z
.string()
.describe("Input token address want to trade for output token"),
outputToken: z
.string()
.describe("Output token address received after trading success"),
amount: z.string().describe("Input token amount used for trading"),
}, async ({ inputToken, outputToken, amount }) => {
let txHash = undefined;
try {
const account = await getAccount();
txHash = await uniswapTrade({
account,
inputToken,
outputToken,
amount,
});
const txUrl = await checkTransactionHash(txHash);
return {
content: [
{
type: "text",
text: `Uniswap transaction sent successfully. ${txUrl}`,
url: txUrl,
},
],
};
}
catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
const txUrl = buildTxUrl(txHash);
return {
content: [
{
type: "text",
text: `Failed to trade on uniswap: ${errorMessage}`,
url: txUrl,
},
],
isError: true,
};
}
});
}