From 9f59348345f2397aedcf1dfcc0c6c4d355403395 Mon Sep 17 00:00:00 2001 From: Alexander Kolotov Date: Wed, 13 Aug 2025 23:01:29 +0000 Subject: [PATCH 1/2] build script for extension --- dxt/README.md | 29 +++++++++++ dxt/build.sh | 91 ++++++++++++++++++++++++++++++++ dxt/manifest-dev.json | 118 ++++++++++++++++++++++++++++++++++++++++++ dxt/manifest.json | 2 +- 4 files changed, 239 insertions(+), 1 deletion(-) create mode 100755 dxt/build.sh create mode 100644 dxt/manifest-dev.json diff --git a/dxt/README.md b/dxt/README.md index 132bfc4..c4afe1a 100644 --- a/dxt/README.md +++ b/dxt/README.md @@ -21,6 +21,35 @@ The reasons for this are: ## Packaging instructions +### Automated Build (Recommended) + +For automated building using the provided build script: + +**Production mode (default):** + +```shell +docker run --rm -it -v "$(pwd)"/dxt:/workspace -w /workspace node:20-slim bash -c "./build.sh" +# or explicitly: +docker run --rm -it -v "$(pwd)"/dxt:/workspace -w /workspace node:20-slim bash -c "./build.sh prod" +``` + +**Development mode:** + +```shell +docker run --rm -it -v "$(pwd)"/dxt:/workspace -w /workspace node:20-slim bash -c "./build.sh dev" +``` + +#### Build Modes + +- **Production (`prod`)**: Uses `manifest.json` and connects to the official `https://mcp.blockscout.com/mcp/` server. Creates `blockscout-mcp.dxt`. +- **Development (`dev`)**: Uses `manifest-dev.json` with configurable URL and creates `blockscout-mcp-dev.dxt`. Users can configure the Blockscout MCP server URL during installation in Claude Desktop. + +This will automatically handle all the steps below and create the extension at `dxt/_build/blockscout-mcp[--dev].dxt`. + +### Manual Build + +For manual building or if you prefer step-by-step control: + 1. This step is optional and required only if there is no local Node.js installation. For the project directory run: diff --git a/dxt/build.sh b/dxt/build.sh new file mode 100755 index 0000000..43c33e6 --- /dev/null +++ b/dxt/build.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +# Build script for Blockscout MCP Server Desktop Extension +# This script can be run inside the Docker container to build the extension automatically +# +# Usage: ./build.sh [mode] +# mode: "prod" (default) or "dev" + +set -e # Exit on any error + +# Parse arguments +MODE="${1:-prod}" + +if [[ "$MODE" != "prod" && "$MODE" != "dev" ]]; then + echo "❌ Error: Mode must be 'prod' or 'dev'" + echo "Usage: $0 [prod|dev]" + exit 1 +fi + +echo "🚀 Building Blockscout MCP Server Desktop Extension (${MODE} mode)..." + +# Step 1: Install system dependencies +echo "đŸ“Ļ Installing system dependencies..." +apt-get update -qq +apt-get install -y openssl + +# Step 2: Install DXT CLI +echo "🔧 Installing DXT CLI..." +npm install -g @anthropic-ai/dxt + +# Step 3: Prepare build directory +echo "📂 Preparing build directory..." +if [ -d "_build" ]; then + echo " Cleaning existing _build directory..." + rm -rf _build +fi + +mkdir _build + +# Step 4: Copy required files based on mode +echo "📋 Copying manifest and assets..." +if [[ "$MODE" == "dev" ]]; then + echo " Using development manifest (manifest-dev.json)" + cp manifest-dev.json _build/manifest.json +else + echo " Using production manifest (manifest.json)" + cp manifest.json _build/ +fi +cp blockscout.png _build/ + +# Step 5: Change to build directory and install dependencies +echo "đŸ“Ļ Installing mcp-remote dependency..." +cd _build +npm install mcp-remote@0.1.18 + +# Step 6: Package the extension +echo "đŸ“Ļ Packaging extension..." +if [[ "$MODE" == "dev" ]]; then + DXT_FILENAME="blockscout-mcp-dev.dxt" +else + DXT_FILENAME="blockscout-mcp.dxt" +fi +dxt pack . "$DXT_FILENAME" + +# Step 7: Sign the extension +echo "âœī¸ Signing extension..." +dxt sign "$DXT_FILENAME" --self-signed + +# Step 8: Verify the extension +echo "✅ Verifying extension..." +if dxt verify "$DXT_FILENAME"; then + echo " ✅ Extension signature verified successfully" +else + echo " âš ī¸ Extension verification failed (expected for self-signed certificates)" + echo " â„šī¸ This is normal when using self-signed certificates and won't affect functionality" +fi +echo "" +echo "â„šī¸ Extension info:" +dxt info "$DXT_FILENAME" + +echo "" +echo "🎉 Extension built successfully!" +echo "📄 Output: dxt/_build/$DXT_FILENAME" +echo "🔧 Mode: $MODE" +if [[ "$MODE" == "dev" ]]; then + echo "âš™ī¸ Note: Dev mode requires manual configuration of Blockscout MCP server URL" +fi +echo "" +echo "To use this extension:" +echo "1. Copy the .dxt file from the container to your host system" +echo "2. Install it in Claude Desktop" diff --git a/dxt/manifest-dev.json b/dxt/manifest-dev.json new file mode 100644 index 0000000..62436c7 --- /dev/null +++ b/dxt/manifest-dev.json @@ -0,0 +1,118 @@ +{ + "dxt_version": "0.1", + "name": "blockscout-mcp-dev", + "display_name": "Blockscout (dev)", + "version": "0.2.0", + "description": "Contextual blockchain activity analysis via Blockscout APIs", + "long_description": "This extension enables contextual blockchain activity analysis with multi-chain support, intelligent context optimization, smart response slicing, and seamless pagination. The server exposes blockchain data including balances, tokens, NFTs, contract metadata, transactions, and logs via MCP for comprehensive blockchain analysis. This extension acts as a proxy to the official Blockscout MCP server.", + "author": { + "name": "Blockscout", + "url": "https://blockscout.com" + }, + "repository": { + "type": "git", + "url": "https://github.com/blockscout/mcp-server" + }, + "homepage": "https://blockscout.com", + "documentation": "https://mcp.blockscout.com", + "support": "https://github.com/blockscout/mcp-server/issues", + "icon": "blockscout.png", + "server": { + "type": "node", + "entry_point": "node_modules/mcp-remote/dist/proxy.js", + "mcp_config": { + "command": "node", + "args": [ + "${__dirname}/node_modules/mcp-remote/dist/proxy.js", + "${user_config.blockscout_url}", + "--transport", "http-only", + "--allow-http" + ], + "env": {} + } + }, + "user_config": { + "blockscout_url": { + "type": "string", + "title": "Blockscout MCP Server URL", + "description": "The URL of the Blockscout MCP server to connect to (e.g., http://127.0.0.1:8000/mcp/ for local development)", + "default": "http://127.0.0.1:8000/mcp/", + "required": true + } + }, + "tools": [ + { + "name": "__unlock_blockchain_analysis__", + "description": "Provides custom instructions for the MCP host. This is a mandatory first step." + }, + { + "name": "get_chains_list", + "description": "Returns a list of all known blockchain chains" + }, + { + "name": "get_address_by_ens_name", + "description": "Converts an ENS name to its Ethereum address" + }, + { + "name": "lookup_token_by_symbol", + "description": "Searches for tokens by symbol" + }, + { + "name": "get_contract_abi", + "description": "Retrieves the ABI for a smart contract" + }, + { + "name": "get_address_info", + "description": "Gets comprehensive information about an address" + }, + { + "name": "get_tokens_by_address", + "description": "Returns ERC20 token holdings for an address" + }, + { + "name": "get_latest_block", + "description": "Returns the latest indexed block" + }, + { + "name": "get_transactions_by_address", + "description": "Gets transactions for an address" + }, + { + "name": "get_token_transfers_by_address", + "description": "Returns ERC-20 token transfers for an address" + }, + { + "name": "transaction_summary", + "description": "Provides a human-readable transaction summary" + }, + { + "name": "nft_tokens_by_address", + "description": "Retrieves NFT tokens owned by an address" + }, + { + "name": "get_block_info", + "description": "Returns detailed block information" + }, + { + "name": "get_transaction_info", + "description": "Gets comprehensive transaction information" + }, + { + "name": "get_transaction_logs", + "description": "Returns transaction logs with decoded event data" + }, + { + "name": "read_contract", + "description": "Executes a read-only smart contract function" + } + ], + "keywords": [ + "blockchain", + "ethereum", + "evm", + "blockscout", + "arbitrum", + "optimism" + ], + "license": "MIT" +} diff --git a/dxt/manifest.json b/dxt/manifest.json index 731c070..ededf7d 100644 --- a/dxt/manifest.json +++ b/dxt/manifest.json @@ -2,7 +2,7 @@ "dxt_version": "0.1", "name": "blockscout-mcp", "display_name": "Blockscout", - "version": "0.1.0", + "version": "0.2.0", "description": "Contextual blockchain activity analysis via Blockscout APIs", "long_description": "This extension enables contextual blockchain activity analysis with multi-chain support, intelligent context optimization, smart response slicing, and seamless pagination. The server exposes blockchain data including balances, tokens, NFTs, contract metadata, transactions, and logs via MCP for comprehensive blockchain analysis. This extension acts as a proxy to the official Blockscout MCP server.", "author": { From 7645863d46ba94d5ab2f7add4b49b07b8f1d8962 Mon Sep 17 00:00:00 2001 From: Alexander Kolotov Date: Wed, 13 Aug 2025 23:01:52 +0000 Subject: [PATCH 2/2] proper commands to run server in docker container --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7434c50..4f24931 100644 --- a/README.md +++ b/README.md @@ -257,13 +257,13 @@ docker pull ghcr.io/blockscout/mcp-server:latest To run the Docker container in HTTP mode with port mapping: ```bash -docker run --rm -p 8000:8000 ghcr.io/blockscout/mcp-server:latest --http --http-host 0.0.0.0 +docker run --rm -p 8000:8000 ghcr.io/blockscout/mcp-server:latest python -m blockscout_mcp_server --http --http-host 0.0.0.0 ``` With custom port: ```bash -docker run --rm -p 8080:8080 ghcr.io/blockscout/mcp-server:latest --http --http-host 0.0.0.0 --http-port 8080 +docker run --rm -p 8080:8080 ghcr.io/blockscout/mcp-server:latest python -m blockscout_mcp_server --http --http-host 0.0.0.0 --http-port 8080 ``` **HTTP Mode with REST API:** @@ -271,7 +271,7 @@ docker run --rm -p 8080:8080 ghcr.io/blockscout/mcp-server:latest --http --http- To run with the REST API enabled: ```bash -docker run --rm -p 8000:8000 ghcr.io/blockscout/mcp-server:latest --http --rest --http-host 0.0.0.0 +docker run --rm -p 8000:8000 ghcr.io/blockscout/mcp-server:latest python -m blockscout_mcp_server --http --rest --http-host 0.0.0.0 ``` **Note:** When running in HTTP mode with Docker, use `--http-host 0.0.0.0` to bind to all interfaces so the server is accessible from outside the container.