Skip to content

Commit 3f7fa09

Browse files
committed
add /openapi for SSE transport, even without JWE token, when JWE enabled, fix wrong config override from CLI to allow /openapi endpoint, even without JWE token, fix #15
Signed-off-by: Slach <[email protected]>
1 parent f3d5f3f commit 3f7fa09

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v1.1.2
2+
BUG FIXES
3+
- add /openapi for SSE transport, even without JWE token, when JWE enabled, fix wrong config override from CLI to allow `/openapi` endpoint, even without JWE token, fix https://github.com/Altinity/altinity-mcp/issues/15
4+
15
# v1.1.1
26
IMPROVEMENTS
37
- make `--jwt-secret-key` optional to use JSON serialization+JWE encryption instead of JWT signing+JWE encryption, fix https://github.com/Altinity/altinity-mcp/issues/25

cmd/altinity-mcp/main.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ func (a *application) startHTTPServer(cfg config.Config, mcpServer *server.MCPSe
536536
mux.HandleFunc("/{token}/openapi/list_tables", serverInjectorOpenAPI)
537537
mux.HandleFunc("/{token}/openapi/describe_table", serverInjectorOpenAPI)
538538
mux.HandleFunc("/{token}/openapi/execute_query", serverInjectorOpenAPI)
539-
log.Info().Str("url", fmt.Sprintf("%s://%s:%d/{token}/openapi", openAPIProtocol, cfg.Server.Address, cfg.Server.Port)).Msg("Started OpenAPI listening")
539+
log.Info().Str("url", fmt.Sprintf("%s://%s:%d/{token}/openapi", openAPIProtocol, cfg.Server.Address, cfg.Server.Port)).Msg("OpenAPI server listening")
540540
}
541541
mux.HandleFunc("/health", a.healthHandler)
542542
mux.HandleFunc("/jwe-token-generator", a.jweTokenGeneratorHandler)
@@ -551,7 +551,7 @@ func (a *application) startHTTPServer(cfg config.Config, mcpServer *server.MCPSe
551551
mux.HandleFunc("/openapi/list_tables", serverInjectorOpenAPI)
552552
mux.HandleFunc("/openapi/describe_table", serverInjectorOpenAPI)
553553
mux.HandleFunc("/openapi/execute_query", serverInjectorOpenAPI)
554-
log.Info().Str("url", fmt.Sprintf("%s://%s:%d/openapi", openAPIProtocol, cfg.Server.Address, cfg.Server.Port)).Msg("Started OpenAPI listening")
554+
log.Info().Str("url", fmt.Sprintf("%s://%s:%d/openapi", openAPIProtocol, cfg.Server.Address, cfg.Server.Port)).Msg("OpenAPI server listening")
555555
}
556556
mux.HandleFunc("/health", a.healthHandler)
557557
mux.HandleFunc("/jwe-token-generator", a.jweTokenGeneratorHandler)
@@ -636,11 +636,12 @@ func (a *application) startSSEServer(cfg config.Config, mcpServer *server.MCPSer
636636
mux.Handle("/{token}/sse", serverInjector(tokenInjector(sseServer.SSEHandler())))
637637
mux.Handle("/{token}/message", serverInjector(tokenInjector(sseServer.MessageHandler())))
638638
if cfg.Server.OpenAPI.Enabled {
639+
mux.HandleFunc("/openapi", a.mcpServer.ServeOpenAPISchema)
639640
mux.HandleFunc("/{token}/openapi", serverInjectorOpenAPI)
640641
mux.HandleFunc("/{token}/openapi/list_tables", serverInjectorOpenAPI)
641642
mux.HandleFunc("/{token}/openapi/describe_table", serverInjectorOpenAPI)
642643
mux.HandleFunc("/{token}/openapi/execute_query", serverInjectorOpenAPI)
643-
log.Info().Str("url", fmt.Sprintf("%s://%s:%d/{token}/openapi", openAPIProtocol, cfg.Server.Address, cfg.Server.Port)).Msg("Started OpenAPI listening")
644+
log.Info().Str("url", fmt.Sprintf("%s://%s:%d/{token}/openapi", openAPIProtocol, cfg.Server.Address, cfg.Server.Port)).Msg("OpenAPI server listening")
644645
}
645646
mux.HandleFunc("/health", a.healthHandler)
646647
mux.HandleFunc("/jwe-token-generator", a.jweTokenGeneratorHandler)
@@ -656,7 +657,7 @@ func (a *application) startSSEServer(cfg config.Config, mcpServer *server.MCPSer
656657
mux.HandleFunc("/openapi/list_tables", serverInjectorOpenAPI)
657658
mux.HandleFunc("/openapi/describe_table", serverInjectorOpenAPI)
658659
mux.HandleFunc("/openapi/execute_query", serverInjectorOpenAPI)
659-
log.Info().Str("url", fmt.Sprintf("%s://%s:%d/openapi", openAPIProtocol, cfg.Server.Address, cfg.Server.Port)).Msg("Started OpenAPI listening")
660+
log.Info().Str("url", fmt.Sprintf("%s://%s:%d/openapi", openAPIProtocol, cfg.Server.Address, cfg.Server.Port)).Msg("OpenAPI server listening")
660661
}
661662
mux.HandleFunc("/health", a.healthHandler)
662663
mux.HandleFunc("/jwe-token-generator", a.jweTokenGeneratorHandler)
@@ -898,9 +899,6 @@ func overrideWithCLIFlags(cfg *config.Config, cmd CommandInterface) {
898899
case "https":
899900
cfg.Server.OpenAPI.Enabled = true
900901
cfg.Server.OpenAPI.TLS = true
901-
default:
902-
cfg.Server.OpenAPI.Enabled = false
903-
cfg.Server.OpenAPI.TLS = false
904902
}
905903

906904
// Override Server TLS config with CLI flags
@@ -1220,6 +1218,7 @@ func (a *application) Start() error {
12201218
log.Info().
12211219
Str("transport", string(cfg.Server.Transport)).
12221220
Bool("jwe_enabled", cfg.Server.JWE.Enabled).
1221+
Bool("openapi_enabled", cfg.Server.OpenAPI.Enabled).
12231222
Msg("Starting MCP server...")
12241223

12251224
// Access the underlying MCPServer from our ClickHouseJWEServer

0 commit comments

Comments
 (0)