> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendai.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Adapter

> Create a Model Context Protocol server for the Solana Agent Kit

# MCP Adapter

The `@solana-agent-kit/adapter-mcp` adapter provides a framework for creating a Model Context Protocol (MCP) server to handle protocol operations on the Solana blockchain using the Solana Agent Kit.

## Installation

Install the adapter alongside the core Solana Agent Kit and your desired plugins:

```bash theme={"system"}
npm install solana-agent-kit @solana-agent-kit/adapter-mcp @solana-agent-kit/plugin-token dotenv
```

## Features

* Supports all actions from the Solana Agent Kit
* MCP server implementation for standardized interactions with Claude Desktop
* Environment-based configuration
* Selective action exposure

## Prerequisites

* Node.js (v16 or higher recommended)
* pnpm, yarn, or npm
* Solana wallet with private key
* Solana RPC URL
* Claude Desktop application

## Basic Setup

Create a new project for your MCP server:

```bash theme={"system"}
mkdir solana-agent-mcp
cd solana-agent-mcp
npm init -y
```

Install the required dependencies:

```bash theme={"system"}
npm install solana-agent-kit @solana-agent-kit/adapter-mcp @solana-agent-kit/plugin-token dotenv
```

Create a `.env` file in your project root:

```env theme={"system"}
SOLANA_PRIVATE_KEY=your_private_key_here
RPC_URL=your_solana_rpc_url_here
OPENAI_API_KEY=your_openai_api_key_here
```

Create an `index.js` file with the following code:

```javascript theme={"system"}
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";

// Load environment variables
dotenv.config();

// Initialize wallet with private key from environment
const wallet = new KeypairWallet(process.env.SOLANA_PRIVATE_KEY);

// Create agent with plugin
const agent = new SolanaAgentKit(
  wallet,
  process.env.RPC_URL,
  {
    OPENAI_API_KEY: process.env.OPENAI_API_KEY,
  }
).use(TokenPlugin);

// Select which actions to expose to the MCP server
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"),
};

// Start the MCP server
startMcpServer(finalActions, agent, { name: "solana-agent", version: "0.0.1" });
```

Update your `package.json` to add the `type` field:

```json theme={"system"}
{
  "name": "solana-agent-mcp",
  "version": "1.0.0",
  "type": "module",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  }
}
```

## Claude Desktop Configuration

1. Open the Claude Desktop configuration file:

   **MacOS:**

   ```bash theme={"system"}
   code ~/Library/Application\ Support/Claude/claude_desktop_config.json
   ```

   **Windows:**

   ```bash theme={"system"}
   code $env:AppData\Claude\claude_desktop_config.json
   ```

2. Add your MCP server configuration:

   ```json theme={"system"}
   {
       "mcpServers": {
           "agent-kit": {
               "command": "node",
               "env": {
                   "RPC_URL": "your_solana_rpc_url_here",
                   "SOLANA_PRIVATE_KEY": "your_private_key_here",
                   "OPENAI_API_KEY": "your_openai_api_key_here"
               },
               "args": [
                   "/ABSOLUTE/PATH/TO/YOUR/solana-agent-mcp/index.js"
               ]
           }
       }
   }
   ```

   Replace the path with the absolute path to your `index.js` file.

3. Restart Claude Desktop after updating the configuration.

## Customizing Available Actions

You can customize which actions are available to Claude by modifying the `finalActions` object:

```javascript theme={"system"}
// Example of adding more actions from different plugins
const finalActions = {
  // Basic wallet actions
  BALANCE_ACTION: agent.actions.find((action) => action.name === "BALANCE_ACTION"),
  GET_WALLET_ADDRESS_ACTION: agent.actions.find((action) => action.name === "GET_WALLET_ADDRESS_ACTION"),
  
  // Token actions
  TOKEN_BALANCE_ACTION: agent.actions.find((action) => action.name === "TOKEN_BALANCE_ACTION"),
  TRANSFER_ACTION: agent.actions.find((action) => action.name === "TRANSFER_ACTION"),
  
  // Trading actions
  TRADE_ACTION: agent.actions.find((action) => action.name === "TRADE_ACTION"),
};
```

## Testing the Integration

1. Start your MCP server (if running manually):
   ```bash theme={"system"}
   node index.js
   ```

2. Open Claude Desktop and ask questions about Solana, like:
   * "What's my SOL balance?"
   * "Show me my token balances"
   * "What's my wallet address?"

Claude will use your MCP server to interact with the Solana blockchain and provide responses based on the available actions.

