Skip to content

sendaifun/solana-mcp-cloudflare

Repository files navigation

Solana Agent MCP Server on Cloudflare (Without Auth)

This example allows you to deploy a remote MCP server powered by SolanaAgentKit on Cloudflare Workers. It automatically exposes Solana blockchain interaction tools without requiring authentication.

Prerequisites

Before deploying, you'll need:

  1. A Solana RPC URL: An endpoint to connect to the Solana network (e.g., from Helius, QuickNode, Triton, or public RPCs).
  2. A Google OAuth Client ID: A client ID for the Google OAuth client.
  3. A Google OAuth Client Secret: A client secret for the Google OAuth client.
  4. Cookie Encryption Key: A key for encrypting cookies. (Generate a random string to secure your cookies)

Get started:

Deploy to Workers

This will deploy your MCP server to a URL like: your-worker-name.<your-account>.workers.dev/sse

Alternatively, you can use the command line below to clone the template and set up locally:

npm create cloudflare@latest -- my-mcp-server --template=cloudflare/ai/demos/remote-mcp-authless
# Or clone this repository directly

Important: After deploying or when running locally (e.g., with wrangler dev), you must configure the following environment variables:

  • RPC_URL: Your chosen Solana RPC endpoint URL.
  • GOOGLE_CLIENT_ID: Your Google OAuth client ID.
  • GOOGLE_CLIENT_SECRET: Your Google OAuth client secret.
  • COOKIE_ENCRYPTION_KEY: A key for encrypting cookies. (Generate a random string to secure your cookies)

You can set these in your Cloudflare dashboard under Worker Settings > Variables > Environment Variables, or in a local .dev.vars file for wrangler dev.

How Tools are Added

This MCP server uses SolanaAgentKit. Tools are automatically registered based on the SolanaAgentKit instance and any added plugins. In src/index.ts, you can see:

// ...
import TokenPlugin from "@solana-agent-kit/plugin-token";
// ...
private solanaAgent = new SolanaAgentKit(this.wallet, this.env.RPC_URL!, {});
// ...
async init() {
  this.solanaAgent.use(TokenPlugin); // Adds SPL Token tools

  const actions = this.solanaAgent.actions;

  // Loops through actions and adds them as MCP tools
  for (const action of actions) {
      // ... registers tool using this.server.tool(...)
  }
}
// ...

To add more functionality, install other SolanaAgentKit plugins and call this.solanaAgent.use(YourPlugin) within the init() method in src/index.ts.

Connect to Cloudflare AI Playground

You can connect to your MCP server from the Cloudflare AI Playground, which is a remote MCP client:

  1. Go to https://playground.ai.cloudflare.com/
  2. Enter your deployed MCP server URL (your-worker-name.<your-account>.workers.dev/sse)
  3. You can now use your Solana agent's tools directly from the playground! The server name is "SendAI Solana Agent".

Connect Claude Desktop to your MCP server

You can also connect to your remote MCP server from local MCP clients, by using the mcp-remote proxy.

To connect to your MCP server from Claude Desktop, follow Anthropic's Quickstart and within Claude Desktop go to Settings > Developer > Edit Config.

Update with this configuration, replacing the URL with your deployed worker URL or http://localhost:8787/sse if running locally:

{
	"mcpServers": {
		"solana_agent": {
			// You can name this connection anything
			"command": "npx",
			"args": [
				"mcp-remote",
				"https://your-worker-name.your-account.workers.dev/sse" // Replace with your URL
			]
		}
	}
}

Restart Claude and you should see the tools from your "SendAI Solana Agent" become available.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors