mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2025-08-23 14:23:05 +00:00
refactor: refactor logging and server setup for clarity and structure (#64)
- Refactor server initialization calls in Run to use multiline construction style and explicitly pass options in HTTP mode - Fix logic in Default to prevent redundant logger initialization - Remove unused Logger function and introduce a Logger struct with Infof and Errorf methods for structured logging - Add a New function for creating instances of the Logger struct Signed-off-by: appleboy <appleboy.tw@gmail.com> Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/64 Co-authored-by: appleboy <appleboy.tw@gmail.com> Co-committed-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
@@ -44,17 +44,24 @@ func Run() error {
|
||||
RegisterTool(mcpServer)
|
||||
switch flag.Mode {
|
||||
case "stdio":
|
||||
if err := server.ServeStdio(mcpServer); err != nil {
|
||||
if err := server.ServeStdio(
|
||||
mcpServer,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
case "sse":
|
||||
sseServer := server.NewSSEServer(mcpServer)
|
||||
sseServer := server.NewSSEServer(
|
||||
mcpServer,
|
||||
)
|
||||
log.Infof("Gitea MCP SSE server listening on :%d", flag.Port)
|
||||
if err := sseServer.Start(fmt.Sprintf(":%d", flag.Port)); err != nil {
|
||||
return err
|
||||
}
|
||||
case "http":
|
||||
httpServer := server.NewStreamableHTTPServer(mcpServer)
|
||||
httpServer := server.NewStreamableHTTPServer(
|
||||
mcpServer,
|
||||
server.WithLogger(log.New()),
|
||||
)
|
||||
log.Infof("Gitea MCP HTTP server listening on :%d", flag.Port)
|
||||
if err := httpServer.Start(fmt.Sprintf(":%d", flag.Port)); err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user