Starknet 标志

Starknet

组织
mcpdotdirect

MCP server that provides LLM with tools for interacting with Starknet

发布者mcpdotdirect
代码仓库starknet-mcp-server
语言TypeScript
复刻数
4
星标数
7
可用工具
25
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    Starknet 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 25 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 7 个 Star 和 4 个 Fork。

Starknet MCP Server

smithery badge License: MIT TypeScript MCP Starknet.js

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.

📋 Contents

🔭 Overview

The 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.

Key capabilities include:

  • Reading blockchain state (balances, transactions, blocks)
  • Interacting with Cairo smart contracts
  • Transferring tokens (ETH, STRK, and other ERC20 tokens)
  • Working with NFTs and token metadata
  • Resolving StarknetID domains (similar to ENS for Ethereum)
  • Making both read and write operations with proper transaction handling

All 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.

✨ Features

  • Starknet Integration: Full Starknet blockchain integration using Starknet.js
  • Network Support: Supports both Mainnet and Sepolia testnet
  • StarknetID Integration: Resolution of Starknet IDs to addresses and vice versa
  • Native Token Support: Support for both ETH and STRK native tokens
  • Smart Contract Interaction: Call and query Starknet smart contracts
  • Dual Transport: Run as stdio server or HTTP server for different integration needs
  • AI-Ready: Designed to be used with Claude, GPT, and other AI assistants

Blockchain Information

  • Query chain information (chain ID, latest block)
  • Explore block details and transactions
  • View transaction receipts and status
  • Get address information and contract data

Native Token Operations

  • Get ETH and STRK balances for any address
  • Transfer ETH and STRK between accounts
  • View combined native token balances

Token Operations

  • Get ERC20 token balances and information
  • Transfer ERC20 tokens
  • View token supply and metadata
  • Check token ownership

NFT Operations

  • Check NFT ownership by token ID
  • Get NFT collection information
  • View NFT balances for addresses

Smart Contract Interaction

  • Call read-only contract functions
  • Execute contract writes with transaction confirmation
  • Get contract storage information
  • View ABIs and contract class information

StarknetID

  • Resolve Starknet addresses to Starknet IDs
  • Resolve Starknet IDs to addresses
  • Get complete Starknet ID profiles with verification data
  • Validate Starknet domains

🔧 Networks Supported

The server supports the following Starknet networks:

  • Mainnet: The primary Starknet production network
  • Sepolia: Starknet's testnet on Ethereum's Sepolia

🛠️ Prerequisites

  • Bun 1.0.0 or higher (recommended)
  • Node.js 18.0.0 or higher

📦 Installation

Installing via Smithery

To install starknet-mcp-server for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @mcpdotdirect/starknet-mcp-server --client claude

Option 1: Use without installation (npx)

The easiest way to get started is to use npx to run the package directly:

bash
# Run the stdio server without installation
npx @mcpdotdirect/starknet-mcp-server

# Run the HTTP server without installation
npx @mcpdotdirect/starknet-mcp-server http

This will automatically download and run the latest version without needing to install it first.

Option 2: Global installation

If you plan to use it frequently, you can install it globally:

bash
# Install globally
npm install -g @mcpdotdirect/starknet-mcp-server

# Then run from anywhere
starknet-mcp-server
starknet-mcp-server http

Option 3: Local project installation

bash
# Add to your project
npm install @mcpdotdirect/starknet-mcp-server

# Using yarn
yarn add @mcpdotdirect/starknet-mcp-server

# Using pnpm
pnpm add @mcpdotdirect/starknet-mcp-server

Then add to your package.json scripts:

json
"scripts": {
  "starknet-mcp": "starknet-mcp-server",
  "starknet-mcp-http": "starknet-mcp-server http"
}

Option 4: Running from source

If you want to run from source or develop locally:

bash
# Clone the repository
git clone https://github.com/mcpdotdirect/starknet-mcp-server.git
cd starknet-mcp-server

# Install dependencies
npm install

# Start the stdio server
npm start

# Or start the HTTP server
npm run start:http

For development with auto-reload:

bash
# Development mode with stdio
npm run dev

# Development mode with HTTP
npm run dev:http

⚙️ Server Configuration

The server uses the following default configuration:

  • Default Network: Mainnet
  • Server Port: 3000 (HTTP mode)
  • Server Host: 0.0.0.0 (accessible from any network interface)

These values are hardcoded in the application. If you need to modify them, you can edit the following files:

  • For network configuration: src/core/chains.ts
  • For server configuration: src/server/http-server.ts

🔍 Usage

Running the Server

