code-mode-alchemy-mcp
Provides access to Alchemy's blockchain APIs, including NFT operations, token balances, transaction history, portfolio data, pricing, notifications, and transaction simulation via search and execute tools.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@code-mode-alchemy-mcpShow me NFTs owned by vitalik.eth"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
code-mode-alchemy-mcp
An MCP (Model Context Protocol) server that gives Claude access to Alchemy's blockchain APIs. Instead of defining 88+ individual tools, it loads all Alchemy API specs at startup and exposes just two tools — search and execute — keeping context usage minimal (~1,000 tokens vs. thousands).
Inspired by Cloudflare's Code Mode MCP pattern.
How It Works
At startup, the server fetches 10 Alchemy API specifications (6 REST OpenAPI + 4 JSON-RPC OpenRPC) and indexes all their endpoints. Claude can then:
Search — find relevant endpoints by keyword
Execute — run JavaScript code in a sandboxed environment against those endpoints
Claude → search("NFT owner") → finds getNFTsForOwner endpoint
Claude → execute(code) → runs against Alchemy API, returns dataLoaded Specifications
REST (OpenAPI):
nft— NFT operations (mint, transfer, ownership queries)portfolio— Wallet portfolio dataprices— Token pricing informationnotify— Webhook notificationstransactions— Transaction history and detailsaccounts— Account management
JSON-RPC (OpenRPC):
transfers— Token transfer history (alchemy_getAssetTransfers)token— Token metadata and balances (alchemy_getTokenBalances, etc.)transaction-simulation— Simulate transactions before sendingbundler— ERC-4337 bundler operations
Related MCP server: Alchemy MCP Plugin
Prerequisites
Node.js 18+
Installation
git clone https://github.com/your-username/code-mode-alchemy-mcp
cd code-mode-alchemy-mcp
npm install
npm run buildConfiguration
Copy the example environment file:
cp .env.example .envSet your values in .env:
ALCHEMY_API_KEY=your_key_here
ALCHEMY_NETWORK=eth-mainnetSupported Networks
Any network string Alchemy supports in their URL format, e.g.:
eth-mainneteth-sepoliapolygon-mainnetarb-mainnetopt-mainnetbase-mainnet
Add to Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"alchemy": {
"command": "node",
"args": ["/absolute/path/to/code-mode-alchemy-mcp/dist/index.js"],
"env": {
"ALCHEMY_API_KEY": "your_key_here",
"ALCHEMY_NETWORK": "eth-mainnet"
}
}
}
}Restart Claude Desktop. You should see the Alchemy MCP server connected.
Tools
search(query, limit?)
Searches across all loaded endpoint metadata (summaries, descriptions, paths, tags) and returns the most relevant endpoints.
Parameter | Type | Default | Description |
| string | required | Keywords to search for |
| number | 8 | Max results to return (max 20) |
Example queries:
"NFT owner"— find endpoints for fetching NFTs by owner"token balance"— find token balance endpoints"asset transfers"— find transfer history endpoints"simulate transaction"— find simulation endpoints
execute(code)
Runs JavaScript code in a sandboxed Node.js VM with access to the Alchemy API. Execution is isolated with a 30-second timeout.
Available in the sandbox:
Name | Type | Description |
| function | Simplified API caller. Replaces |
| function | Raw Fetch API for custom requests |
| string | Your API key |
| string | Your configured network |
| function | Output captured and returned |
| function | Errors captured and returned |
REST example:
const data = await request(
"https://{network}.g.alchemy.com/nft/v3/{apiKey}/getNFTsForOwner",
{ owner: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", withMetadata: true }
);
return data;JSON-RPC example:
const data = await request(
"https://{network}.g.alchemy.com/v2/{apiKey}",
{
jsonrpc: "2.0",
method: "alchemy_getTokenBalances",
params: ["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"],
id: 1
},
{ method: "POST" }
);
return data;Usage Examples
NFTs for a wallet
"Show me all NFTs owned by 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
Claude will:
Call
search("NFT owner")→ findsgetNFTsForOwnerCall
execute(...)→ fetches and returns NFT data
Token balances
"What ERC-20 tokens does this address hold: 0x..."
Claude will:
Call
search("token balances")→ findsalchemy_getTokenBalancesCall
execute(...)→ returns token list with balances
Transaction history
"Show recent transactions for vitalik.eth"
Claude will:
Call
search("asset transfers")→ findsalchemy_getAssetTransfersCall
execute(...)→ returns transfer history
Simulate a transaction
"What would happen if I sent 1 ETH from 0x... to 0x...?"
Claude will:
Call
search("simulate transaction")→ finds simulation endpointCall
execute(...)→ returns simulation result
Development
# Run in development mode (no build step needed)
npm run dev
# Build for production
npm run build
# Run the compiled server
npm startProject Structure
code-mode-alchemy-mcp/
├── src/
│ └── index.ts # Everything: spec loading, search, sandbox, MCP server
├── dist/
│ ├── index.js # Compiled output (run this)
│ └── index.d.ts # TypeScript declarations
├── .env.example # Environment variable template
├── package.json
└── tsconfig.jsonArchitecture
Claude Desktop
│
│ MCP (stdio)
▼
MCP Server
│
├── Startup: fetch 10 specs → index all endpoints
│
├── search(query)
│ └── score & rank endpoints by keyword match
│
└── execute(code)
└── vm.runInNewContext() with 30s timeout
└── request() helper → Alchemy REST/RPC APIsWhy two tools instead of 88+?
Defining every Alchemy endpoint as a separate MCP tool would consume thousands of tokens just in tool definitions, before Claude even starts reasoning. This pattern loads specs once, searches them dynamically, and executes code — using ~1,000 tokens of tool definitions regardless of how many endpoints Alchemy adds.
Security Notes
Code in
execute()runs in a Node.jsvmsandbox with no access to the filesystem, environment, orrequireThe API key is injected by the sandbox via placeholder replacement — it is never returned in search results or exposed to user-visible output
Execution is limited to 30 seconds to prevent runaway code
References
Cloudflare Code Mode MCP — the pattern this is based on
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/itsanishjain/code-mode-alchemy-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server