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.
Before deploying, you'll need:
- A Solana RPC URL: An endpoint to connect to the Solana network (e.g., from Helius, QuickNode, Triton, or public RPCs).
- A Google OAuth Client ID: A client ID for the Google OAuth client.
- A Google OAuth Client Secret: A client secret for the Google OAuth client.
- Cookie Encryption Key: A key for encrypting cookies. (Generate a random string to secure your cookies)
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 directlyImportant: 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.
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.
You can connect to your MCP server from the Cloudflare AI Playground, which is a remote MCP client:
- Go to https://playground.ai.cloudflare.com/
- Enter your deployed MCP server URL (
your-worker-name.<your-account>.workers.dev/sse) - You can now use your Solana agent's tools directly from the playground! The server name is "SendAI Solana Agent".
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.