Files
gitea-mcp/cmd/cmd.go
appleboy 88471b5de0 refactor: remove SSE transport support from code and documentation (#97)
- Remove support and documentation for sse mode across all language README files
- Update CLI flags and help text to exclude references to sse mode
- Remove SSE server initialization in operation logic
- Adjust error messages to only mention stdio and http transport types
- Update logging setup to remove sse mode conditional logging

See the latest documentation: https://modelcontextprotocol.io/specification/2025-06-18/basic/transports

Signed-off-by: appleboy <appleboy.tw@gmail.com>

Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/97
Co-authored-by: appleboy <appleboy.tw@gmail.com>
Co-committed-by: appleboy <appleboy.tw@gmail.com>
2025-09-27 08:01:56 +00:00

111 lines
1.7 KiB
Go

package cmd
import (
"context"
"flag"
"os"
"gitea.com/gitea/gitea-mcp/operation"
flagPkg "gitea.com/gitea/gitea-mcp/pkg/flag"
"gitea.com/gitea/gitea-mcp/pkg/log"
)
var (
host string
port int
token string
)
func init() {
flag.StringVar(
&flagPkg.Mode,
"t",
"stdio",
"Transport type (stdio or http)",
)
flag.StringVar(
&flagPkg.Mode,
"transport",
"stdio",
"Transport type (stdio or http)",
)
flag.StringVar(
&host,
"host",
os.Getenv("GITEA_HOST"),
"Gitea host",
)
flag.IntVar(
&port,
"port",
8080,
"http port",
)
flag.StringVar(
&token,
"token",
"",
"Your personal access token",
)
flag.BoolVar(
&flagPkg.ReadOnly,
"read-only",
false,
"Read-only mode",
)
flag.BoolVar(
&flagPkg.Debug,
"d",
false,
"debug mode (If -d flag is provided, debug mode will be enabled by default)",
)
flag.BoolVar(
&flagPkg.Insecure,
"insecure",
false,
"ignore TLS certificate errors",
)
flag.Parse()
flagPkg.Host = host
if flagPkg.Host == "" {
flagPkg.Host = "https://gitea.com"
}
flagPkg.Port = port
flagPkg.Token = token
if flagPkg.Token == "" {
flagPkg.Token = os.Getenv("GITEA_ACCESS_TOKEN")
}
if os.Getenv("MCP_MODE") != "" {
flagPkg.Mode = os.Getenv("MCP_MODE")
}
if os.Getenv("GITEA_READONLY") == "true" {
flagPkg.ReadOnly = true
}
if os.Getenv("GITEA_DEBUG") == "true" {
flagPkg.Debug = true
}
// Set insecure mode based on environment variable
if os.Getenv("GITEA_INSECURE") == "true" {
flagPkg.Insecure = true
}
}
func Execute() {
defer log.Default().Sync()
if err := operation.Run(); err != nil {
if err == context.Canceled {
log.Info("Server shutdown due to context cancellation")
return
}
log.Fatalf("Run Gitea MCP Server Error: %v", err)
}
}