Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/grafana/v13.0/developer-resources/mcp/developer/go-sdk.md, or by sending Accept: text/markdown to https://grafana.com/docs/grafana/v13.0/developer-resources/mcp/developer/go-sdk/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
Go SDK (programmatic use)
You can use the Grafana MCP server as a Go library to build custom MCP server contexts, for example with custom TLS or debug settings. The package is available on pkg.go.dev.
What you’ll achieve
You integrate the server into your own Go program, using ComposedStdioContextFunc and GrafanaConfig (and optionally TLSConfig) so the server runs with your chosen configuration.
Before you begin
- A Go toolchain and the module in your project:
go get github.com/grafana/mcp-grafana.
Compose a stdio context with config
Create a GrafanaConfig with your Grafana URL, credentials (or token), and options such as Debug. For TLS to Grafana, set TLSConfig with CertFile, KeyFile, and CAFile. Then build the context function with mcpgrafana.ComposedStdioContextFunc(grafanaConfig) and pass it to your MCP server setup so the server uses this context when handling requests.
Example (structure only):
grafanaConfig := mcpgrafana.GrafanaConfig{
Debug: true,
TLSConfig: &mcpgrafana.TLSConfig{
CertFile: "/path/to/client.crt",
KeyFile: "/path/to/client.key",
CAFile: "/path/to/ca.crt",
},
}
contextFunc := mcpgrafana.ComposedStdioContextFunc(grafanaConfig)Refer to the package documentation for the exact types and constructors.
Next steps
- Observability (metrics and tracing) for Prometheus and OTLP.
- Client TLS (Grafana connection) for TLS flag reference.
Was this page helpful?
Related resources from Grafana Labs


