@solana-agent-kit/adapter-mcp v2.0.6
Solana Agent Kit MCP Server Utility
This utility provides a framework for creating a Model Context Protocol (MCP) server to handle protocol operations on the Solana blockchain using the Solana Agent Kit.
Features
- Supports all actions from the Solana Agent Kit
- MCP server implementation for standardized interactions
- Environment-based configuration
Prerequisites
- Node.js (v16 or higher recommended)
- pnpm, yarn, or npm
- Solana wallet with private key
- Solana RPC URL
Installation
pnpm install
Configuration
- Configure the
claude_desktop_config.json
file by editing theenv
fields.
SOLANA_PRIVATE_KEY=your_private_key_here
RPC_URL=your_solana_rpc_url_here
- Change the Claude Desktop MCP server settings:
For MacOS:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
For Windows:
code $env:AppData\Claude\claude_desktop_config.json
The final configuration should look like the following (replace the path with your absolute project path):
{
"mcpServers": {
"agent-kit": {
"command": "node",
"env": {
"RPC_URL": "your_solana_rpc_url_here",
"SOLANA_PRIVATE_KEY": "your_private_key_here"
},
"args": [
"/ABSOLUTE/PATH/TO/YOUR/MCP/PROJECT/FILE" // e.g /Users/username/Projects/solana-agent-kit-mcp-server/index.js
]
}
}
}
Note: Make sure to restart Claude Desktop after updating the configuration and building the project.
Building the Project
To build the project, run:
pnpm run build
This will compile the TypeScript code and set the appropriate permissions for the executable.
Project Structure
src/
- Source code directorysrc/index.ts
- Main entry point implementing the MCP server
Usage Examples
Starting the MCP Server
To start the MCP server, use the following command:
Installation
First you'll need to create a node project
pnpm init
Then install the solana-agent-kit, desired plugins and the mcp utility
pnpm add solana-agent-kit @solana-agent-kit/plugin-token @solana-agent-kit/adapter-mcp dotenv
Usage
import { SolanaAgentKit, KeypairWallet } from "solana-agent-kit";
import { startMcpServer } from '@solana-agent-kit/adapter-mcp'
import TokenPlugin from '@solana-agent-kit/plugin-token'
import * as dotenv from "dotenv";
dotenv.config();
const wallet = new KeypairWallet(process.env.SOLANA_PRIVATE_KEY)
const agent = new SolanaAgentKit(
wallet,
process.env.RPC_URL,
{
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
},
).use(TokenPlugin);
const finalActions = {
BALANCE_ACTION: agent.actions.find((action) => action.name === "BALANCE_ACTION")!,
TOKEN_BALANCE_ACTION: agent.actions.find((action) => action.name === "TOKEN_BALANCE_ACTION")!,
GET_WALLET_ADDRESS_ACTION: agent.actions.find((action) => action.name === "GET_WALLET_ADDRESS_ACTION")!,
};
startMcpServer(finalActions, agent, { name: "solana-agent", version: "0.0.1" });
This will start the server once you start up Claude. You can add actions by simply adding them to the finalActions
object.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. Refer to CONTRIBUTING.md for detailed guidelines on how to contribute to this project.
21 days ago
1 month ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago