MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / Start

Method Start

pkg/mcp/server.go:66–85  ·  view source on GitHub ↗

Start binds to cfg.Addr() and serves using streamable HTTP transport. It blocks until ctx is cancelled or a fatal error occurs.

(ctx context.Context)

Source from the content-addressed store, hash-verified

64// Start binds to cfg.Addr() and serves using streamable HTTP transport.
65// It blocks until ctx is cancelled or a fatal error occurs.
66func (s *Server) Start(ctx context.Context) error {
67 streamSrv := mcpserver.NewStreamableHTTPServer(s.mcpSrv)
68 wrapped := BearerAuthMiddleware(s.cfg, streamSrv)
69
70 httpSrv := &http.Server{
71 Addr: s.cfg.Addr(),
72 Handler: wrapped,
73 }
74
75 go func() {
76 <-ctx.Done()
77 _ = httpSrv.Shutdown(context.Background())
78 }()
79
80 log.Printf("gosqlx-mcp: listening on %s (auth=%v)\n", s.cfg.Addr(), s.cfg.AuthEnabled())
81 if err := httpSrv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
82 return fmt.Errorf("server error: %w", err)
83 }
84 return nil
85}
86
87// registerTools adds all 7 GoSQLX tools with their JSON Schema definitions.
88func (s *Server) registerTools() {

Callers 5

newInProcessClientFunction · 0.80
InstrumentedParseFunction · 0.80

Calls 4

BearerAuthMiddlewareFunction · 0.85
AddrMethod · 0.80
AuthEnabledMethod · 0.80
ErrorfMethod · 0.65

Tested by 4

newInProcessClientFunction · 0.64