+24
-3
lines changedFilter options
+24
-3
lines changed Original file line number Diff line number Diff line change
@@ -52,6 +52,10 @@ run: ## Run the MCP server in stdio mode.
52
52
run-sse: ## Run the MCP server in SSE mode.
53
53
go run ./cmd/mcp-grafana --transport sse --log-level debug --debug
54
54
55
+
PHONY: run-streamable-http
56
+
run-streamable-http: ## Run the MCP server in StreamableHTTP mode.
57
+
go run ./cmd/mcp-grafana --transport streamable-http --log-level debug --debug
58
+
55
59
.PHONY: run-test-services
56
60
run-test-services: ## Run the docker-compose services required for the unit and integration tests.
57
61
docker-compose up -d --build
Original file line number Diff line number Diff line change
@@ -118,6 +118,13 @@ the OnCall tools, use `--disable-oncall`.
118
118
docker pull mcp/grafana
119
119
docker run --rm -p 8000:8000 -e GRAFANA_URL=http://localhost:3000 -e GRAFANA_API_KEY=<your service account token> mcp/grafana
120
120
```
121
+
122
+
3. **Streamable HTTP Mode**: In this mode, the server operates as an independent process that can handle multiple client connections. You must expose port 8000 using the `-p` flag: For this mode you must explicitly override the default with `-t streamable-http`
123
+
124
+
```bash
125
+
docker pull mcp/grafana
126
+
docker run --rm -p 8000:8000 -e GRAFANA_URL=http://localhost:3000 -e GRAFANA_API_KEY=<your service account token> mcp/grafana -t streamable-http
127
+
```
121
128
122
129
- **Download binary**: Download the latest release of `mcp-grafana` from the [releases page](https://github.com/grafana/mcp-grafana/releases) and place it in your `$PATH`.
123
130
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ func newServer(dt disabledTools) *server.MCPServer {
87
87
return s
88
88
}
89
89
90
-
func run(transport, addr, basePath string, logLevel slog.Level, dt disabledTools, gc grafanaConfig) error {
90
+
func run(transport, addr, basePath string, endpointPath string, logLevel slog.Level, dt disabledTools, gc grafanaConfig) error {
91
91
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: logLevel})))
92
92
s := newServer(dt)
93
93
@@ -106,6 +106,15 @@ func run(transport, addr, basePath string, logLevel slog.Level, dt disabledTools
106
106
if err := srv.Start(addr); err != nil {
107
107
return fmt.Errorf("Server error: %v", err)
108
108
}
109
+
case "streamable-http":
110
+
srv := server.NewStreamableHTTPServer(s, server.WithHTTPContextFunc(mcpgrafana.ComposedHTTPContextFunc(gc.debug)),
111
+
server.WithStateLess(true),
112
+
server.WithEndpointPath(endpointPath),
113
+
)
114
+
slog.Info("Starting Grafana MCP server using StreamableHTTP transport", "address", addr, "endpointPath", endpointPath)
115
+
if err := srv.Start(addr); err != nil {
116
+
return fmt.Errorf("Server error: %v", err)
117
+
}
109
118
default:
110
119
return fmt.Errorf(
111
120
"Invalid transport type: %s. Must be 'stdio' or 'sse'",
@@ -124,16 +133,17 @@ func main() {
124
133
"stdio",
125
134
"Transport type (stdio or sse)",
126
135
)
127
-
addr := flag.String("sse-address", "localhost:8000", "The host and port to start the sse server on")
136
+
addr := flag.String("address", "localhost:8000", "The host and port to start the sse server on")
128
137
basePath := flag.String("base-path", "", "Base path for the sse server")
138
+
endpointPath := flag.String("endpoint-path", "/mcp", "Endpoint path for the streamable-http server")
129
139
logLevel := flag.String("log-level", "info", "Log level (debug, info, warn, error)")
130
140
var dt disabledTools
131
141
dt.addFlags()
132
142
var gc grafanaConfig
133
143
gc.addFlags()
134
144
flag.Parse()
135
145
136
-
if err := run(transport, *addr, *basePath, parseLevel(*logLevel), dt, gc); err != nil {
146
+
if err := run(transport, *addr, *basePath, *endpointPath, parseLevel(*logLevel), dt, gc); err != nil {
137
147
panic(err)
138
148
}
139
149
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4