@solana-agent-kit/adapter-mcp
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

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

  1. Configure the claude_desktop_config.json file by editing the env fields.
SOLANA_PRIVATE_KEY=your_private_key_here
RPC_URL=your_solana_rpc_url_here
  1. 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 directory
  • src/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/util-mcp dotenv

Usage

import { SolanaAgentKit, KeypairWallet } from "solana-agent-kit";
import  { startMcpServer } from '@solana-agent-kit/util-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.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.214latest
2.0.0-beta.114beta

Version History

VersionDownloads (Last 7 Days)Published
2.0.214
2.0.0-beta.114
2.0.0-beta.93
2.0.0-beta.84
2.0.0-beta.73
2.0.0-beta.63
2.0.0-beta.54
2.0.0-beta.22

Package Sidebar

Install

npm i @solana-agent-kit/adapter-mcp

Weekly Downloads

37

Version

2.0.2

License

Apache-2.0

Unpacked Size

26.6 kB

Total Files

7

Last publish

Collaborators

  • 0xaryan