diff --git a/cmd/BUILD.bazel b/cmd/BUILD.bazel index 7eb7869..54b3ea7 100644 --- a/cmd/BUILD.bazel +++ b/cmd/BUILD.bazel @@ -21,8 +21,8 @@ go_library( deps = [ "//pkg", "//pkg/auth", - "//pkg/common", "@com_github_eat_pray_ai_cobra_mcp//:cobra-mcp", + "@com_github_modelcontextprotocol_go_sdk//mcp", "@com_github_savioxavier_termlink//:termlink", "@com_github_spf13_cobra//:cobra", ], diff --git a/cmd/mcp.go b/cmd/mcp.go index 1cfff9c..03dc880 100644 --- a/cmd/mcp.go +++ b/cmd/mcp.go @@ -4,11 +4,9 @@ package cmd import ( - "fmt" - cobramcp "github.com/eat-pray-ai/cobra-mcp" "github.com/eat-pray-ai/yutu/pkg/auth" - "github.com/eat-pray-ai/yutu/pkg/common" + "github.com/modelcontextprotocol/go-sdk/mcp" "github.com/spf13/cobra" ) @@ -27,7 +25,16 @@ yutu mcp --mode http --baseUrl https://mcp.example.com` var mcpConfig = &cobramcp.Config{ Name: "yutu", Version: Version, - Instructions: "Automate YouTube operations", + ListCacheTTL: 7_200_000, + ServerOptions: &mcp.ServerOptions{ + Instructions: "Automate YouTube operations", + }, + HTTPOptions: &mcp.StreamableHTTPOptions{ + Stateless: true, + JSONResponse: true, + MaxRequestBodyBytes: 2 << 20, + PropagateRequestCancellation: true, + }, } var Server, mcpCmd = cobramcp.ServerAndCommand(mcpConfig) @@ -44,10 +51,6 @@ func init() { Scopes: auth.Scopes, AuthorizationServers: []string{"https://accounts.google.com"}, } - } else { - port, _ := cmd.Flags().GetInt("port") - redirectURL := fmt.Sprintf("http://localhost:%d", port) - cmd.SetContext(common.CtxWithRedirectURL(cmd.Context(), redirectURL)) } return nil diff --git a/pkg/common/common.go b/pkg/common/common.go index f71d354..e58bff3 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -21,13 +21,6 @@ import ( "google.golang.org/api/youtube/v3" ) -type redirectURLKey struct{} - -// CtxWithRedirectURL returns a child context carrying the OAuth redirect URL. -func CtxWithRedirectURL(ctx context.Context, url string) context.Context { - return context.WithValue(ctx, redirectURLKey{}, url) -} - type Fields struct { Ctx context.Context `yaml:"-" json:"-"` Service *youtube.Service `yaml:"-" json:"-"` @@ -51,11 +44,6 @@ func (d *Fields) GetFields() *Fields { // automatic context injection from MCP tool handlers. func (d *Fields) SetContext(ctx context.Context) { d.Ctx = ctx - if d.RedirectURL == "" { - if url, ok := ctx.Value(redirectURLKey{}).(string); ok { - d.RedirectURL = url - } - } } func (d *Fields) EnsureService() error {