A comprehensive Model Context Protocol (MCP) server for the Starknet blockchain. This server provides AI agents with the ability to interact with Starknet networks, query blockchain data, manage wallets, and interact with smart contracts. - Supported Networks - Prerequisites - Installation - Server Configuration - API Reference - Resources - Usage with AI Assistants - Security Considerations - Pro
Add this skill
npx mdskills install mcpdotdirect/starknet-mcp-serverComprehensive MCP server for Starknet blockchain with well-documented tools and clear setup instructions
1# Starknet MCP Server23[](https://smithery.ai/server/@mcpdotdirect/starknet-mcp-server)456789A comprehensive Model Context Protocol (MCP) server for the Starknet blockchain. This server provides AI agents with the ability to interact with Starknet networks, query blockchain data, manage wallets, and interact with smart contracts.1011<a href="https://glama.ai/mcp/servers/@mcpdotdirect/starknet-mcp-server">12 <img width="380" height="200" src="https://glama.ai/mcp/servers/@mcpdotdirect/starknet-mcp-server/badge" alt="Starknet Server MCP server" />13</a>1415## ๐ Contents1617- [Overview](#-overview)18- [Features](#-features)19- [Supported Networks](#-networks-supported)20- [Prerequisites](#-prerequisites)21- [Installation](#-installation)22- [Server Configuration](#-server-configuration)23- [Usage](#-usage)24- [API Reference](#-api-reference)25 - [Tools](#available-mcp-tools)26 - [Resources](#available-mcp-resources)27 - [Prompts](#available-mcp-prompts)28- [Usage with AI Assistants](#-usage-with-ai-assistants)29- [Security Considerations](#-security-considerations)30- [Project Structure](#-project-structure)31- [Development Conventions](#๏ธ-development-conventions)32- [Documentation](#-documentation)33- [License](#-license)3435## ๐ญ Overview3637The Starknet MCP Server leverages the Model Context Protocol to provide blockchain services to AI agents. It offers a comprehensive interface to the Starknet ecosystem, powering AI assistants with the ability to interact with Starknet blockchain data and operations through natural language.3839Key capabilities include:40- Reading blockchain state (balances, transactions, blocks)41- Interacting with Cairo smart contracts42- Transferring tokens (ETH, STRK, and other ERC20 tokens)43- Working with NFTs and token metadata44- Resolving StarknetID domains (similar to ENS for Ethereum)45- Making both read and write operations with proper transaction handling4647All services are exposed through a consistent interface of MCP tools and resources, making it easy for AI agents to discover and use Starknet blockchain functionality. **Every tool that accepts Starknet addresses also supports StarknetID**, automatically resolving human-readable identities to addresses behind the scenes.4849## โจ Features5051- **Starknet Integration**: Full Starknet blockchain integration using Starknet.js52- **Network Support**: Supports both Mainnet and Sepolia testnet53- **StarknetID Integration**: Resolution of Starknet IDs to addresses and vice versa54- **Native Token Support**: Support for both ETH and STRK native tokens55- **Smart Contract Interaction**: Call and query Starknet smart contracts56- **Dual Transport**: Run as stdio server or HTTP server for different integration needs57- **AI-Ready**: Designed to be used with Claude, GPT, and other AI assistants5859### Blockchain Information60- Query chain information (chain ID, latest block)61- Explore block details and transactions62- View transaction receipts and status63- Get address information and contract data6465### Native Token Operations66- Get ETH and STRK balances for any address67- Transfer ETH and STRK between accounts68- View combined native token balances6970### Token Operations71- Get ERC20 token balances and information72- Transfer ERC20 tokens73- View token supply and metadata74- Check token ownership7576### NFT Operations77- Check NFT ownership by token ID78- Get NFT collection information79- View NFT balances for addresses8081### Smart Contract Interaction82- Call read-only contract functions83- Execute contract writes with transaction confirmation84- Get contract storage information85- View ABIs and contract class information8687### StarknetID88- Resolve Starknet addresses to Starknet IDs89- Resolve Starknet IDs to addresses90- Get complete Starknet ID profiles with verification data91- Validate Starknet domains9293## ๐ง Networks Supported9495The server supports the following Starknet networks:9697- **Mainnet**: The primary Starknet production network98- **Sepolia**: Starknet's testnet on Ethereum's Sepolia99100## ๐ ๏ธ Prerequisites101102- [Bun](https://bun.sh/) 1.0.0 or higher (recommended)103- Node.js 18.0.0 or higher104105## ๐ฆ Installation106107### Installing via Smithery108109To install starknet-mcp-server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@mcpdotdirect/starknet-mcp-server):110111```bash112npx -y @smithery/cli install @mcpdotdirect/starknet-mcp-server --client claude113```114115### Option 1: Use without installation (npx)116117The easiest way to get started is to use `npx` to run the package directly:118119```bash120# Run the stdio server without installation121npx @mcpdotdirect/starknet-mcp-server122123# Run the HTTP server without installation124npx @mcpdotdirect/starknet-mcp-server http125```126127This will automatically download and run the latest version without needing to install it first.128129### Option 2: Global installation130131If you plan to use it frequently, you can install it globally:132133```bash134# Install globally135npm install -g @mcpdotdirect/starknet-mcp-server136137# Then run from anywhere138starknet-mcp-server139starknet-mcp-server http140```141142### Option 3: Local project installation143144```bash145# Add to your project146npm install @mcpdotdirect/starknet-mcp-server147148# Using yarn149yarn add @mcpdotdirect/starknet-mcp-server150151# Using pnpm152pnpm add @mcpdotdirect/starknet-mcp-server153```154155Then add to your package.json scripts:156```json157"scripts": {158 "starknet-mcp": "starknet-mcp-server",159 "starknet-mcp-http": "starknet-mcp-server http"160}161```162163### Option 4: Running from source164165If you want to run from source or develop locally:166167```bash168# Clone the repository169git clone https://github.com/mcpdotdirect/starknet-mcp-server.git170cd starknet-mcp-server171172# Install dependencies173npm install174175# Start the stdio server176npm start177178# Or start the HTTP server179npm run start:http180```181182For development with auto-reload:183```bash184# Development mode with stdio185npm run dev186187# Development mode with HTTP188npm run dev:http189```190191## โ๏ธ Server Configuration192193The server uses the following default configuration:194195- **Default Network**: Mainnet196- **Server Port**: 3000 (HTTP mode)197- **Server Host**: 0.0.0.0 (accessible from any network interface)198199These values are hardcoded in the application. If you need to modify them, you can edit the following files:200201- For network configuration: `src/core/chains.ts`202- For server configuration: `src/server/http-server.ts`203204## ๐ Usage205206### Running the Server207208You can run the Starknet MCP Server in two modes:209210```bash211# Run the server in stdio mode (for CLI tools and AI assistants)212npx @mcpdotdirect/starknet-mcp-server213214# Run the server in HTTP mode (for web applications)215npx @mcpdotdirect/starknet-mcp-server http216```217218The HTTP server runs on port 3000 by default and provides both a REST API and Server-Sent Events (SSE) for real-time communication.219220### Connecting from Cursor221222To connect to the Starknet MCP server from Cursor:2232241. Open Cursor and go to Settings (gear icon in the bottom left)2252. Click on "Features" in the left sidebar2263. Scroll down to "MCP Servers" section2274. Click "Add new MCP server"2285. Enter the following details:229 - Server name: `starknet-mcp-server`230 - Type: `command`231 - Command: `npx @mcpdotdirect/starknet-mcp-server`2322336. Click "Save"234235Once connected, you can use the MCP server's capabilities directly within Cursor. The server will appear in the MCP Servers list and can be enabled/disabled as needed.236237### Using mcp.json with Cursor238239For a more portable configuration that you can share with your team or use across projects, you can create an `.cursor/mcp.json` file in your project's root directory:240241```json242{243 "mcpServers": {244 "starknet-mcp-server": {245 "command": "npx",246 "args": [247 "@mcpdotdirect/starknet-mcp-server"248 ]249 },250 "starknet-mcp-http": {251 "command": "npx",252 "args": [253 "@mcpdotdirect/starknet-mcp-server",254 "http"255 ]256 }257 }258}259```260261Place this file in your project's `.cursor` directory (create it if it doesn't exist), and Cursor will automatically detect and use these MCP server configurations when working in that project.262263### HTTP Mode with SSE264265If you're developing a web application and want to connect to the HTTP server with Server-Sent Events (SSE), you can use this configuration:266267```json268{269 "mcpServers": {270 "starknet-mcp-sse": {271 "url": "http://localhost:3000/sse"272 }273 }274}275```276277### Connecting using Claude CLI278279If you're using Claude CLI, you can connect to the MCP server with just two commands:280281```bash282# Add the MCP server using npx283claude mcp add starknet-mcp-server npx @mcpdotdirect/starknet-mcp-server284285# Start Claude with the MCP server enabled286claude287```288289### Example: Using the MCP Server in Cursor290291After configuring the MCP server, you can easily use it in Cursor. For example:2922931. Create a new JavaScript/TypeScript file in your project:294295```javascript296// starknet-example.js297async function main() {298 try {299 // When using with Cursor, you can simply ask Cursor to:300 // "Check the ETH balance of address 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 on Starknet mainnet"301 // Or "Lookup the Starknet ID for address 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"302303 // Cursor will use the MCP server to execute these operations304 // without requiring any additional code from you305 } catch (error) {306 console.error("Error:", error.message);307 }308}309310main();311```3123132. With the file open in Cursor, you can ask Cursor to:314 - "Check the ETH balance of vitalik.stark"315 - "Get information about the latest block on Starknet"316 - "Look up the owner of NFT #123 in collection 0x..."317318### Example: Getting an ETH Balance with Starknet ID319320```javascript321// Example of using the MCP client to check an ETH balance using Starknet ID322const mcp = new McpClient("http://localhost:3000");323324const result = await mcp.invokeTool("get_starknet_eth_balance", {325 address: "vitalik.stark", // Starknet ID instead of address326 network: "mainnet"327});328329console.log(result);330// {331// wei: "1000000000000000000",332// ether: "1.0"333// }334```335336### Example: Resolving a Starknet ID337338```javascript339// Example of using the MCP client to resolve a Starknet ID to an address340const mcp = new McpClient("http://localhost:3000");341342const result = await mcp.invokeTool("resolve_starknet_address", {343 name: "vitalik.stark",344 network: "mainnet"345});346347console.log(result);348// {349// starknetId: "vitalik.stark",350// address: "0x04d07e40e93398ed3c76981e449d3446f7c4e52aac5b3e8a37d7b0ca30845a5d",351// resolved: true352// }353```354355### Example: Calling a Smart Contract356357```javascript358// Example of using the MCP client to call a smart contract function359const mcp = new McpClient("http://localhost:3000");360361const result = await mcp.invokeTool("call_starknet_contract", {362 contractAddress: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", // ETH contract363 entrypoint: "totalSupply",364 calldata: [],365 network: "mainnet"366});367368console.log(result);369// {370// result: ["0x84b6c7d5970d5a73abe"]371// }372```373374### Using in a Node.js Project375376If you want to programmatically use the MCP server in your Node.js project:377378```javascript379// Start the MCP server as a child process380const { spawn } = require('child_process');381const mcpServer = spawn('npx', ['@mcpdotdirect/starknet-mcp-server']);382383// Connect to it with the MCP client384const mcp = new McpClient({ process: mcpServer });385386// Now you can use the client387const networks = await mcp.invokeTool("get_supported_starknet_networks", {388 random_string: "any"389});390console.log("Supported networks:", networks);391```392393For more advanced usage, you can create a wrapper class around the HTTP API or use libraries like Axios for cleaner API calls.394395## ๐ API Reference396397### Available MCP Tools398399This server implements the following MCP tools:400401#### Network Tools402- `get_starknet_chain_info`: Get information about a Starknet network403- `get_supported_starknet_networks`: Get a list of supported Starknet networks404405#### Balance Tools406- `get_starknet_eth_balance`: Get the ETH balance for a Starknet address or Starknet ID407- `get_starknet_token_balance`: Get the balance of any token for an address408- `get_starknet_strk_balance`: Get the STRK token balance for an address409- `get_starknet_native_balances`: Get all native token balances (ETH and STRK) for an address410411#### StarknetID Tools412- `resolve_starknet_name`: Get the Starknet ID for an address413- `resolve_starknet_address`: Get the address for a Starknet ID414- `get_starknet_profile`: Get the full Starknet ID profile for an address415- `validate_starknet_domain`: Check if a string is a valid Starknet ID416417#### Block Tools418- `get_starknet_block`: Get information about a specific block419- `get_starknet_block_transactions`: Get transactions in a specific block420421#### Transaction Tools422- `get_starknet_transaction`: Get details about a transaction423- `get_starknet_transaction_receipt`: Get transaction receipt424- `check_starknet_transaction_status`: Check if a transaction is confirmed425426#### Contract Tools427- `call_starknet_contract`: Call a read-only function on a contract428- `get_starknet_contract_class`: Get the class (ABI and other information) of a contract429- `execute_starknet_contract`: Execute a contract call (write operation)430431#### Token Tools432- `get_starknet_token_info`: Get information about a token433- `get_starknet_token_supply`: Get the total supply of a token434- `check_starknet_nft_ownership`: Check if an address owns a specific NFT435- `get_starknet_nft_balance`: Get the number of NFTs owned by an address436437#### Transfer Tools438- `transfer_starknet_eth`: Transfer ETH from one account to another (amounts in human-readable format)439- `transfer_starknet_strk`: Transfer STRK from one account to another (amounts in human-readable format)440- `transfer_starknet_token`: Transfer ERC20 tokens from one account to another (amounts in human-readable format)441442### Available MCP Resources443444The server provides the following MCP resources:445446#### Network Resources447- `starknet://{network}/chain`: Get chain information for a specific network448- `starknet://networks`: Get a list of all supported networks449450#### Block Resources451- `starknet://{network}/block/{blockIdentifier}`: Get information about a specific block452- `starknet://{network}/block/latest`: Get the latest block453454#### Address Resources455- `starknet://{network}/address/{address}`: Get information about an address456457#### Transaction Resources458- `starknet://{network}/tx/{txHash}`: Get transaction information459460#### StarknetID Resources461- `starknet://{network}/id/address/{address}`: Resolve an address to a Starknet ID462- `starknet://{network}/id/name/{name}`: Resolve a Starknet ID to an address463- `starknet://{network}/id/profile/{address}`: Get the Starknet ID profile for an address464465### Available MCP Prompts466467For LLM interactions, the server provides these prompts:468469- `explore_starknet_block`: Explore information about a specific Starknet block470- `explore_starknet_address`: Get information about a Starknet address471- `explore_starknet_transaction`: Get information about a Starknet transaction472- `lookup_starknet_id`: Look up a Starknet ID or resolve an address to a Starknet ID473- `explore_starknet_id_profile`: Explore a full Starknet ID profile474475## ๐ Usage with AI Assistants476477When using this server with AI assistants like Claude or GPT:4784791. Configure your AI assistant to use this MCP server4802. The assistant can then use tools to interact with Starknet4813. Example queries:482 - "What's the ETH balance of address 0x04d07e40e93398ed3c76981e449d3446f7c4e52aac5b3e8a37d7b0ca30845a5d?"483 - "Look up the Starknet ID for address 0x04d07e40e93398ed3c76981e449d3446f7c4e52aac5b3e8a37d7b0ca30845a5d"484 - "What's in the latest block on Starknet mainnet?"485 - "Get information about transaction 0x7e3a33ab42f2e24184763563b7b8482b53e3b89831ebc3eacf29d4d11f5198"486 - "Resolve the Starknet ID vitalik.stark to an address"487488## ๐ Security Considerations489490- **Private keys** are used only for transaction signing and are never stored by the server491- **All token amounts** are specified in human-readable format (e.g., ETH, STRK, token units) rather than in wei or smallest units492- Always validate and sanitize input parameters before executing operations493- Consider implementing additional authentication mechanisms for production use494- Use HTTPS for the HTTP server in production environments495- Implement rate limiting to prevent abuse496- For high-value services, consider adding confirmation steps497498## ๐ Project Structure499500```501starknet-mcp-server/502โโโ src/503โ โโโ index.ts # Main stdio server entry point504โ โโโ server/ # Server-related files505โ โ โโโ http-server.ts # HTTP server with SSE506โ โ โโโ server.ts # General server setup507โ โโโ core/508โ โ โโโ chains.ts # Chain definitions and utilities509โ โ โโโ resources.ts # MCP resources implementation510โ โ โโโ tools.ts # MCP tools implementation511โ โ โโโ prompts.ts # MCP prompts implementation512โ โ โโโ services/ # Core blockchain services513โ โ โโโ index.ts # Service exports514โ โ โโโ balance.ts # Balance services515โ โ โโโ blocks.ts # Block services516โ โ โโโ clients.ts # Client utilities517โ โ โโโ contracts.ts # Contract interactions518โ โ โโโ starknetid.ts # Starknet ID services519โ โ โโโ tokens.ts # Token services520โ โ โโโ transactions.ts # Transaction services521โ โ โโโ transfer.ts # Transfer services522โ โ โโโ utils.ts # Utility functions523โโโ package.json524โโโ tsconfig.json525โโโ README.md526```527528## ๐ ๏ธ Development Conventions529530When adding custom tools, resources, or prompts:5315321. Use underscores (`_`) instead of hyphens (`-`) in all resource, tool, and prompt names533 ```typescript534 // Good: Uses underscores535 server.tool(536 "starknet_contract_call",537 "Description of the tool",538 {539 contract_address: z.string().describe("The contract address")540 },541 async (params) => {542 // Tool implementation543 }544 );545 ```5465472. This naming convention ensures compatibility with Cursor and other AI tools548549## ๐ Documentation550551For more information about:552- [Model Context Protocol](https://modelcontextprotocol.io/introduction)553- [Starknet.js Documentation](https://www.starknetjs.com/)554- [Starknet Documentation](https://docs.starknet.io/)555- [StarknetID Documentation](https://docs.starknet.id/)556557## ๐ License558559This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Full transparency โ inspect the skill content before installing.