diff --git a/README.md b/README.md index 1f7a3db..f96b1c4 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,18 @@ Example query to Claude: > "Buy $20 worth of OpenRouter credits." +### check_onchain_reputation + +Checks the CDP onchain reputation of an Ethereum address. + +Parameters: + +- `address`: The Ethereum address to check reputation for + +Example query to Claude: + +> "Check the onchain reputation of 0x1234567890abcdef1234567890abcdef12345678." + ## Security Considerations - The configuration file contains sensitive information (API keys and seed phrases). Ensure it's properly secured and not shared. diff --git a/src/tools/index.ts b/src/tools/index.ts index b254d32..08cf4c9 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -3,6 +3,7 @@ import { erc20BalanceTool, erc20TransferTool } from './erc20/index.js'; import { getMorphoVaultsTool } from './morpho/index.js'; import { getOnrampAssetsTool, onrampTool } from './onramp/index.js'; import { buyOpenRouterCreditsTool } from './open-router/index.js'; +import { checkReputationTool } from './reputation/index.js'; import type { ToolHandler, ToolWithHandler } from './types.js'; export const baseMcpTools: ToolWithHandler[] = [ @@ -13,6 +14,7 @@ export const baseMcpTools: ToolWithHandler[] = [ erc20BalanceTool, erc20TransferTool, buyOpenRouterCreditsTool, + checkReputationTool, ]; export const toolToHandler: Record = baseMcpTools.reduce< diff --git a/src/tools/reputation/handlers.ts b/src/tools/reputation/handlers.ts new file mode 100644 index 0000000..7e19e48 --- /dev/null +++ b/src/tools/reputation/handlers.ts @@ -0,0 +1,22 @@ +import { ExternalAddress } from '@coinbase/coinbase-sdk'; +import { isAddress } from 'viem'; +import type { PublicActions, WalletClient } from 'viem'; +import type { z } from 'zod'; +import { CheckReputationSchema } from './schemas.js'; + +export async function checkReputationHandler( + wallet: WalletClient & PublicActions, + args: z.infer, +): Promise { + const { address } = args; + + // Validate the address format + if (!isAddress(address, { strict: false })) { + throw new Error(`Invalid Ethereum address: ${address}`); + } + + const externalAddress = new ExternalAddress('base-mainnet', address); + const reputation = await externalAddress.reputation(); + + return `Reputation score: ${reputation.score}, Metadata: ${JSON.stringify(reputation.metadata)}`; +} diff --git a/src/tools/reputation/index.ts b/src/tools/reputation/index.ts new file mode 100644 index 0000000..ea8d531 --- /dev/null +++ b/src/tools/reputation/index.ts @@ -0,0 +1,10 @@ +import { generateTool } from '../../utils.js'; +import { checkReputationHandler } from './handlers.js'; +import { CheckReputationSchema } from './schemas.js'; + +export const checkReputationTool = generateTool({ + name: 'check_onchain_reputation', + description: 'Check the onchain reputation of an Ethereum address', + inputSchema: CheckReputationSchema, + toolHandler: checkReputationHandler, +}); diff --git a/src/tools/reputation/schemas.ts b/src/tools/reputation/schemas.ts new file mode 100644 index 0000000..e2849ee --- /dev/null +++ b/src/tools/reputation/schemas.ts @@ -0,0 +1,7 @@ +import { z } from 'zod'; + +export const CheckReputationSchema = z.object({ + address: z + .string() + .describe('The Ethereum address to check CDP onchain reputation for'), +});