For more detailed information, please refer to the full documentation at [docs.sendai.fun](https://docs.sendai.fun).

## Solana Agent Kit MCP Server

[![npm version](https://badge.fury.io/js/solana-mcp.svg)](https://www.npmjs.com/package/solana-mcp)
[![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)

A Model Context Protocol (MCP) server that provides onchain tools for Claude AI, allowing it to interact with the Solana blockchain through a standardized interface. This implementation is based on the Solana Agent Kit and enables AI agents to perform blockchain operations seamlessly.

### Overview

This MCP server extends Claude's capabilities by providing tools to:

* Interact with Solana blockchain
* Execute transactions
* Query account information
* Manage Solana wallets

The server implements the Model Context Protocol specification to standardize blockchain interactions for AI agents.

### Prerequisites

* Node.js (v16 or higher)
* pnpm (recommended), npm, or yarn
* Solana wallet with private key
* Solana RPC URL (mainnet, testnet, or devnet)

### Installation

#### Option 1: Quick Install (Recommended)

```bash theme={"system"}
# Download the installation script
curl -fsSL https://raw.githubusercontent.com/sendaifun/solana-mcp/main/scripts/install.sh -o solana-mcp-install.sh

# Make it executable and run
chmod +x solana-mcp-install.sh && ./solana-mcp-install.sh --backup
```

This will start an interactive installation process that will guide you through:

* Setting up Node.js if needed
* Configuring your Solana RPC URL and private key
* Setting up the Claude Desktop integration

#### Option 2: Install from npm (Recommended for clients like Cursor/Cline)

```bash theme={"system"}
# Install globally
npm install -g solana-mcp

# Or install locally in your project
npm install solana-mcp
```

#### Option 3: Build from Source

1. Clone this repository:

```bash theme={"system"}
git clone https://github.com/sendaifun/solana-mcp
cd solana-mcp
```

2. Install dependencies:

```bash theme={"system"}
pnpm install
```

3. Build the project:

```bash theme={"system"}
pnpm run build
```

### Configuration

#### Environment Setup

Create a `.env` file with your credentials:

```env theme={"system"}
# Solana Configuration
SOLANA_PRIVATE_KEY=your_private_key_here
RPC_URL=your_solana_rpc_url_here
OPENAI_API_KEY=your_openai_api_key # OPTIONAL
```

#### Integration with Claude Desktop

To add this MCP server to Claude Desktop, follow these steps:

1. **Locate the Claude Desktop Configuration File**
   * macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
   * Windows: `%APPDATA%\Claude\claude_desktop_config.json`
   * Linux: `~/.config/Claude/claude_desktop_config.json`

2. **Add the Configuration**
   Create or edit the configuration file and add the following JSON:

   If you installed via npm (Option 1):

   ```json theme={"system"}
   {
     "mcpServers": {
       "solana-mcp": {
         "command": "npx",
         "args": ["solana-mcp"],
         "env": {
           "RPC_URL": "your_solana_rpc_url_here",
           "SOLANA_PRIVATE_KEY": "your_private_key_here",
           "OPENAI_API_KEY": "your_openai_api_key"  // OPTIONAL
         },
         "disabled": false,
         "autoApprove": []
       }
     }
   }
   ```

   If you built from source (Option 2):

   ```json theme={"system"}
   {
     "mcpServers": {
       "solana-mcp": {
         "command": "node",
         "args": ["/path/to/solana-mcp/build/index.js"],
         "env": {
           "RPC_URL": "your_solana_rpc_url_here",
           "SOLANA_PRIVATE_KEY": "your_private_key_here",
           "OPENAI_API_KEY": "your_openai_api_key"  // OPTIONAL
         },
         "disabled": false,
         "autoApprove": []
       }
     }
   }
   ```

3. **Restart Claude Desktop**
   After making these changes, restart Claude Desktop for the configuration to take effect.

### Project Structure

```
solana-agent-kit-mcp/
├── src/
│   ├── index.ts          # Main entry point
├── package.json
└── tsconfig.json
```

### Available Tools

The MCP server provides all the Solana Agent Kit tools like:

* `GET_ASSET` - Retrieve information about a Solana asset/token
* `DEPLOY_TOKEN` - Deploy a new token on Solana
* `GET_PRICE` - Fetch price information for tokens
* `WALLET_ADDRESS` - Get the wallet address
* `BALANCE` - Check wallet balance
* `TRANSFER` - Transfer tokens between wallets
* `MINT_NFT` - Create and mint new NFTs
* `TRADE` - Execute token trades
* `REQUEST_FUNDS` - Request funds (useful for testing/development)
* `RESOLVE_DOMAIN` - Resolve Solana domain names
* `GET_TPS` - Get current transactions per second on Solana

### Security Considerations

* Keep your private key secure and never share it
* Use environment variables for sensitive information
* Consider using a dedicated wallet for AI agent operations
* Regularly monitor and audit AI agent activities
* Test operations on devnet/testnet before mainnet

### Troubleshooting

If you encounter issues:

1. Verify your Solana private key is correct
2. Check your RPC URL is accessible
3. Ensure you're on the intended network (mainnet, testnet, or devnet)
4. Check Claude Desktop logs for error messages
5. Verify the build was successful

### Dependencies

Key dependencies include:

* [@solana/web3.js](https://github.com/solana-labs/solana-web3.js)
* [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk)
* [solana-agent-kit](https://github.com/sendaifun/solana-agent-kit)

### Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

### License

This project is licensed under the MIT License.
