feat: migrate to @akashnetwork/chain-sdk#14
feat: migrate to @akashnetwork/chain-sdk#14wonderwomancode wants to merge 9 commits intoakash-network:mainfrom
Conversation
BREAKING CHANGE: Migrates from deprecated @akashnetwork/akashjs and @akashnetwork/akash-api packages to the new @akashnetwork/chain-sdk package. Key changes: - Update dependencies to use @akashnetwork/chain-sdk@1.0.0-alpha.18 - Require Node.js >= 22.0.0 - Update all tools to use new chain SDK API: - deployment v1beta4 (was v1beta3) - market v1beta5 (was v1beta4) - escrow v1 - provider v1beta4 (was v1beta3) - cert v1 - Update type definitions for new SDK interfaces - Use createChainNodeSDK for queries and transactions - Use createStargateClient for signing operations - Update field names: version -> hash for deployments - Add bseq field to BidID and LeaseID - Update Lease.id (was Lease.leaseId) and Bid.id (was Bid.bidId) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Set up vitest testing framework with coverage support - Add unit tests for create-output utility function - Add tests for tool handlers: - get-account-addr: metadata and handler tests - get-bids: parameter validation and handler tests - get-balances: parameter validation and handler tests - create-deployment: parameter validation and error handling tests - create-lease: parameter validation and handler tests - close-deployment: parameter validation and handler tests - All 65 tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
This is a major change so I don't know if you want to adopt this now, but it looked like it was already being used in the console and the two js libs that are currently being used were both deprecated. I also added some tests. Let me know if you have any suggested changes and I'm happy to hit them up. |
- Add exec-command tool for running shell commands in containers - Add get-logs tool for retrieving container logs via WebSocket - Add certificate management tools (revoke, revoke-all, regenerate) - Add deployment audit scripts and documentation - Improve send-manifest with better mTLS handling - Add reloadCertificate method for dynamic cert refresh 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- New MCP tool to check if a provider is safe for a deployment - Prevents NAT hairpin issues by blocking proxy's provider for backend services - Parameters: provider (address), serviceType (proxy|backend|standalone) - Returns safety status with detailed reason Usage: mcp__akash__check-provider-safety with provider and serviceType 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Increased gasMultiplier from default 1.3 to 2.0 - Resolves transaction code 11 (out of gas) errors when updating deployments - The default multiplier was insufficient for deployment update transactions Fixes alternatefutures/infrastructure-proxy proxy update issue Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- get-deployment now includes: - Resource totals (CPU, memory, storage, GPU) calculated from groups - Lease information with provider details (hostUri, attributes, info) - Lease pricing information - Created height for timeline tracking - get-bids now includes: - Provider information (hostUri, attributes, info) for each bid - Helps users make better decisions when selecting bids These changes align with the context displayed in the Akash Console, providing more visibility into deployments and provider capabilities. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added comprehensive documentation of the context field enhancements made to get-deployment and get-bids tools. This includes resource totals, lease information, provider details, and timeline tracking. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Code Review - High Signal Issues FoundThis PR has 5 HIGH SIGNAL issues that require fixes before merge. All are compilation/runtime failures or security vulnerabilities. 🔴 CRITICAL SECURITY: TLS Certificate Verification DisabledFile: src/tools/send-manifest.ts (Line 79) The code disables TLS certificate verification, enabling man-in-the-middle attacks: const agent = new https.Agent({
cert: certificate.cert,
key: certificate.privateKey,
rejectUnauthorized: false, // ❌ REGRESSION - was true in original
servername: 'localhost',
});Why it's critical:
Fix: Change 🔴 CRITICAL: Mnemonic Validation Completely RemovedFile: src/config.ts (Line 7) The validateMnemonic() function and all validation logic were removed: Original: validateMnemonic(rawMnemonic); // 50+ lines of validationNew: mnemonic: process.env.AKASH_MNEMONIC || '', // Silent default to empty stringWhy it's critical:
Fix: Keep mnemonic validation or at minimum validate that AKASH_MNEMONIC is not empty. 🟠 HIGH: Unused Import - Will Fail LintingFile: src/tools/get-sdl.ts (Line 3)
import { ResourceDefinition } from '../types/index.js'; // ❌ UnusedThe handler doesn't reference this import anywhere. This will fail TypeScript strict mode and linting. Fix: Remove the unused import on line 3. 🟠 HIGH: Unused Function ParameterFile: src/utils/load-certificate.ts (Line 48) The export async function loadCertificate(
wallet: DirectSecp256k1HdWallet,
client: StargateTxClient, // ❌ Never referenced
chainSDK?: ChainNodeSDK
): Promise<CertificatePem> {
// Function never uses 'client'
}```
**Why it's high:**
- Parameter added to signature but has no effect
- Misleads callers into thinking `client` is required for something
- Function uses `chainSDK` instead
**Fix:** Remove the unused `client` parameter from the function signature and all callers.
---
### 🟠 HIGH: Unsafe Certificate Reload Logic
**File:** src/AkashMCP.ts (Lines 42-53)
In `getToolContext()`, if `loadCertificateFromDisk()` returns null, the certificate is not updated and could be stale:
```typescript
const freshCert = loadCertificateFromDisk(accounts[0].address);
if (freshCert) {
this.certificate = freshCert; // Only updates if found
}
return {
// ...
certificate: this.certificate\!, // Could be stale/null
};```
**Why it's high:**
- Intent is to "always read certificate fresh from disk" but logic doesn't ensure it
- If disk certificate is missing, stale certificate is returned
- Could cause 401 errors in provider calls after cert rotation
**Fix:** Either throw error if fresh certificate can't be loaded, or explicitly document and handle the null case.
---
## Summary Table
| Issue | File | Severity | Type | Must Fix |
|-------|------|----------|------|----------|
| TLS verification disabled | send-manifest.ts:79 | CRITICAL | Security | ✅ YES |
| Mnemonic validation removed | config.ts:7 | CRITICAL | Logic | ✅ YES |
| ResourceDefinition unused import | get-sdl.ts:3 | HIGH | Linting | ✅ YES |
| Unused client parameter | load-certificate.ts:48 | HIGH | Type Safety | ✅ YES |
| Unsafe cert reload | AkashMCP.ts:42-53 | HIGH | Logic | ✅ YES |
All 5 issues must be resolved before this PR can be merged. Please address each and let me know when ready for re-review. |
|
Thanks for the review. A few comments on it:
I will create a new PR for it after this is merged. Regarding the PR, i plan to merge it but it needs a cleanup:
Separately, chain-sdk now recommends JWT over mTLS for provider auth (mTLS is marked legacy in the SDK docs). Will handle that migration in a follow-up PR. |
Summary
This PR migrates the Akash MCP server from the deprecated
@akashnetwork/akashjsand@akashnetwork/akash-apipackages to the new@akashnetwork/chain-sdkpackage.Breaking Changes
Changes
@akashnetwork/chain-sdk@1.0.0-alpha.18createChainNodeSDKfor queries and transactionscreateStargateClientfor signing operationsversion→hashfor deploymentsLease.leaseId→Lease.idBid.bidId→Bid.idbseqfield to BidID and LeaseIDMotivation
The old packages (
@akashnetwork/akashjsand@akashnetwork/akash-api) are deprecated and the mainnet has migrated to newer API versions. This migration ensures compatibility with the current Akash mainnet.Test plan
npm run build🤖 Generated with Claude Code