diff --git a/README.md b/README.md index 96447ce..61bbdbb 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ The server exposes a standard MCP interface that can be used by AI models to int The server provides the following tools for AI agents: - **GetAccountAddrTool**: Retrieve your Akash account address +- **GetBalancesTool**: Get the AKT (uakt) and other balances for a given Akash account address - **GetBidsTool**: Get bids for deployments - **CreateDeploymentTool**: Create a new deployment on Akash Network - **GetSDLsTool**: Get a list of available SDLs (from awesome-akash repository) @@ -117,6 +118,42 @@ The server provides the following tools for AI agents: - **GetServicesTool**: Get information about active services - **UpdateDeploymentTool**: Update a deployment on Akash Network +### GetBalancesTool + +**Description:** + +Get the AKT (uakt) and other balances for a given Akash account address. + +**Input Schema:** + +```json +{ + "address": "akash1..." // Akash account address (string, required) +} +``` + +**Example Usage:** + +Request: + +```json +{ + "address": "akash1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +} +``` + +Response: + +```json +[ + { + "denom": "uakt", + "amount": "123456789" + } + // ...other tokens if present +] +``` + ## Development ### Linting and Formatting diff --git a/src/AkashMCP.ts b/src/AkashMCP.ts index df052ab..3f4c9b9 100644 --- a/src/AkashMCP.ts +++ b/src/AkashMCP.ts @@ -13,6 +13,7 @@ import { GetServicesTool, CreateDeploymentTool, UpdateDeploymentTool, + GetBalancesTool, } from './tools/index.js'; import type { ToolContext } from './types/index.js'; import type { CertificatePem } from '@akashnetwork/akashjs/build/certificates/certificate-manager/CertificateManager.js'; @@ -122,6 +123,13 @@ class AkashMCP extends McpServer { UpdateDeploymentTool.parameters.shape, async (args, extra) => UpdateDeploymentTool.handler(args, this.getToolContext()) ); + + this.tool( + GetBalancesTool.name, + GetBalancesTool.description, + GetBalancesTool.parameters.shape, + async (args, extra) => GetBalancesTool.handler(args, this.getToolContext()) + ); } public isInitialized(): boolean { return this.wallet !== null && this.client !== null && this.certificate !== null; diff --git a/src/tools/get-balances.ts b/src/tools/get-balances.ts new file mode 100644 index 0000000..8ee1d50 --- /dev/null +++ b/src/tools/get-balances.ts @@ -0,0 +1,21 @@ +import { z } from 'zod'; +import type { ToolDefinition, ToolContext } from '../types/index.js'; +import { createOutput } from '../utils/create-output.js'; + +const parameters = z.object({ + address: z.string().min(1, 'Akash account address is required'), +}); + +export const GetBalancesTool: ToolDefinition = { + name: 'get-akash-balances', + description: 'Get the AKT (uakt) and other balances for a given Akash account address.', + parameters, + handler: async (params: z.infer, context: ToolContext) => { + try { + const balances = await context.client.getAllBalances(params.address); + return createOutput(balances); + } catch (error: any) { + return createOutput({ error: error.message || 'Failed to fetch balances' }); + } + }, +}; diff --git a/src/tools/index.ts b/src/tools/index.ts index 3fe016e..fc182f2 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -7,3 +7,4 @@ export { GetBidsTool } from './get-bids.js'; export { CreateLeaseTool } from './create-lease.js'; export { GetAccountAddrTool } from './get-account-addr.js'; export { UpdateDeploymentTool } from './update-deployment.js'; +export { GetBalancesTool } from './get-balances.js';