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
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ The server provides the following tools for AI agents:
- **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
- **AddFundsTool**: Deposit additional AKT (uakt) into a deployment escrow account
- **GetSDLsTool**: Get a list of available SDLs (from awesome-akash repository)
- **GetSDLTool**: Get a specific SDL by name
- **SendManifestTool**: Send a manifest to a provider
Expand Down Expand Up @@ -154,6 +155,40 @@ Response:
]
```

### AddFundsTool

**Description:**

Deposit additional AKT (uakt) into a deployment escrow account.

**Input Schema:**

```json
{
"address": "akash1...", // Akash account address (string, required)
"dseq": 123456, // Deployment sequence number (integer, required)
"amount": "1000000" // Amount to add in uakt (string, required)
}
```

**Example Usage:**

Request:

```json
{
"address": "akash1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"dseq": 123456,
"amount": "1000000"
}
```

Response:

```json
"...transaction raw log or error message..."
```

## 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,
AddFundsTool,
GetBalancesTool,
} from './tools/index.js';
import type { ToolContext } from './types/index.js';
Expand Down Expand Up @@ -124,6 +125,13 @@ class AkashMCP extends McpServer {
async (args, extra) => UpdateDeploymentTool.handler(args, this.getToolContext())
);

this.tool(
AddFundsTool.name,
AddFundsTool.description,
AddFundsTool.parameters.shape,
async (args, extra) => AddFundsTool.handler(args, this.getToolContext())
);

this.tool(
GetBalancesTool.name,
GetBalancesTool.description,
Expand Down
52 changes: 52 additions & 0 deletions src/tools/add-funds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { z } from 'zod';
import type { ToolDefinition, ToolContext } from '../types/index.js';
import { createOutput } from '../utils/create-output.js';
import { getTypeUrl } from '@akashnetwork/akashjs/build/stargate/index.js';
import { MsgDepositDeployment } from '@akashnetwork/akash-api/akash/deployment/v1beta3';
import { QueryClientImpl, QueryDeploymentRequest } from '@akashnetwork/akash-api/akash/deployment/v1beta3';
import { getRpc } from '@akashnetwork/akashjs/build/rpc/index.js';
import { SERVER_CONFIG } from '../config.js';

const parameters = z.object({
address: z.string().min(1, 'Akash account address is required'),
dseq: z.number().int().positive(),
amount: z.string().min(1, 'Amount of uakt to add is required'),
});

export const AddFundsTool: ToolDefinition<typeof parameters> = {
name: 'add-funds',
description: 'Deposit additional AKT (uakt) into a deployment escrow account.',
parameters,
handler: async (params, context) => {
const { address, dseq, amount } = params;
try {
// 1. Validate deployment exists
const rpc = await getRpc(SERVER_CONFIG.rpcEndpoint);
const deploymentClient = new QueryClientImpl(rpc);
const queryReq = QueryDeploymentRequest.fromPartial({
id: { owner: address, dseq },
});
const deploymentRes = await deploymentClient.Deployment(queryReq);
if (!deploymentRes.deployment) {
return createOutput({ error: `Deployment with owner ${address} and dseq ${dseq} not found.` });
}

// 2. Prepare MsgDepositDeployment
const depositMsg = MsgDepositDeployment.fromPartial({
id: { owner: address, dseq },
amount: { denom: 'uakt', amount: amount.toString() },
depositor: address,
});
const msg = {
typeUrl: getTypeUrl(MsgDepositDeployment),
value: depositMsg,
};

// 3. Sign and broadcast
const tx = await context.client.signAndBroadcast(address, [msg], 'auto');
return createOutput(tx.rawLog);
} catch (error: any) {
return createOutput({ error: error.message || 'Failed to add funds to deployment.' });
}
},
};
1 change: 1 addition & 0 deletions src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ 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 { AddFundsTool } from './add-funds.js';
export { GetBalancesTool } from './get-balances.js';