If you're building AI agents that interact directly with Solana blockchain data via the Model Context Protocol (MCP), setting up a reliable Solana MCP server is your first big step. This tutorial walks you through the hands-on process of launching a Solana MCP server, configuring the Solana Agent Kit (SAK) to utilize that server, and integrating the Solana MCP Claude AI model. I'll share practical setup commands, configuration examples, and security tips along the way.
The goal? To get you from zero to a working server + agent combo that can fetch and serve Solana on-chain context to AI agents.
For a foundational understanding of MCP server concepts, see base MCP server setup.
Before we start, make sure you have:
Tool versions used in this guide:
| Tool | Version |
|---|---|
| Solana CLI | 1.14.10 |
| Solana Agent Kit | v0.4.2 |
| MCP Server (Node) | v0.7.5 |
| Solana MCP Claude | v0.1.0 (alpha) |
Packages are actively evolving, so always check the latest on GitHub or npm.
Note: Many MCP and agent suites are in early development, so expect some rough edges.
The core MCP server acts as a context provider for your AI agents, querying and caching blockchain data efficiently.
# Clone the MCP server repo (NodeJS version)
git clone https://github.com/mcp-protocol/mcp-node-server.git
cd mcp-node-server
# Install dependencies
yarn install
# Build
npx tsc
Create a .env file with the following minimal settings:
# .env
RPC_URL=https://api.devnet.solana.com
REDIS_URL=redis://localhost:6379
CACHE_TTL=60
# Optional
LOG_LEVEL=info
RPC_URL points to your Solana cluster RPC. Devnet is perfect for testing.
yarn start
You should see logs about successful startup and cache initialization. The server exposes a REST API on port 8080 by default.
Tip: Running Redis locally helps performance when multiple agents hit the server.
Query the status endpoint:
curl http://localhost:8080/status
Expected output:
{
"status": "ok",
"rpc": "https://api.devnet.solana.com"
}
You now have a working MCP server hooked to Solana devnet.
For a deeper dive, refer to the general setup at base MCP server setup.
The Solana Agent Kit (SAK) simplifies spawning on-chain AI agents that consume MCP context.
npm install --save @solana/agent-kit
Here's how to configure SAK to point to your MCP server:
import { Agent } from '@solana/agent-kit';
const agent = new Agent({
mcpServerUrl: 'http://localhost:8080',
solanaRpcUrl: 'https://api.devnet.solana.com',
network: 'devnet',
});
await agent.initialize();
console.log('Agent ready', agent.address);
This snippet sets up your agent to pull context from the MCP server.
SAK defaults to a software wallet-derived private key for dev/testing. In production, use hardware wallets or key management services, because agent wallets can be drained if exposed.
You can also pass explicit session keys with spending limits;
const sessionKey = {
pubkey: '...',
spendingLimit: 0.1, // SOL
expiry: Date.now() + 3600000 // 1 hour
};
agent.addSessionKey(sessionKey);
Session keys allow scoped, temporary permissions for agent interactions.
Solana MCP Claude provides an AI inference layer specifically tuned for Solana agent workflows.
You’ll want to install the client SDK:
npm install --save @solana/mcp-claude
import { ClaudeClient } from '@solana/mcp-claude';
const claude = new ClaudeClient({
serverUrl: 'http://localhost:8080',
model: 'solana-mcp-claude-v0',
});
const prompt = 'Fetch SPL token balances for wallet XYZ';
const response = await claude.generate({ prompt });
console.log('AI Response:', response.text);
The model currently runs inference via the MCP server proxy, querying on-chain data and returning context-sensitive answers.
The Claude integration is experimental — expect longer latencies and occasional failures. Monitor logs closely.
MCP servers can pull on-chain data from Solana through RPC or indexer backends.
Under the hood, MCP server scripts query SPL token accounts:
async function getTokenBalances(wallet: string) {
const accounts = await connection.getParsedTokenAccountsByOwner(
new PublicKey(wallet),
{ programId: TOKEN_PROGRAM_ID }
);
return accounts.value.map(acc => ({
mint: acc.account.data.parsed.info.mint,
amount: acc.account.data.parsed.info.tokenAmount.uiAmount,
}));
}
MCP caches these results to avoid repeated expensive RPC calls.
You can plug DeFi aggregator APIs like Jupiter into MCP server ingestion pipelines for real-time swap data, useful for DeFAI agents.
Check mcp-server-tools-comparison for notes on available indexers and savings.
Here are a few things I learned the hard way when wiring up agent wallets:
For a security checklist, mcp-server-security-best-practices is a solid companion.
.env for correct RPC and Redis URLs.REDIS_URL.mcpServerUrl matches the MCP server endpoint.solana-mcp-claude-v0).See mcp-server-troubleshooting for additional examples.
You’ve now got a baseline Solana MCP server running, connected your Solana Agent Kit to it, and experimented with the Solana MCP Claude AI model. This trio opens doors to powerful AI agents that understand on-chain Solana context in real-time.
Next, I’d recommend:
The tools and frameworks here are young but evolving fast—staying hands-on is the best way to catch all the nuances.
Good luck shipping your Solana AI agents!
For foundational MCP concepts and multi-chain comparisons, check out what is MCP and evm MCP server overview.