Skip to content

Commit aad8d14

Browse files
feat: add --json-response CLI flag
Merge pull request #131 from zlucas-netapp/zl-json-response
1 parent 5690bdc commit aad8d14

4 files changed

Lines changed: 10 additions & 1 deletion

File tree

cmd/cmds.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type StartCmd struct {
3131
InspectTraffic bool `default:"false" help:"Inspect MCP HTTP traffic"`
3232
ReadOnly bool `default:"false" help:"Run MCP in read-only mode. This disables all tool calls that modify ONTAP state."`
3333
Stateless bool `default:"false" help:"Run in stateless mode (no mcp-session-id header validation). Required when deploying behind proxies or gateways that don't preserve session headers, e.g. on-premises data gateways."`
34+
JSONResponse bool `default:"false" help:"Respond with application/json instead of text/event-stream. Required when deploying behind proxies or gateways that do not relay SSE/chunked responses, e.g. on-premises data gateways."`
3435
}
3536

3637
func (a *StartCmd) Run(cli *CLI) error {
@@ -50,6 +51,7 @@ func (a *StartCmd) Run(cli *CLI) error {
5051
InspectTraffic: cli.Start.InspectTraffic,
5152
ReadOnly: cli.Start.ReadOnly,
5253
Stateless: cli.Start.Stateless,
54+
JSONResponse: cli.Start.JSONResponse,
5355
}
5456

5557
app := server.NewApp(cfg, opts, logger)

docs/install.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Some commonly used flags:
135135
|---|---|
136136
| `--read-only` | Disable all mutating operations. Only read-only tools are registered. |
137137
| `--stateless` | Disable mcp-session-id header validation. Required when deploying behind proxies or gateways that do not preserve session headers, e.g. on-premises data gateways. |
138+
| `--json-response` | Respond with application/json instead of text/event-stream. Required when deploying behind proxies or gateways that do not relay SSE/chunked responses, e.g. on-premises data gateways. |
138139
| `--inspect-traffic` | Log all MCP HTTP request and response bodies for debugging. |
139140

140141
## Next Steps

docs/tools.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ If you want to run the ONTAP MCP server in read-only mode, you can start the ser
1010

1111
To run without mcp-session-id header validation (e.g. behind proxies that strip session headers), use the `--stateless` flag. See the [configuration documentation](install.md#configuration) for more details.
1212

13+
To respond with `application/json` instead of `text/event-stream` (e.g. behind gateways that do not relay SSE/chunked responses), use the `--json-response` flag. See the [configuration documentation](install.md#configuration) for more details.
14+
1315
## API Discovery
1416

1517
- `list_ontap_endpoints` (available when the API catalog is loaded)

server/server.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type Options struct {
3737
Port int
3838
ReadOnly bool
3939
Stateless bool
40+
JSONResponse bool
4041
TestHTTPClient *http.Client // Optional HTTP client for testing
4142
}
4243

@@ -82,6 +83,9 @@ func (a *App) StartServer() {
8283
if a.options.Stateless {
8384
a.logger.Info("MCP server is running in stateless mode; mcp-session-id header validation is disabled")
8485
}
86+
if a.options.JSONResponse {
87+
a.logger.Info("MCP server is responding with application/json instead of text/event-stream")
88+
}
8589
server := a.createMCPServer()
8690
a.runHTTPServer(server)
8791
}
@@ -243,7 +247,7 @@ func (a *App) runHTTPServer(server *mcp.Server) {
243247

244248
handler = mcp.NewStreamableHTTPHandler(func(*http.Request) *mcp.Server {
245249
return server
246-
}, &mcp.StreamableHTTPOptions{Stateless: a.options.Stateless})
250+
}, &mcp.StreamableHTTPOptions{Stateless: a.options.Stateless, JSONResponse: a.options.JSONResponse})
247251

248252
if a.options.InspectTraffic {
249253
prevHandler := handler

0 commit comments

Comments
 (0)