Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .claude-plugin/install-binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/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="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"
EXT="tar.gz"
BINARY_NAME="mcp-grafana"
;;
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
exit 1
;;
esac

# Version to download
VERSION="v0.7.6"
ARCHIVE_NAME="mcp-grafana_${OS}_${ARCH}.${EXT}"
DOWNLOAD_URL="https://github.com/grafana/mcp-grafana/releases/download/${VERSION}/${ARCHIVE_NAME}"

# 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

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
Comment on lines +57 to +80
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should verify checksums after downloading, too.


# Execute the binary with all arguments
exec "${BINARY_PATH}" "$@"
17 changes: 17 additions & 0 deletions .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -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": []
}
}
}