You can run the Starknet MCP Server in two modes:

bash
# Run the server in stdio mode (for CLI tools and AI assistants)
npx @mcpdotdirect/starknet-mcp-server

# Run the server in HTTP mode (for web applications)
npx @mcpdotdirect/starknet-mcp-server http

The HTTP server runs on port 3000 by default and provides both a REST API and Server-Sent Events (SSE) for real-time communication.

Connecting from Cursor

To connect to the Starknet MCP server from Cursor:

  1. Open Cursor and go to Settings (gear icon in the bottom left)

  2. Click on "Features" in the left sidebar

  3. Scroll down to "MCP Servers" section

  4. Click "Add new MCP server"

  5. Enter the following details:

    • Server name: starknet-mcp-server
    • Type: command
    • Command: npx @mcpdotdirect/starknet-mcp-server
  6. Click "Save"

Once 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.

Using mcp.json with Cursor

For 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:

json
{
  "mcpServers": {
    "starknet-mcp-server": {
      "command": "npx",
      "args": [
        "@mcpdotdirect/starknet-mcp-server"
      ]
    },
    "starknet-mcp-http": {
      "command": "npx",
      "args": [
        "@mcpdotdirect/starknet-mcp-server",
        "http"
      ]
    }
  }
}

Place 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.

HTTP Mode with SSE

If you're developing a web application and want to connect to the HTTP server with Server-Sent Events (SSE), you can use this configuration:

json
{
  "mcpServers": {
    "starknet-mcp-sse": {
      "url": "http://localhost:3000/sse"
    }
  }
}

Connecting using Claude CLI

If you're using Claude CLI, you can connect to the MCP server with just two commands:

bash
# Add the MCP server using npx
claude mcp add starknet-mcp-server npx @mcpdotdirect/starknet-mcp-server

# Start Claude with the MCP server enabled
claude

Example: Using the MCP Server in Cursor

After configuring the MCP server, you can easily use it in Cursor. For example:

  1. Create a new JavaScript/TypeScript file in your project:
javascript
// starknet-example.js
async function main() {
  try {
    // When using with Cursor, you can simply ask Cursor to:
    // "Check the ETH balance of address 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 on Starknet mainnet"
    // Or "Lookup the Starknet ID for address 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
    
    // Cursor will use the MCP server to execute these operations 
    // without requiring any additional code from you
  } catch (error) {
    console.error("Error:", error.message);
  }
}

main();
  1. With the file open in Cursor, you can ask Cursor to:
    • "Check the ETH balance of vitalik.stark"
    • "Get information about the latest block on Starknet"
    • "Look up the owner of NFT #123 in collection 0x..."

Example: Getting an ETH Balance with Starknet ID

javascript
// Example of using the MCP client to check an ETH balance using Starknet ID
const mcp = new McpClient("http://localhost:3000");

const result = await mcp.invokeTool("get_starknet_eth_balance", {
  address: "vitalik.stark", // Starknet ID instead of address
  network: "mainnet"
});

console.log(result);
// {
//   wei: "1000000000000000000",
//   ether: "1.0"
// }

Example: Resolving a Starknet ID

javascript
// Example of using the MCP client to resolve a Starknet ID to an address
const mcp = new McpClient("http://localhost:3000");

const result = await mcp.invokeTool("resolve_starknet_address", {
  name: "vitalik.stark",
  network: "mainnet"
});

console.log(result);
// {
//   starknetId: "vitalik.stark",
//   address: "0x04d07e40e93398ed3c76981e449d3446f7c4e52aac5b3e8a37d7b0ca30845a5d",
//   resolved: true
// }

Example: Calling a Smart Contract

javascript
// Example of using the MCP client to call a smart contract function
const mcp = new McpClient("http://localhost:3000");

const result = await mcp.invokeTool("call_starknet_contract", {
  contractAddress: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", // ETH contract
  entrypoint: "totalSupply",
  calldata: [],
  network: "mainnet"
});

console.log(result);
// {
//   result: ["0x84b6c7d5970d5a73abe"]
// }

Using in a Node.js Project

If you want to programmatically use the MCP server in your Node.js project:

javascript
// Start the MCP server as a child process
const { spawn } = require('child_process');
const mcpServer = spawn('npx', ['@mcpdotdirect/starknet-mcp-server']);

// Connect to it with the MCP client
const mcp = new McpClient({ process: mcpServer });

// Now you can use the client
const networks = await mcp.invokeTool("get_supported_starknet_networks", {
  random_string: "any"
});
console.log("Supported networks:", networks);

For more advanced usage, you can create a wrapper class around the HTTP API or use libraries like Axios for cleaner API calls.

