---
title: "Build, test, and lint | Grafana documentation"
description: "Run the Grafana MCP server from source, execute tests, and lint the repository."
---

# Build, test, and lint

Contributions are welcome. Open an issue or pull request on [GitHub](https://github.com/grafana/mcp-grafana). This project is written in Go.

## What you’ll achieve

You can run the server from source, execute the test suites, and run linters locally.

## Before you begin

- [Go](https://go.dev/doc/install) installed for your platform.
- Optional: Docker for integration tests.

## Run the server locally

**STDIO** (default for local development):

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
make run
```

**SSE:**

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
go run ./cmd/mcp-grafana --transport sse
```

## Build and run the Docker image

Build the image:

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
make build-image
```

Run in SSE mode (image default):

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
docker run -it --rm -p 8000:8000 mcp-grafana:latest
```

Run in stdio mode:

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
docker run -it --rm mcp-grafana:latest -t stdio
```

## Run tests

There are three types of tests available: unit tests, integration tests, and cloud tests.

**Unit tests** (no external dependencies required):

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
make test-unit
```

You can also run:

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
make test
```

**Integration tests** (requires Docker containers):

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
make test-integration
```

**Cloud tests** (requires Grafana Cloud instance and credentials):

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
make test-cloud
```

**Note**: Cloud tests are automatically configured in CI. For local development, you’ll need to set up your own Grafana Cloud instance and credentials.

For the full integration suite, start the supporting services first (Grafana and its dependencies on port 3000):

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
make run-test-services
make test-integration
```

If you add tools, add integration tests; existing tests are a good template.

## Run linters

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
make lint
```

The repository includes a custom linter for unescaped commas in `jsonschema` struct tags (`description` fields must be escaped with `\\,` to avoid truncation). Run only that linter:

Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```bash
make lint-jsonschema
```

Refer to the [JSONSchema linter README](https://github.com/grafana/mcp-grafana/blob/main/internal/linter/jsonschema/README.md) in the repository.

## Next steps

- [Go SDK](../go-sdk/)
- [Observability (metrics and tracing)](../observability-metrics-and-tracing/)
