Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/AkashMCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions src/tools/get-balances.ts
Original file line number Diff line number Diff line change
@@ -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<typeof parameters> = {
name: 'get-akash-balances',
description: 'Get the AKT (uakt) and other balances for a given Akash account address.',
parameters,
handler: async (params: z.infer<typeof parameters>, 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' });
}
},
};
1 change: 1 addition & 0 deletions src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';