@@ -24,6 +24,7 @@ import (
2424 "github.com/stackql/any-sdk/pkg/logging"
2525 "github.com/stackql/stackql/internal/stackql/acid/tsm_physio"
2626 "github.com/stackql/stackql/internal/stackql/entryutil"
27+ "github.com/stackql/stackql/internal/stackql/handler"
2728 "github.com/stackql/stackql/internal/stackql/iqlerror"
2829 "github.com/stackql/stackql/internal/stackql/mcpbackend"
2930 "github.com/stackql/stackql/pkg/mcp_server"
@@ -52,35 +53,42 @@ var mcpSrvCmd = &cobra.Command{
5253 handlerCtx , err := entryutil .BuildHandlerContext (runtimeCtx , nil , queryCache , inputBundle , false )
5354 iqlerror .PrintErrorAndExitOneIfError (err )
5455 iqlerror .PrintErrorAndExitOneIfNil (handlerCtx , "handler context is unexpectedly nil" )
55- var config mcp_server.Config
56- json .Unmarshal ([]byte (mcpConfig ), & config ) //nolint:errcheck // TODO: investigate
57- config .Server .Transport = mcpServerType
58- var isReadOnly bool
59- if config .Server .IsReadOnly != nil {
60- isReadOnly = * config .Server .IsReadOnly
56+ if mcpServerType == "" {
57+ mcpServerType = "http"
6158 }
62- orchestrator , orchestratorErr := tsm_physio .NewOrchestrator (handlerCtx )
63- iqlerror .PrintErrorAndExitOneIfError (orchestratorErr )
64- iqlerror .PrintErrorAndExitOneIfNil (orchestrator , "orchestrator is unexpectedly nil" )
65- // handlerCtx.SetTSMOrchestrator(orchestrator)
66- backend , backendErr := mcpbackend .NewStackqlMCPBackendService (
67- isReadOnly ,
68- orchestrator ,
69- handlerCtx ,
70- logging .GetLogger (),
71- )
72- iqlerror .PrintErrorAndExitOneIfError (backendErr )
73- iqlerror .PrintErrorAndExitOneIfNil (backend , "mcp backend is unexpectedly nil" )
74-
75- server , serverErr := mcp_server .NewAgnosticBackendServer (
76- backend ,
77- & config ,
78- logging .GetLogger (),
79- )
80- // server, serverErr := mcp_server.NewExampleHTTPBackendServer(
81- // logging.GetLogger(),
82- // )
83- iqlerror .PrintErrorAndExitOneIfError (serverErr )
84- server .Start (context .Background ()) //nolint:errcheck // TODO: investigate
59+ runMCPServer (handlerCtx )
8560 },
8661}
62+
63+ func runMCPServer (handlerCtx handler.HandlerContext ) {
64+ var config mcp_server.Config
65+ json .Unmarshal ([]byte (mcpConfig ), & config ) //nolint:errcheck // TODO: investigate
66+ config .Server .Transport = mcpServerType
67+ var isReadOnly bool
68+ if config .Server .IsReadOnly != nil {
69+ isReadOnly = * config .Server .IsReadOnly
70+ }
71+ orchestrator , orchestratorErr := tsm_physio .NewOrchestrator (handlerCtx )
72+ iqlerror .PrintErrorAndExitOneIfError (orchestratorErr )
73+ iqlerror .PrintErrorAndExitOneIfNil (orchestrator , "orchestrator is unexpectedly nil" )
74+ // handlerCtx.SetTSMOrchestrator(orchestrator)
75+ backend , backendErr := mcpbackend .NewStackqlMCPBackendService (
76+ isReadOnly ,
77+ orchestrator ,
78+ handlerCtx ,
79+ logging .GetLogger (),
80+ )
81+ iqlerror .PrintErrorAndExitOneIfError (backendErr )
82+ iqlerror .PrintErrorAndExitOneIfNil (backend , "mcp backend is unexpectedly nil" )
83+
84+ server , serverErr := mcp_server .NewAgnosticBackendServer (
85+ backend ,
86+ & config ,
87+ logging .GetLogger (),
88+ )
89+ // server, serverErr := mcp_server.NewExampleHTTPBackendServer(
90+ // logging.GetLogger(),
91+ // )
92+ iqlerror .PrintErrorAndExitOneIfError (serverErr )
93+ server .Start (context .Background ()) //nolint:errcheck // TODO: investigate
94+ }
0 commit comments