📚 API Reference

Available MCP Tools

This server implements the following MCP tools:

Network Tools

  • get_starknet_chain_info: Get information about a Starknet network
  • get_supported_starknet_networks: Get a list of supported Starknet networks

Balance Tools

  • get_starknet_eth_balance: Get the ETH balance for a Starknet address or Starknet ID
  • get_starknet_token_balance: Get the balance of any token for an address
  • get_starknet_strk_balance: Get the STRK token balance for an address
  • get_starknet_native_balances: Get all native token balances (ETH and STRK) for an address

StarknetID Tools

  • resolve_starknet_name: Get the Starknet ID for an address
  • resolve_starknet_address: Get the address for a Starknet ID
  • get_starknet_profile: Get the full Starknet ID profile for an address
  • validate_starknet_domain: Check if a string is a valid Starknet ID

Block Tools

  • get_starknet_block: Get information about a specific block
  • get_starknet_block_transactions: Get transactions in a specific block

Transaction Tools

  • get_starknet_transaction: Get details about a transaction
  • get_starknet_transaction_receipt: Get transaction receipt
  • check_starknet_transaction_status: Check if a transaction is confirmed

Contract Tools

  • call_starknet_contract: Call a read-only function on a contract
  • get_starknet_contract_class: Get the class (ABI and other information) of a contract
  • execute_starknet_contract: Execute a contract call (write operation)

Token Tools

  • get_starknet_token_info: Get information about a token
  • get_starknet_token_supply: Get the total supply of a token
  • check_starknet_nft_ownership: Check if an address owns a specific NFT
  • get_starknet_nft_balance: Get the number of NFTs owned by an address

Transfer Tools

  • transfer_starknet_eth: Transfer ETH from one account to another (amounts in human-readable format)
  • transfer_starknet_strk: Transfer STRK from one account to another (amounts in human-readable format)
  • transfer_starknet_token: Transfer ERC20 tokens from one account to another (amounts in human-readable format)

Available MCP Resources

The server provides the following MCP resources:

Network Resources

  • starknet://{network}/chain: Get chain information for a specific network
  • starknet://networks: Get a list of all supported networks

Block Resources

  • starknet://{network}/block/{blockIdentifier}: Get information about a specific block
  • starknet://{network}/block/latest: Get the latest block

Address Resources

  • starknet://{network}/address/{address}: Get information about an address

Transaction Resources

  • starknet://{network}/tx/{txHash}: Get transaction information

StarknetID Resources

  • starknet://{network}/id/address/{address}: Resolve an address to a Starknet ID
  • starknet://{network}/id/name/{name}: Resolve a Starknet ID to an address
  • starknet://{network}/id/profile/{address}: Get the Starknet ID profile for an address

Available MCP Prompts

For LLM interactions, the server provides these prompts:

  • explore_starknet_block: Explore information about a specific Starknet block
  • explore_starknet_address: Get information about a Starknet address
  • explore_starknet_transaction: Get information about a Starknet transaction
  • lookup_starknet_id: Look up a Starknet ID or resolve an address to a Starknet ID
  • explore_starknet_id_profile: Explore a full Starknet ID profile

🔍 Usage with AI Assistants

When using this server with AI assistants like Claude or GPT:

  1. Configure your AI assistant to use this MCP server
  2. The assistant can then use tools to interact with Starknet
  3. Example queries:
    • "What's the ETH balance of address 0x04d07e40e93398ed3c76981e449d3446f7c4e52aac5b3e8a37d7b0ca30845a5d?"
    • "Look up the Starknet ID for address 0x04d07e40e93398ed3c76981e449d3446f7c4e52aac5b3e8a37d7b0ca30845a5d"
    • "What's in the latest block on Starknet mainnet?"
    • "Get information about transaction 0x7e3a33ab42f2e24184763563b7b8482b53e3b89831ebc3eacf29d4d11f5198"
    • "Resolve the Starknet ID vitalik.stark to an address"

🔒 Security Considerations

  • Private keys are used only for transaction signing and are never stored by the server
  • All token amounts are specified in human-readable format (e.g., ETH, STRK, token units) rather than in wei or smallest units
  • Always validate and sanitize input parameters before executing operations
  • Consider implementing additional authentication mechanisms for production use
  • Use HTTPS for the HTTP server in production environments
  • Implement rate limiting to prevent abuse
  • For high-value services, consider adding confirmation steps

📁 Project Structure

