-
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
base: main
Are you sure you want to change the base?
Changes from all commits
85ce6c7
c5ccd77
1883e3e
e2d30cf
05ccceb
4d104ef
7192e2d
3c1a00e
40b20f3
f4a7346
ab1bdb8
7856e55
a1c63be
61a5259
317e839
ea7555b
fb0f3cf
1288300
5ba0fcf
9888117
16ce2d6
947a09d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: Release MCP Server | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: "Semver type of new version (major / minor / patch)" | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - patch | ||
| - minor | ||
| - major | ||
|
|
||
| jobs: | ||
| release-mcp: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - id: get-secrets | ||
| uses: grafana/shared-workflows/actions/get-vault-secrets@a37de51f3d713a30a9e4b21bcdfbd38170020593 # v1.3.0 | ||
| with: | ||
| repo_secrets: | | ||
| GITHUB_APP_ID=plugins-platform-bot-app:app_id | ||
| GITHUB_APP_PRIVATE_KEY=plugins-platform-bot-app:app_pem | ||
| export_env: false | ||
|
|
||
| - name: Generate token | ||
| id: generate_token | ||
| uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1 | ||
| with: | ||
| app-id: ${{ fromJSON(steps.get-secrets.outputs.secrets).GITHUB_APP_ID }} | ||
| private-key: ${{ fromJSON(steps.get-secrets.outputs.secrets).GITHUB_APP_PRIVATE_KEY }} | ||
| permission-contents: write | ||
|
|
||
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | ||
| with: | ||
| token: ${{ steps.generate_token.outputs.token }} | ||
| persist-credentials: true | ||
|
|
||
| - name: Setup Git | ||
| run: | | ||
| git config user.name 'grafana-plugins-platform-bot[bot]' | ||
| git config user.email '144369747+grafana-plugins-platform-bot[bot]@users.noreply.github.com' | ||
|
|
||
| - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | ||
| with: | ||
| node-version: "24" | ||
|
|
||
| - name: Bump MCP version and create tag | ||
| run: | | ||
| cd mcp-package | ||
| npm version ${INPUT_VERSION} --no-git-tag-version | ||
| NEW_VERSION=$(jq -r .version package.json) | ||
| cd .. | ||
|
|
||
| git add mcp-package/package.json | ||
| git commit -m "chore(mcp): release v${NEW_VERSION}" | ||
| git tag "mcp/v${NEW_VERSION}" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We manually tag with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| env: | ||
| INPUT_VERSION: ${{ github.event.inputs.version }} | ||
|
|
||
| - name: Push changes and tag | ||
| run: | | ||
| git push origin main | ||
| git push origin --tags | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| name: Create MCP release and publish to github, npm and docker hub | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I first tried with modifying the |
||
|
|
||
| on: # zizmor: ignore[cache-poisoning] | ||
| push: | ||
| tags: | ||
| - 'mcp/v[0-9]*' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only triggered for mcp tag pushes. |
||
|
|
||
| jobs: | ||
| release-mcp-to-github: | ||
| runs-on: ubuntu-arm64 | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - run: git fetch --force --tags | ||
| - uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 | ||
| with: | ||
| go-version-file: go.mod | ||
| check-latest: true | ||
|
|
||
| - id: get-secrets | ||
| uses: grafana/shared-workflows/actions/get-vault-secrets@a37de51f3d713a30a9e4b21bcdfbd38170020593 # v1.3.0 | ||
| with: | ||
| repo_secrets: | | ||
| GITHUB_APP_ID=plugins-platform-bot-app:app_id | ||
| GITHUB_APP_PRIVATE_KEY=plugins-platform-bot-app:app_pem | ||
| export_env: false | ||
|
|
||
| - name: Generate token | ||
| id: generate_token | ||
| uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1 | ||
| with: | ||
| app-id: ${{ fromJSON(steps.get-secrets.outputs.secrets).GITHUB_APP_ID }} | ||
| private-key: ${{ fromJSON(steps.get-secrets.outputs.secrets).GITHUB_APP_PRIVATE_KEY }} | ||
| permission-contents: write | ||
|
|
||
| - name: Extract MCP version | ||
| run: echo "MCP_VERSION=${GITHUB_REF_NAME#mcp/v}" >> $GITHUB_ENV | ||
|
|
||
| - uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 | ||
| with: | ||
| distribution: goreleaser | ||
| version: latest | ||
| args: release --clean --config .goreleaser.mcp.yaml --skip=validate | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| env: | ||
| GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
| GORELEASER_CURRENT_TAG: ${{ github.ref_name }} | ||
| MCP_VERSION: ${{ env.MCP_VERSION }} | ||
|
|
||
| release-mcp-to-npm: | ||
| runs-on: ubuntu-latest | ||
| needs: release-mcp-to-github | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | ||
| with: | ||
| node-version: "24" | ||
| registry-url: "https://registry.npmjs.org" | ||
| - run: cd mcp-package && npm install | ||
| - run: cd mcp-package && npm publish | ||
|
|
||
| release-mcp-to-dockerhub: | ||
| runs-on: ubuntu-x64 | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Get version from package.json | ||
| id: get_version | ||
| run: | | ||
| echo "version=$(jq -r .version mcp-package/package.json)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - id: push-mcp-to-dockerhub | ||
| uses: grafana/shared-workflows/actions/build-push-to-dockerhub@f02d5da7ddff4ea32bbe5034c7c70e90d2b9622c # build-push-to-dockerhub/v0.4.1 | ||
| with: | ||
| repository: grafana/plugin-validator-mcp | ||
| context: . | ||
| file: mcp-package/Dockerfile | ||
| build-args: | | ||
| MCP_VERSION=${{ steps.get_version.outputs.version }} | ||
| tags: |- | ||
| "v${{ steps.get_version.outputs.version }}" | ||
| "latest" | ||
| push: true | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ name: Create release and publish to github, npm and docker hub | |
| on: # zizmor: ignore[cache-poisoning] | ||
| push: | ||
| tags: | ||
| - "*" | ||
| - 'v[0-9]*' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only triggered on validator's version tag pushes. |
||
|
|
||
| jobs: | ||
| release-to-github: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
| # Separate goreleaser config for the MCP server. | ||
| # Triggered by mcp/v* tags independently of the main plugin-validator releases. | ||
| # MCP_VERSION env var must be set to the bare semver (e.g. "0.2.0") by the workflow. | ||
| version: 2 | ||
|
|
||
| project_name: plugin-validator-mcp | ||
|
|
||
| before: | ||
| hooks: | ||
| - go mod tidy | ||
|
|
||
| builds: | ||
| - id: mcpserver | ||
| main: ./pkg/cmd/mcpserver | ||
| binary: plugin-validator-mcp | ||
| goos: | ||
| - linux | ||
| - darwin | ||
| - windows | ||
| goarch: | ||
| - amd64 | ||
| - arm64 | ||
| env: | ||
| - CGO_ENABLED=0 | ||
| ldflags: | ||
| - -s -w -X main.version={{ .Env.MCP_VERSION }} | ||
|
|
||
| archives: | ||
| - name_template: "plugin-validator-mcp_{{ .Env.MCP_VERSION }}_{{ .Os }}_{{ .Arch }}" | ||
| formats: [tar.gz] | ||
|
|
||
| checksum: | ||
| name_template: "checksums.txt" | ||
|
|
||
| changelog: | ||
| disable: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,12 @@ Then you can run the utility: | |
| plugincheck2 -sourceCodeUri [source_code_location/] [plugin_archive.zip] | ||
| ``` | ||
|
|
||
| ### MCP Server (for AI assistants) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider this will be what we ask people to do to install our MCP server the instructions are far off. Most people that want to install an mcp server expect instructions to tell them something like: modify your mcp.json file and add |
||
|
|
||
| The plugin validator can be used as an MCP (Model Context Protocol) server, allowing AI assistants like Claude, Cline, and other MCP-compatible tools to validate Grafana plugins. | ||
|
|
||
| See the [MCP Server README](mcp-package/README.md) for configuration instructions. | ||
|
|
||
| ### Generating local files For validation | ||
|
|
||
| You must create a `.zip` archive containing the `dist/` directory but named as your plugin ID: | ||
|
|
@@ -186,7 +192,6 @@ analyzers: | |
| - my-plugin-id | ||
| ``` | ||
|
|
||
|
|
||
| ### Source code | ||
|
|
||
| You can specify the location of the plugin source code to the validator with the `-sourceCodeUri` option. Doing so allows for additional [analyzers](#analyzers) to be run and for a more complete scan. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| FROM golang:1.25-alpine3.22@sha256:fa3380ab0d73b706e6b07d2a306a4dc68f20bfc1437a6a6c47c8f88fe4af6f75 AS builder | ||
|
|
||
| ARG MCP_VERSION=dev | ||
|
|
||
| WORKDIR /build | ||
| COPY pkg/cmd/mcpserver ./pkg/cmd/mcpserver | ||
| COPY go.mod go.sum ./ | ||
|
|
||
| RUN apk add --no-cache git ca-certificates && \ | ||
| update-ca-certificates && \ | ||
| CGO_ENABLED=0 GO111MODULE=on go build -ldflags "-s -w -X main.version=${MCP_VERSION}" -o plugin-validator-mcp ./pkg/cmd/mcpserver | ||
|
|
||
| FROM alpine:3.22@sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412 | ||
|
|
||
| RUN apk add --no-cache ca-certificates docker-cli nodejs npm && \ | ||
| update-ca-certificates | ||
|
|
||
| WORKDIR /app | ||
| COPY --from=builder /build/plugin-validator-mcp /app/plugin-validator-mcp | ||
|
|
||
| # MCP servers communicate over stdin/stdout | ||
| ENTRYPOINT ["/app/plugin-validator-mcp"] |
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.
--no-git-tag-versionso it does not auto commit and tag0.0.1. We need tomcp/vprefix.