-
Notifications
You must be signed in to change notification settings - Fork 6
feat: mcp server for validate plugin #518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
s4kh
wants to merge
9
commits into
main
Choose a base branch
from
feat-mcp-server
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+757
−181
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a095846
feat: mcp server for validate plugin
s4kh 9c52d13
ref: extract plugin archive extraction and check runner to pkg
s4kh d7d50f3
feat: run validate_plugin from mcp
s4kh 8b5e130
test: add test for mcpserver
s4kh 8ac8362
feat: check project structure
s4kh 7379482
chore: readme.md
s4kh 258359d
chore: regenerated readme
s4kh 8ef2faf
chore: mcp server install script, add mcpserver to release
s4kh 7341a3a
ref: os.exit(1) when run returns err
s4kh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,240 @@ | ||
| # Plugin Validator MCP Server | ||
|
|
||
| An MCP (Model Context Protocol) server that provides Grafana plugin validation capabilities to AI assistants and code editors. | ||
|
|
||
| ## Building | ||
|
|
||
| ```bash | ||
| # From the project root | ||
| go build -o bin/mcpserver ./pkg/cmd/mcpserver | ||
|
|
||
| # Or using mage | ||
| mage build:commands | ||
| ``` | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Quick Install from Release (Recommended) | ||
|
|
||
| **Linux/macOS:** | ||
|
|
||
| Run the installation script: | ||
|
|
||
| ```bash | ||
| curl -fsSL https://raw.githubusercontent.com/grafana/plugin-validator/main/scripts/install-mcp.sh | bash | ||
| ``` | ||
|
|
||
| Or download and inspect the script first: | ||
|
|
||
| ```bash | ||
| wget https://raw.githubusercontent.com/grafana/plugin-validator/main/scripts/install-mcp.sh | ||
| chmod +x install-mcp.sh | ||
| ./install-mcp.sh | ||
| ``` | ||
|
|
||
| **Windows (PowerShell):** | ||
|
|
||
| ```powershell | ||
| # Download latest release | ||
| $version = (Invoke-RestMethod "https://api.github.com/repos/grafana/plugin-validator/releases/latest").tag_name | ||
| $arch = if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { "386" } | ||
| $url = "https://github.com/grafana/plugin-validator/releases/download/$version/plugin-validator_$($version.TrimStart('v'))_windows_$arch.zip" | ||
|
|
||
| # Download and extract | ||
| Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\plugin-validator.zip" | ||
| Expand-Archive -Path "$env:TEMP\plugin-validator.zip" -DestinationPath "$env:TEMP\plugin-validator" -Force | ||
|
|
||
| # Move to user bin directory | ||
| $binDir = "$env:USERPROFILE\.local\bin" | ||
| New-Item -ItemType Directory -Force -Path $binDir | Out-Null | ||
| Move-Item -Path "$env:TEMP\plugin-validator\plugin-validator-mcp.exe" -Destination "$binDir\" -Force | ||
|
|
||
| # Add to PATH if not already present | ||
| if ($env:PATH -notlike "*$binDir*") { | ||
| [Environment]::SetEnvironmentVariable("PATH", "$env:PATH;$binDir", "User") | ||
| } | ||
| ``` | ||
|
|
||
| ### Install via Go | ||
|
|
||
| If you have Go installed and prefer building from source: | ||
|
|
||
| ```bash | ||
| # Clone and build | ||
| git clone https://github.com/grafana/plugin-validator.git | ||
| cd plugin-validator | ||
| go build -o ~/.local/bin/plugin-validator-mcp ./pkg/cmd/mcpserver | ||
|
|
||
| # Make sure ~/.local/bin is in your PATH | ||
| export PATH="$HOME/.local/bin:$PATH" | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### Claude Code (CLI & VS Code Extension) | ||
|
|
||
| **Option 1: Global Configuration** | ||
|
|
||
| Add to `~/.claude.json` (shared between CLI and VS Code extension): | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "plugin-validator": { | ||
| "command": "/home/YOUR_USERNAME/.local/bin/plugin-validator-mcp", | ||
| "args": [] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| On macOS, use: | ||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "plugin-validator": { | ||
| "command": "/Users/YOUR_USERNAME/.local/bin/plugin-validator-mcp", | ||
| "args": [] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| **Option 2: Project-Scoped** | ||
|
|
||
| Create `.mcp.json` in your project root: | ||
|
|
||
| ```json | ||
| { | ||
| "plugin-validator": { | ||
| "command": "/home/YOUR_USERNAME/.local/bin/plugin-validator-mcp", | ||
| "args": [] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| For more details on MCP server types and configuration, see [Claude Code Plugin Documentation](https://docs.anthropic.com/en/docs/claude-code). | ||
|
|
||
| ### Claude Desktop (macOS) | ||
|
|
||
| Edit `~/Library/Application Support/Claude/claude_desktop_config.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "plugin-validator": { | ||
| "command": "/Users/YOUR_USERNAME/.local/bin/plugin-validator-mcp" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Claude Desktop (Linux) | ||
|
|
||
| Edit `~/.config/Claude/claude_desktop_config.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "plugin-validator": { | ||
| "command": "/home/YOUR_USERNAME/.local/bin/plugin-validator-mcp" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### VS Code with Continue Extension | ||
|
|
||
| Edit `~/.continue/config.json` (Linux/macOS): | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": [ | ||
| { | ||
| "name": "plugin-validator", | ||
| "command": "~/.local/bin/plugin-validator-mcp" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### Cline (VS Code Extension) | ||
|
|
||
| Edit `~/.cline/mcp_settings.json` (Linux/macOS): | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "plugin-validator": { | ||
| "command": "/home/YOUR_USERNAME/.local/bin/plugin-validator-mcp", | ||
| "args": [] | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| ## Usage | ||
|
|
||
| Once configured, you can ask your AI assistant to validate Grafana plugins: | ||
|
|
||
| ``` | ||
| Validate this Grafana plugin: /path/to/plugin.zip | ||
| ``` | ||
|
|
||
| ``` | ||
| Check this plugin with source code: | ||
| - Plugin: ./my-plugin.zip | ||
| - Source: https://github.com/user/my-plugin | ||
| ``` | ||
|
|
||
| ## Tool Details | ||
|
|
||
| ### validate_plugin | ||
|
|
||
| Validates a Grafana plugin against publishing requirements. | ||
|
|
||
| **Inputs:** | ||
|
|
||
| - `pluginPath` (required): Path or URL to the plugin archive (.zip) | ||
| - `sourceCodeUri` (optional): Path or URL to plugin source code (zip, folder, or git repo) | ||
|
|
||
| **Output:** | ||
|
|
||
| - `diagnostics`: Structured validation results with errors, warnings, and recommendations | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Server not found | ||
|
|
||
| Make sure the binary path is correct: | ||
|
|
||
| ```bash | ||
| which plugin-validator-mcp | ||
| # or | ||
| ls -la ~/.local/bin/plugin-validator-mcp | ||
| ``` | ||
|
|
||
| ### Permission denied | ||
|
|
||
| Make the binary executable: | ||
|
|
||
| ```bash | ||
| chmod +x ~/.local/bin/plugin-validator-mcp | ||
| ``` | ||
|
|
||
| ### Test manually | ||
|
|
||
| Run the server directly to check for errors: | ||
|
|
||
| ```bash | ||
| ~/.local/bin/plugin-validator-mcp | ||
| # Press Ctrl+C to exit | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| Run tests: | ||
|
|
||
| ```bash | ||
| go test ./pkg/cmd/mcpserver -v | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for response for the LLM call.