UniversalDeFi AI

Official
import { Tool } from "@modelcontextprotocol/sdk/types.js"; import { callContractHandler, deployContractHandler, getWalletDetailsHandler, transferNativeTokenHandler } from "./handlers.js"; const getWalletDetailsTool: Tool = { name: "get_wallet_details", description: "Get the details of the pre-configured wallet including the chain, address, and balance", inputSchema: { type: "object", properties: { }, }, }; const transferNativeTokenTool: Tool = { name: "transfer_native_token", description: "Transfer a native token to a specified address", inputSchema: { type: "object", properties: { toAddress: { type: "string", description: "The address to transfer the native token to", }, amount: { type: "string", description: "The amount of native token to transfer", }, }, }, }; const deployContractTool: Tool = { name: "deploy_contract", description: "Deploy a contract from source code, and return the contract address, deployment hash, and transaction url", inputSchema: { type: "object", properties: { sourceCode: { type: "string", description: "The source code of the contract to deploy", }, contractName: { type: "string", description: "The name of the contract to deploy", }, constructorArgs: { type: "array", description: "The constructor arguments for the contract", items: { oneOf: [ { type: "string", pattern: "^0x[a-fA-F0-9]{40}$" }, // ethAddressSchema { type: "string", pattern: "^\\d+$" }, // uint256Schema string { type: "integer" }, // uint256Schema bigint { type: "string", pattern: "^0x[a-fA-F0-9]+$" }, // hexStringSchema { type: "string" }, // normal string { type: "boolean" }, // boolean { type: "array", items: { $ref: "#/properties/constructorArgs/items" } // recursive reference for nested arrays } ] } }, }, }, }; const callContractTool: Tool = { name: "call_contract", description: "Call a function on a contract", inputSchema: { type: "object", properties: { contractAddress: { type: "string", description: "The address of the contract", }, functionName: { type: "string", description: "The name of the function to call", }, abi: { type: "string", description: "The ABI of the contract", }, args: { type: "array", description: "The arguments for the function to call", items: { oneOf: [ { type: "string", pattern: "^0x[a-fA-F0-9]{40}$" }, // ethAddressSchema { type: "string", pattern: "^\\d+$" }, // uint256Schema string { type: "integer" }, // uint256Schema bigint { type: "string", pattern: "^0x[a-fA-F0-9]+$" }, // hexStringSchema { type: "string" }, // normal string { type: "boolean" }, // boolean { type: "array", items: { $ref: "#/properties/args/items" } // recursive reference for nested arrays } ] } }, }, }, }; export const tools: Tool[] = [getWalletDetailsTool, transferNativeTokenTool, deployContractTool, callContractTool]; export const toolToHandler: Record<string, Function> = { "get_wallet_details": getWalletDetailsHandler, "transfer_native_token": transferNativeTokenHandler, "deploy_contract": deployContractHandler, "call_contract": callContractHandler, };