starknet-mcp-server/
├── src/
│   ├── index.ts                # Main stdio server entry point
│   ├── server/                 # Server-related files
│   │   ├── http-server.ts      # HTTP server with SSE
│   │   └── server.ts           # General server setup
│   ├── core/
│   │   ├── chains.ts           # Chain definitions and utilities
│   │   ├── resources.ts        # MCP resources implementation
│   │   ├── tools.ts            # MCP tools implementation
│   │   ├── prompts.ts          # MCP prompts implementation
│   │   └── services/           # Core blockchain services
│   │       ├── index.ts        # Service exports
│   │       ├── balance.ts      # Balance services
│   │       ├── blocks.ts       # Block services
│   │       ├── clients.ts      # Client utilities
│   │       ├── contracts.ts    # Contract interactions
│   │       ├── starknetid.ts   # Starknet ID services
│   │       ├── tokens.ts       # Token services
│   │       ├── transactions.ts # Transaction services
│   │       ├── transfer.ts     # Transfer services
│   │       └── utils.ts        # Utility functions
├── package.json
├── tsconfig.json
└── README.md

🛠️ Development Conventions

When adding custom tools, resources, or prompts:

  1. Use underscores (_) instead of hyphens (-) in all resource, tool, and prompt names

    typescript
    // Good: Uses underscores
    server.tool(
      "starknet_contract_call",
      "Description of the tool",
      {
        contract_address: z.string().describe("The contract address")
      },
      async (params) => {
        // Tool implementation
      }
    );
  2. This naming convention ensures compatibility with Cursor and other AI tools

📚 Documentation

For more information about:

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

安装

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "starknet-mcp-server": {
      "command": "npx",
      "args": [
        "@mcpdotdirect/starknet-mcp-server"
      ]
    }
  }
}

可用工具

  • get_starknet_chain_info

    Get information about a Starknet network

  • get_supported_starknet_networks

    Get a list of supported Starknet networks

  • get_starknet_eth_balance

    Get the ETH balance for a Starknet address or Starknet ID

  • get_starknet_token_balance

    Get the token balance for a Starknet address or Starknet ID

  • get_starknet_strk_balance

    Get the STRK token balance for a Starknet address or Starknet ID

  • get_starknet_native_balances

    Get all native token balances (ETH and STRK) for a Starknet address or Starknet ID

  • resolve_starknet_name

    Get the Starknet ID for an address

  • resolve_starknet_address

    Get the address for a Starknet ID

  • get_starknet_profile

    Get the full Starknet ID profile for an address or Starknet ID

  • validate_starknet_domain

    Check if a string is a valid Starknet ID

  • get_starknet_block

    Get information about a specific block

  • get_starknet_block_transactions

    Get transactions in a specific block

  • get_starknet_transaction

    Get details about a transaction

  • get_starknet_transaction_receipt

    Get transaction receipt

  • call_starknet_contract

    Call a read-only function on a contract

  • get_starknet_contract_class

    Get the class (ABI and other information) of a contract

  • get_starknet_token_info

    Get information about a token

  • check_starknet_nft_ownership

    Check if an address owns a specific NFT

  • get_starknet_nft_balance

    Get the number of NFTs owned by an address for a specific collection

  • get_starknet_token_supply

    Get the total supply of a token

  • check_starknet_transaction_status

    Check if a transaction is confirmed (finalized)

  • transfer_starknet_eth

    Transfer ETH from one account to another

  • transfer_starknet_strk

    Transfer STRK from one account to another

  • transfer_starknet_token

    Transfer ERC20 tokens from one account to another

  • execute_starknet_contract

    Execute a contract call (write operation)

将 Starknet MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Starknet 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 Starknet 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Starknet MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "starknet": {
      "command": "npx",
      "args": [
        "-y",
        "@mcpdotdirect/starknet-mcp-server"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Starknet MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Starknet MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Starknet 帮我完成这项任务吗?
Starknet
当然。我已阅读。
以下是我使用 Starknet 得到的结果。

常见问题

Starknet MCP 服务器有什么用途?

Starknet 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Starknet MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 Starknet,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 Starknet MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 Starknet 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Starknet MCP 连接到 TypingMind?

Starknet 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

Starknet MCP 在 TypingMind 中提供哪些工具?

Starknet 提供 25 个 MCP 工具,您可以在 TypingMind 的插件页面启用这些工具,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Starknet MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 Starknet 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

explore_starknet_block

Explore information about a specific Starknet block

explore_starknet_address

Get information about a Starknet address

explore_starknet_transaction

Get information about a Starknet transaction

lookup_starknet_id

Look up a Starknet ID or resolve an address to a Starknet ID

explore_starknet_id_profile

Explore a full Starknet ID profile

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