Solana Agent Kit is an open-source toolkit that connects AI agents to Solana blockchain protocols. It enables AI agents (regardless of the underlying model) to perform over 60 Solana actions including token trading, launching tokens, lending assets, sending airdrops, executing cross-chain operations, and more.
npm install solana-agent-kit
import { SolanaAgentKit, createSolanaTools } from "solana-agent-kit";
// Initialize with private key and optional RPC URL
const agent = new SolanaAgentKit(
"your-wallet-private-key-as-base58",
"https://api.mainnet-beta.solana.com",
{ OPENAI_API_KEY: "your-openai-api-key" } // optional config
);
// Create LangChain tools
const tools = createSolanaTools(agent);
const result = await agent.deployToken(
"my ai token", // name
"uri", // uri
"token", // symbol
9, // decimals
{
mintAuthority: null, // by default, deployer account
freezeAuthority: null, // by default, deployer account
updateAuthority: undefined, // by default, deployer account
isMutable: false // by default, true
},
1000000 // initial supply
);
console.log("Token Mint Address:", result.mint.toString());
const result = await agent.delpoyToken2022(
"my ai token 2022", // name
"uri", // uri
"token2022", // symbol
9, // decimals
{
mintAuthority: null, // by default, deployer account
freezeAuthority: null, // by default, deployer account
updateAuthority: undefined, // by default, deployer account
isMutable: false // by default, true
},
1000000 // initial supply
);
console.log("Token2022 Mint Address:", result.mint.toString());
import { PublicKey } from "@solana/web3.js";
const signature = await agent.trade(
new PublicKey("target-token-mint"),
100, // amount
new PublicKey("source-token-mint"),
300 // 3% slippage
);
const { signature } = await agent.closeEmptyTokenAccounts();
const collection = await agent.deployCollection({
name: "My NFT Collection",
uri: "https://arweave.net/metadata.json",
royaltyBasisPoints: 500, // 5%
creators: [
{
address: "creator-wallet-address",
percentage: 100,
},
],
});
const isDevnet = false; // (Optional) if not present TX takes place in Mainnet
const priorityFeeParam = 1000000; // (Optional) if not present the default priority fee will be 50000
const collectionOpts = {
collectionName: "My Collection",
collectionSymbol: "MYCOLL",
collectionDescription: "A description of my collection",
mainImageUrl: "https://example.com/image.png"
};
const result = await agent.create3LandCollection(
collectionOpts,
isDevnet,
priorityFeeParam
);
const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
const withPool = true; // (Optional) only present if NFT will be created with a Liquidity Pool
const priorityFeeParam = 1000000; // (Optional) if not present the default priority fee will be 50000
const collectionAccount = "collection-account-hash";
const createItemOptions = {
itemName: "My NFT",
sellerFee: 500, // 5%
itemAmount: 100, // total items to be created
itemSymbol: "MYNFT",
itemDescription: "Description of my NFT",
traits: [
{ trait_type: "Background", value: "Blue" },
],
price: 100000000, // 0.1 SOL
splHash: "spl-token-hash", // present if listing is on a specific SPL token
poolName: "My Pool", // Only present if "withPool" is true
mainImageUrl: "https://example.com/nft.png",
};
const result = await agent.create3LandNft(
collectionAccount,
createItemOptions,
isDevnet,
withPool,
priorityFeeParam
);
const signature = await agent.stake(
1 // amount in SOL to stake
);
const signature = await agent.restake(
1 // amount in SOL to stake
);
const signature = await agent.lendAssets(
100 // amount of USDC to lend
);
import { PublicKey } from "@solana/web3.js";
console.log(
"~Airdrop cost estimate:",
getAirdropCostEstimate(
1000, // recipients
30_000 // priority fee in lamports
)
);
const signature = await agent.sendCompressedAirdrop(
new PublicKey("JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN"), // mint
42, // amount per recipient
[
new PublicKey("1nc1nerator11111111111111111111111111111111"),
// ... add more recipients
],
30_000 // priority fee in lamports
);
const chains = await agent.getWormholeSupportedChains();
console.log("Supported Chains:", chains);
const result = await agent.createWrappedToken({
destinationChain: "BaseSepolia", // Target chain
tokenAddress: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", // Original token address
network: "Testnet", // Network type (Testnet or Mainnet)
});
console.log("Wrapped Token Result:", result);
const transfer = await agent.cctpTransfer({
destinationChain: "Base Sepolia", // Target chain
transferAmount: "1", // Amount to transfer
network: "Testnet", // Network type (Testnet or Mainnet)
});
console.log("Transfer result:", transfer);
const transfer = await agent.tokenTransfer({
destinationChain: "Base Sepolia", // Target chain
tokenAddress: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", // Original token address
network: "Testnet", // Network type (Testnet or Mainnet)
});
// Check supported chains
const chains = await agent.getDebridgeSupportedChains();
console.log("Available chains:", chains);
// Create bridge order (SOL -> ETH)
const orderInput = {
srcChainId: "7565164", // Solana
srcChainTokenIn: "11111111111111111111111111111111", // Native SOL
srcChainTokenInAmount: "1000000000", // 1 SOL (9 decimals)
dstChainId: "1", // Ethereum
dstChainTokenOut: "0x0000000000000000000000000000000000000000", // ETH
dstChainTokenOutRecipient: "0x23C279e58ddF1018C3B9D0C224534fA2a83fb1d2" // ETH recipient
};
const order = await agent.createDebridgeOrder(orderInput);
console.log("Order created:", order);
// Execute the bridge order
const signature = await agent.executeDebridgeOrder(order.tx.data);
console.log("Bridge transaction sent:", signature);
import { PublicKey } from "@solana/web3.js";
// Open a long position
const signature = await agent.openPerpTradeLong({
price: 300, // $300 SOL Max price
collateralAmount: 10, // 10 jitoSOL in
collateralMint: new PublicKey("J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn"), // jitoSOL
leverage: 50000, // x5
tradeMint: new PublicKey("J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn"), // jitoSOL
slippage: 0.3, // 0.3%
});
// Close a long position
const signature = await agent.closePerpTradeLong({
price: 200, // $200 SOL price
tradeMint: new PublicKey("J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn"), // jitoSOL
});
// Create a Drift account
const result = await agent.createDriftUserAccount();
// Create a Drift vault
const signature = await agent.createDriftVault({
name: "my-drift-vault",
marketName: "USDC-SPOT",
redeemPeriod: 1, // in days
maxTokens: 100000, // in token units e.g 100000 USDC
minDepositAmount: 5, // in token units e.g 5 USDC
managementFee: 1, // 1%
profitShare: 10, // 10%
hurdleRate: 5, // 5%
permissioned: false, // public vault or whitelist
});
// Deposit into a Drift vault
const signature = await agent.depositIntoDriftVault(100, "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU");
// Deposit into your Drift account
const {txSig} = await agent.depositToDriftUserAccount(100, "USDC");
// Check if agent has a Drift account
const {hasAccount, account} = await agent.doesUserHaveDriftAccount();
const priceFeedID = await agent.getPythPriceFeedID("SOL");
const price = await agent.getPythPrice(priceFeedID);
console.log("Price of SOL/USD:", price);
const priceData = await agent.getTokenPriceData([
"So11111111111111111111111111111111111111112", // SOL
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" // USDC
]);
console.log("Token prices:", priceData);
// Get trending tokens
const trendingTokens = await agent.getTrendingTokens();
console.log("Trending tokens:", trendingTokens);
// Get latest pools
const latestPools = await agent.getLatestPools();
console.log("Latest pools:", latestPools);
// Get token information
const tokenInfo = await agent.getTokenInfo("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
console.log("Token info:", tokenInfo);
// Get top gainers
const topGainers = await agent.getTopGainers("24h", "all");
console.log("Top gainers:", topGainers);
// Get supported tokens
const tokens = await agent.getTokens();
console.log("Supported tokens:", tokens);
// Get DEX quote
const quote = await agent.getQuote(
"So11111111111111111111111111111111111111112", // fromTokenAddress (SOL)
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // toTokenAddress (USDC)
"1000000000", // amount in base units
"0.5" // slippage (optional, default 0.5%)
);
console.log("Swap quote:", quote);
// Execute token swap
const swapResult = await agent.executeSwap({
fromTokenAddress: "So11111111111111111111111111111111111111112", // SOL
toTokenAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC
amount: "1000000000", // amount in base units
autoSlippage: true, // optional, use auto slippage
slippage: "0.1", // optional, custom slippage (0.1%)
maxAutoSlippageBps: "100", // optional, max auto slippage in basis points
userAddress: "signer-public-key" // optional, user wallet address
});
console.log("Swap executed:", swapResult);
// Get Sanctum LST Price
const prices = await agent.getSanctumLSTPrice([
"bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1",
"7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn"
]);
console.log('prices', prices);
// Add Liquidity to Sanctum Infinite Pool
const txId = await agent.addSanctumLiquidity(
"So11111111111111111111111111111111111111112",
"1000000000",
"1100000000",
5000
);
console.log('txId', txId);
// Swap Sanctum LST
const txId = await agent.swapSanctumLST(
"So11111111111111111111111111111111111111112",
"1000000000",
"1100000000",
5000,
"7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn"
);
console.log('txId', txId);
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "solana-agent-kit" '{"command":"npx","args":["solana-agent-kit"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"solana-agent-kit": {
"command": "npx",
"args": [
"solana-agent-kit"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"solana-agent-kit": {
"command": "npx",
"args": [
"solana-agent-kit"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect