refactor(mcp): remove dead stdio transport state
Drop the unused stdioMode field, route Run() through ServeStdio(), and keep startup logging on the service logger. Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
17280b0aed
commit
102097222d
3 changed files with 2 additions and 9 deletions
|
|
@ -39,7 +39,6 @@ type Service struct {
|
|||
wsServer *http.Server // WebSocket HTTP server (optional)
|
||||
wsAddr string // WebSocket server address
|
||||
wsMu sync.Mutex // Protects wsServer and wsAddr
|
||||
stdioMode bool // True when running via stdio transport
|
||||
tools []ToolRecord // Parallel tool registry for REST bridge
|
||||
}
|
||||
|
||||
|
|
@ -668,11 +667,7 @@ func (s *Service) Run(ctx context.Context) error {
|
|||
if addr := core.Env("MCP_ADDR"); addr != "" {
|
||||
return s.ServeTCP(ctx, addr)
|
||||
}
|
||||
s.stdioMode = true
|
||||
return s.server.Run(ctx, &mcp.IOTransport{
|
||||
Reader: os.Stdin,
|
||||
Writer: sharedStdout,
|
||||
})
|
||||
return s.ServeStdio(ctx)
|
||||
}
|
||||
|
||||
// countOccurrences counts non-overlapping instances of substr in s.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"context"
|
||||
|
||||
core "dappco.re/go/core"
|
||||
"forge.lthn.ai/core/go-log"
|
||||
)
|
||||
|
||||
// Register is the service factory for core.WithService.
|
||||
|
|
@ -68,7 +67,7 @@ func (s *Service) OnStartup(ctx context.Context) core.Result {
|
|||
c.Command("serve", core.Command{
|
||||
Description: "Start as a persistent HTTP daemon",
|
||||
Action: func(opts core.Options) core.Result {
|
||||
log.Default().Info("MCP HTTP server starting")
|
||||
s.logger.Info("MCP HTTP server starting")
|
||||
if err := s.Run(ctx); err != nil {
|
||||
return core.Result{Value: err, OK: false}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import (
|
|||
// }
|
||||
func (s *Service) ServeStdio(ctx context.Context) error {
|
||||
s.logger.Info("MCP Stdio server starting", "user", log.Username())
|
||||
s.stdioMode = true
|
||||
return s.server.Run(ctx, &mcp.IOTransport{
|
||||
Reader: os.Stdin,
|
||||
Writer: sharedStdout,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue