From 7c65ded2d430b703f9278d18f07989e8af7244e1 Mon Sep 17 00:00:00 2001 From: Minsu Lee Date: Wed, 15 Oct 2025 23:18:42 +0900 Subject: [PATCH 1/2] chore: add Claude Code plugin configuration --- .claude-plugin/install-binary.sh | 51 ++++++++++++++++++++++++++++++++ .claude-plugin/plugin.json | 17 +++++++++++ 2 files changed, 68 insertions(+) create mode 100755 .claude-plugin/install-binary.sh create mode 100644 .claude-plugin/plugin.json diff --git a/.claude-plugin/install-binary.sh b/.claude-plugin/install-binary.sh new file mode 100755 index 0000000..8e71e18 --- /dev/null +++ b/.claude-plugin/install-binary.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +set -euo pipefail + +PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT}" +BINARY_PATH="${PLUGIN_ROOT}/mcp-grafana" + +# Detect OS and architecture +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +ARCH=$(uname -m) + +case "${ARCH}" in + x86_64) + ARCH="amd64" + ;; + aarch64|arm64) + ARCH="arm64" + ;; + *) + echo "Unsupported architecture: ${ARCH}" >&2 + exit 1 + ;; +esac + +case "${OS}" in + darwin) + OS="darwin" + ;; + linux) + OS="linux" + ;; + *) + echo "Unsupported OS: ${OS}" >&2 + exit 1 + ;; +esac + +# Version to download +VERSION="v0.7.6" +DOWNLOAD_URL="https://github.com/grafana/mcp-grafana/releases/download/${VERSION}/mcp-grafana_${OS}_${ARCH}" + +# Download binary if not exists or version mismatch +VERSION_FILE="${PLUGIN_ROOT}/.mcp-grafana-version" +if [ ! -f "${BINARY_PATH}" ] || [ ! -f "${VERSION_FILE}" ] || [ "$(cat ${VERSION_FILE})" != "${VERSION}" ]; then + echo "Downloading mcp-grafana ${VERSION} for ${OS}-${ARCH}..." >&2 + curl -fsSL "${DOWNLOAD_URL}" -o "${BINARY_PATH}" + chmod +x "${BINARY_PATH}" + echo "${VERSION}" > "${VERSION_FILE}" +fi + +# Execute the binary with all arguments +exec "${BINARY_PATH}" "$@" diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..0bd7d38 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,17 @@ +{ + "name": "grafana", + "version": "0.7.6", + "description": "A Model Context Protocol (MCP) server for Grafana providing access to dashboards, datasources, and querying capabilities", + "author": { + "name": "Grafana Labs" + }, + "homepage": "https://github.com/grafana/mcp-grafana", + "repository": "https://github.com/grafana/mcp-grafana", + "license": "AGPL-3.0", + "mcpServers": { + "grafana": { + "command": "${CLAUDE_PLUGIN_ROOT}/.claude-plugin/install-binary.sh", + "args": [] + } + } +} From d06cb9e1cb730bf702c0dd9291eda630caced638 Mon Sep 17 00:00:00 2001 From: Minsu Lee Date: Wed, 15 Oct 2025 23:29:37 +0900 Subject: [PATCH 2/2] chore: support tar.gz/zip archives and Windows platform --- .claude-plugin/install-binary.sh | 44 +++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/.claude-plugin/install-binary.sh b/.claude-plugin/install-binary.sh index 8e71e18..89ff3cd 100755 --- a/.claude-plugin/install-binary.sh +++ b/.claude-plugin/install-binary.sh @@ -10,23 +10,37 @@ ARCH=$(uname -m) case "${ARCH}" in x86_64) - ARCH="amd64" + ARCH="x86_64" ;; aarch64|arm64) ARCH="arm64" ;; + i386|i686) + ARCH="i386" + ;; *) echo "Unsupported architecture: ${ARCH}" >&2 exit 1 ;; esac +# Determine OS, archive extension, and binary name case "${OS}" in darwin) - OS="darwin" + OS="Darwin" + EXT="tar.gz" + BINARY_NAME="mcp-grafana" ;; linux) - OS="linux" + OS="Linux" + EXT="tar.gz" + BINARY_NAME="mcp-grafana" + ;; + mingw*|msys*|cygwin*) + OS="Windows" + EXT="zip" + BINARY_NAME="mcp-grafana.exe" + BINARY_PATH="${PLUGIN_ROOT}/mcp-grafana.exe" ;; *) echo "Unsupported OS: ${OS}" >&2 @@ -36,15 +50,33 @@ esac # Version to download VERSION="v0.7.6" -DOWNLOAD_URL="https://github.com/grafana/mcp-grafana/releases/download/${VERSION}/mcp-grafana_${OS}_${ARCH}" +ARCHIVE_NAME="mcp-grafana_${OS}_${ARCH}.${EXT}" +DOWNLOAD_URL="https://github.com/grafana/mcp-grafana/releases/download/${VERSION}/${ARCHIVE_NAME}" -# Download binary if not exists or version mismatch +# Download and extract binary if not exists or version mismatch VERSION_FILE="${PLUGIN_ROOT}/.mcp-grafana-version" if [ ! -f "${BINARY_PATH}" ] || [ ! -f "${VERSION_FILE}" ] || [ "$(cat ${VERSION_FILE})" != "${VERSION}" ]; then echo "Downloading mcp-grafana ${VERSION} for ${OS}-${ARCH}..." >&2 - curl -fsSL "${DOWNLOAD_URL}" -o "${BINARY_PATH}" + + TEMP_DIR=$(mktemp -d) + trap "rm -rf ${TEMP_DIR}" EXIT + + ARCHIVE_PATH="${TEMP_DIR}/${ARCHIVE_NAME}" + curl -fsSL "${DOWNLOAD_URL}" -o "${ARCHIVE_PATH}" + + # Extract archive + if [ "${EXT}" = "tar.gz" ]; then + tar -xzf "${ARCHIVE_PATH}" -C "${TEMP_DIR}" + else + unzip -q "${ARCHIVE_PATH}" -d "${TEMP_DIR}" + fi + + # Move binary to plugin root + mv "${TEMP_DIR}/${BINARY_NAME}" "${BINARY_PATH}" chmod +x "${BINARY_PATH}" echo "${VERSION}" > "${VERSION_FILE}" + + echo "Successfully installed mcp-grafana ${VERSION}" >&2 fi # Execute the binary with all arguments