// MCPProfilesService + MCPCatalogService -- the IA-parity public CRUD
// surface for fraser's MCP feature set.
//
// Two services live in the same package because they share the MCP
// resource family:
//   - MCPProfilesService manages MCP server registrations scoped to
//     (user_id, customer_id, project_id) in mcp_profiles. A profile is
//     what an end user adds when they want their data plane to call out
//     to a remote MCP server they own, with API-key or OAuth credentials
//     attached.
//   - MCPCatalogService manages the platform-curated "official" MCP
//     server catalog (mcp_catalog_servers table). Operators publish a
//     server here; end users see it in the dashboard and CLI when they
//     pick what to add.
//
// Data access is delegated to the existing Drizzle-owned tables
// (`mcp_profiles`, `mcp_catalog_servers`); handlers in svc/internal/mcpsvc
// are a thin REST/CLI facade over those rows -- no parallel schema
// lives here.
//
// Profiles are scoped per (user_id, customer_id, project_id). A profile
// owned by user A in (customer X, project P) is invisible to user A in
// (customer X, project Q) and to any other user. The CLI surface uses
// --user-id together with --customer-id and --project-id to identify the
// owning scope, matching how aikeys.v1 surfaces per-customer/per-project
// scoping today.
//
// The data-plane lookup path (tars.lookup.v1.GetMCPProfileByURL) is
// the read surface ext_authz uses with aggressive caching; this service
// is the slower CRUD path for customer/operator use.

// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: tars/mcp/v1/mcp.proto

package mcpv1connect

import (
	connect "connectrpc.com/connect"
	context "context"
	errors "errors"
	v1 "github.com/tetrateio/agentrouter-go/genapi/api/tars/mcp/v1"
	emptypb "google.golang.org/protobuf/types/known/emptypb"
	http "net/http"
	strings "strings"
)

// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0

const (
	// MCPProfilesServiceName is the fully-qualified name of the MCPProfilesService service.
	MCPProfilesServiceName = "tars.mcp.v1.MCPProfilesService"
	// MCPCatalogServiceName is the fully-qualified name of the MCPCatalogService service.
	MCPCatalogServiceName = "tars.mcp.v1.MCPCatalogService"
)

// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
	// MCPProfilesServiceCreateMCPProfileProcedure is the fully-qualified name of the
	// MCPProfilesService's CreateMCPProfile RPC.
	MCPProfilesServiceCreateMCPProfileProcedure = "/tars.mcp.v1.MCPProfilesService/CreateMCPProfile"
	// MCPProfilesServiceGetMCPProfileProcedure is the fully-qualified name of the MCPProfilesService's
	// GetMCPProfile RPC.
	MCPProfilesServiceGetMCPProfileProcedure = "/tars.mcp.v1.MCPProfilesService/GetMCPProfile"
	// MCPProfilesServiceListMCPProfilesProcedure is the fully-qualified name of the
	// MCPProfilesService's ListMCPProfiles RPC.
	MCPProfilesServiceListMCPProfilesProcedure = "/tars.mcp.v1.MCPProfilesService/ListMCPProfiles"
	// MCPProfilesServiceUpdateMCPProfileProcedure is the fully-qualified name of the
	// MCPProfilesService's UpdateMCPProfile RPC.
	MCPProfilesServiceUpdateMCPProfileProcedure = "/tars.mcp.v1.MCPProfilesService/UpdateMCPProfile"
	// MCPProfilesServiceDeleteMCPProfileProcedure is the fully-qualified name of the
	// MCPProfilesService's DeleteMCPProfile RPC.
	MCPProfilesServiceDeleteMCPProfileProcedure = "/tars.mcp.v1.MCPProfilesService/DeleteMCPProfile"
	// MCPCatalogServiceUpsertCatalogServerProcedure is the fully-qualified name of the
	// MCPCatalogService's UpsertCatalogServer RPC.
	MCPCatalogServiceUpsertCatalogServerProcedure = "/tars.mcp.v1.MCPCatalogService/UpsertCatalogServer"
	// MCPCatalogServiceGetCatalogServerProcedure is the fully-qualified name of the MCPCatalogService's
	// GetCatalogServer RPC.
	MCPCatalogServiceGetCatalogServerProcedure = "/tars.mcp.v1.MCPCatalogService/GetCatalogServer"
	// MCPCatalogServiceListCatalogServersProcedure is the fully-qualified name of the
	// MCPCatalogService's ListCatalogServers RPC.
	MCPCatalogServiceListCatalogServersProcedure = "/tars.mcp.v1.MCPCatalogService/ListCatalogServers"
	// MCPCatalogServiceSetCatalogServerEnabledProcedure is the fully-qualified name of the
	// MCPCatalogService's SetCatalogServerEnabled RPC.
	MCPCatalogServiceSetCatalogServerEnabledProcedure = "/tars.mcp.v1.MCPCatalogService/SetCatalogServerEnabled"
	// MCPCatalogServiceDeleteCatalogServerProcedure is the fully-qualified name of the
	// MCPCatalogService's DeleteCatalogServer RPC.
	MCPCatalogServiceDeleteCatalogServerProcedure = "/tars.mcp.v1.MCPCatalogService/DeleteCatalogServer"
)

// MCPProfilesServiceClient is a client for the tars.mcp.v1.MCPProfilesService service.
type MCPProfilesServiceClient interface {
	// CreateMCPProfile registers a new MCP server for a user.
	CreateMCPProfile(context.Context, *connect.Request[v1.CreateMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error)
	// GetMCPProfile returns a single profile by uuid.
	GetMCPProfile(context.Context, *connect.Request[v1.GetMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error)
	// ListMCPProfiles lists every profile owned by the given
	// (user_id, customer_id, project_id) scope.
	ListMCPProfiles(context.Context, *connect.Request[v1.ListMCPProfilesRequest]) (*connect.Response[v1.ListMCPProfilesResponse], error)
	// UpdateMCPProfile updates mutable profile fields. Omitted scalar
	// strings ("") leave the existing value untouched.
	UpdateMCPProfile(context.Context, *connect.Request[v1.UpdateMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error)
	// DeleteMCPProfile soft-deletes a profile (deleted_at set; row kept
	// for FK integrity against historical request logs).
	DeleteMCPProfile(context.Context, *connect.Request[v1.DeleteMCPProfileRequest]) (*connect.Response[emptypb.Empty], error)
}

// NewMCPProfilesServiceClient constructs a client for the tars.mcp.v1.MCPProfilesService service.
// By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped
// responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
// connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewMCPProfilesServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) MCPProfilesServiceClient {
	baseURL = strings.TrimRight(baseURL, "/")
	mCPProfilesServiceMethods := v1.File_tars_mcp_v1_mcp_proto.Services().ByName("MCPProfilesService").Methods()
	return &mCPProfilesServiceClient{
		createMCPProfile: connect.NewClient[v1.CreateMCPProfileRequest, v1.MCPProfile](
			httpClient,
			baseURL+MCPProfilesServiceCreateMCPProfileProcedure,
			connect.WithSchema(mCPProfilesServiceMethods.ByName("CreateMCPProfile")),
			connect.WithClientOptions(opts...),
		),
		getMCPProfile: connect.NewClient[v1.GetMCPProfileRequest, v1.MCPProfile](
			httpClient,
			baseURL+MCPProfilesServiceGetMCPProfileProcedure,
			connect.WithSchema(mCPProfilesServiceMethods.ByName("GetMCPProfile")),
			connect.WithIdempotency(connect.IdempotencyNoSideEffects),
			connect.WithClientOptions(opts...),
		),
		listMCPProfiles: connect.NewClient[v1.ListMCPProfilesRequest, v1.ListMCPProfilesResponse](
			httpClient,
			baseURL+MCPProfilesServiceListMCPProfilesProcedure,
			connect.WithSchema(mCPProfilesServiceMethods.ByName("ListMCPProfiles")),
			connect.WithIdempotency(connect.IdempotencyNoSideEffects),
			connect.WithClientOptions(opts...),
		),
		updateMCPProfile: connect.NewClient[v1.UpdateMCPProfileRequest, v1.MCPProfile](
			httpClient,
			baseURL+MCPProfilesServiceUpdateMCPProfileProcedure,
			connect.WithSchema(mCPProfilesServiceMethods.ByName("UpdateMCPProfile")),
			connect.WithClientOptions(opts...),
		),
		deleteMCPProfile: connect.NewClient[v1.DeleteMCPProfileRequest, emptypb.Empty](
			httpClient,
			baseURL+MCPProfilesServiceDeleteMCPProfileProcedure,
			connect.WithSchema(mCPProfilesServiceMethods.ByName("DeleteMCPProfile")),
			connect.WithClientOptions(opts...),
		),
	}
}

// mCPProfilesServiceClient implements MCPProfilesServiceClient.
type mCPProfilesServiceClient struct {
	createMCPProfile *connect.Client[v1.CreateMCPProfileRequest, v1.MCPProfile]
	getMCPProfile    *connect.Client[v1.GetMCPProfileRequest, v1.MCPProfile]
	listMCPProfiles  *connect.Client[v1.ListMCPProfilesRequest, v1.ListMCPProfilesResponse]
	updateMCPProfile *connect.Client[v1.UpdateMCPProfileRequest, v1.MCPProfile]
	deleteMCPProfile *connect.Client[v1.DeleteMCPProfileRequest, emptypb.Empty]
}

// CreateMCPProfile calls tars.mcp.v1.MCPProfilesService.CreateMCPProfile.
func (c *mCPProfilesServiceClient) CreateMCPProfile(ctx context.Context, req *connect.Request[v1.CreateMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error) {
	return c.createMCPProfile.CallUnary(ctx, req)
}

// GetMCPProfile calls tars.mcp.v1.MCPProfilesService.GetMCPProfile.
func (c *mCPProfilesServiceClient) GetMCPProfile(ctx context.Context, req *connect.Request[v1.GetMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error) {
	return c.getMCPProfile.CallUnary(ctx, req)
}

// ListMCPProfiles calls tars.mcp.v1.MCPProfilesService.ListMCPProfiles.
func (c *mCPProfilesServiceClient) ListMCPProfiles(ctx context.Context, req *connect.Request[v1.ListMCPProfilesRequest]) (*connect.Response[v1.ListMCPProfilesResponse], error) {
	return c.listMCPProfiles.CallUnary(ctx, req)
}

// UpdateMCPProfile calls tars.mcp.v1.MCPProfilesService.UpdateMCPProfile.
func (c *mCPProfilesServiceClient) UpdateMCPProfile(ctx context.Context, req *connect.Request[v1.UpdateMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error) {
	return c.updateMCPProfile.CallUnary(ctx, req)
}

// DeleteMCPProfile calls tars.mcp.v1.MCPProfilesService.DeleteMCPProfile.
func (c *mCPProfilesServiceClient) DeleteMCPProfile(ctx context.Context, req *connect.Request[v1.DeleteMCPProfileRequest]) (*connect.Response[emptypb.Empty], error) {
	return c.deleteMCPProfile.CallUnary(ctx, req)
}

// MCPProfilesServiceHandler is an implementation of the tars.mcp.v1.MCPProfilesService service.
type MCPProfilesServiceHandler interface {
	// CreateMCPProfile registers a new MCP server for a user.
	CreateMCPProfile(context.Context, *connect.Request[v1.CreateMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error)
	// GetMCPProfile returns a single profile by uuid.
	GetMCPProfile(context.Context, *connect.Request[v1.GetMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error)
	// ListMCPProfiles lists every profile owned by the given
	// (user_id, customer_id, project_id) scope.
	ListMCPProfiles(context.Context, *connect.Request[v1.ListMCPProfilesRequest]) (*connect.Response[v1.ListMCPProfilesResponse], error)
	// UpdateMCPProfile updates mutable profile fields. Omitted scalar
	// strings ("") leave the existing value untouched.
	UpdateMCPProfile(context.Context, *connect.Request[v1.UpdateMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error)
	// DeleteMCPProfile soft-deletes a profile (deleted_at set; row kept
	// for FK integrity against historical request logs).
	DeleteMCPProfile(context.Context, *connect.Request[v1.DeleteMCPProfileRequest]) (*connect.Response[emptypb.Empty], error)
}

// NewMCPProfilesServiceHandler builds an HTTP handler from the service implementation. It returns
// the path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewMCPProfilesServiceHandler(svc MCPProfilesServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
	mCPProfilesServiceMethods := v1.File_tars_mcp_v1_mcp_proto.Services().ByName("MCPProfilesService").Methods()
	mCPProfilesServiceCreateMCPProfileHandler := connect.NewUnaryHandler(
		MCPProfilesServiceCreateMCPProfileProcedure,
		svc.CreateMCPProfile,
		connect.WithSchema(mCPProfilesServiceMethods.ByName("CreateMCPProfile")),
		connect.WithHandlerOptions(opts...),
	)
	mCPProfilesServiceGetMCPProfileHandler := connect.NewUnaryHandler(
		MCPProfilesServiceGetMCPProfileProcedure,
		svc.GetMCPProfile,
		connect.WithSchema(mCPProfilesServiceMethods.ByName("GetMCPProfile")),
		connect.WithIdempotency(connect.IdempotencyNoSideEffects),
		connect.WithHandlerOptions(opts...),
	)
	mCPProfilesServiceListMCPProfilesHandler := connect.NewUnaryHandler(
		MCPProfilesServiceListMCPProfilesProcedure,
		svc.ListMCPProfiles,
		connect.WithSchema(mCPProfilesServiceMethods.ByName("ListMCPProfiles")),
		connect.WithIdempotency(connect.IdempotencyNoSideEffects),
		connect.WithHandlerOptions(opts...),
	)
	mCPProfilesServiceUpdateMCPProfileHandler := connect.NewUnaryHandler(
		MCPProfilesServiceUpdateMCPProfileProcedure,
		svc.UpdateMCPProfile,
		connect.WithSchema(mCPProfilesServiceMethods.ByName("UpdateMCPProfile")),
		connect.WithHandlerOptions(opts...),
	)
	mCPProfilesServiceDeleteMCPProfileHandler := connect.NewUnaryHandler(
		MCPProfilesServiceDeleteMCPProfileProcedure,
		svc.DeleteMCPProfile,
		connect.WithSchema(mCPProfilesServiceMethods.ByName("DeleteMCPProfile")),
		connect.WithHandlerOptions(opts...),
	)
	return "/tars.mcp.v1.MCPProfilesService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.URL.Path {
		case MCPProfilesServiceCreateMCPProfileProcedure:
			mCPProfilesServiceCreateMCPProfileHandler.ServeHTTP(w, r)
		case MCPProfilesServiceGetMCPProfileProcedure:
			mCPProfilesServiceGetMCPProfileHandler.ServeHTTP(w, r)
		case MCPProfilesServiceListMCPProfilesProcedure:
			mCPProfilesServiceListMCPProfilesHandler.ServeHTTP(w, r)
		case MCPProfilesServiceUpdateMCPProfileProcedure:
			mCPProfilesServiceUpdateMCPProfileHandler.ServeHTTP(w, r)
		case MCPProfilesServiceDeleteMCPProfileProcedure:
			mCPProfilesServiceDeleteMCPProfileHandler.ServeHTTP(w, r)
		default:
			http.NotFound(w, r)
		}
	})
}

// UnimplementedMCPProfilesServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedMCPProfilesServiceHandler struct{}

func (UnimplementedMCPProfilesServiceHandler) CreateMCPProfile(context.Context, *connect.Request[v1.CreateMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.MCPProfilesService.CreateMCPProfile is not implemented"))
}

func (UnimplementedMCPProfilesServiceHandler) GetMCPProfile(context.Context, *connect.Request[v1.GetMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.MCPProfilesService.GetMCPProfile is not implemented"))
}

func (UnimplementedMCPProfilesServiceHandler) ListMCPProfiles(context.Context, *connect.Request[v1.ListMCPProfilesRequest]) (*connect.Response[v1.ListMCPProfilesResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.MCPProfilesService.ListMCPProfiles is not implemented"))
}

func (UnimplementedMCPProfilesServiceHandler) UpdateMCPProfile(context.Context, *connect.Request[v1.UpdateMCPProfileRequest]) (*connect.Response[v1.MCPProfile], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.MCPProfilesService.UpdateMCPProfile is not implemented"))
}

func (UnimplementedMCPProfilesServiceHandler) DeleteMCPProfile(context.Context, *connect.Request[v1.DeleteMCPProfileRequest]) (*connect.Response[emptypb.Empty], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.MCPProfilesService.DeleteMCPProfile is not implemented"))
}

// MCPCatalogServiceClient is a client for the tars.mcp.v1.MCPCatalogService service.
type MCPCatalogServiceClient interface {
	// UpsertCatalogServer creates or replaces a catalog entry. Idempotent
	// on `id`. Operator-only.
	UpsertCatalogServer(context.Context, *connect.Request[v1.UpsertCatalogServerRequest]) (*connect.Response[v1.MCPCatalogServer], error)
	// GetCatalogServer returns a single catalog entry by id.
	GetCatalogServer(context.Context, *connect.Request[v1.GetCatalogServerRequest]) (*connect.Response[v1.MCPCatalogServer], error)
	// ListCatalogServers returns every catalog entry, including disabled
	// rows so operators can re-enable them. The dashboard's read-only
	// view filters to is_enabled=true.
	ListCatalogServers(context.Context, *connect.Request[v1.ListCatalogServersRequest]) (*connect.Response[v1.ListCatalogServersResponse], error)
	// SetCatalogServerEnabled flips the operator visibility toggle on a
	// catalog entry. Split from UpsertCatalogServer so a re-upsert that
	// refreshes content fields (display_name, url, ...) cannot silently
	// re-enable a previously-disabled row through the proto bool zero
	// value.
	SetCatalogServerEnabled(context.Context, *connect.Request[v1.SetCatalogServerEnabledRequest]) (*connect.Response[v1.MCPCatalogServer], error)
	// DeleteCatalogServer removes a catalog entry by id. Operator-only.
	DeleteCatalogServer(context.Context, *connect.Request[v1.DeleteCatalogServerRequest]) (*connect.Response[emptypb.Empty], error)
}

// NewMCPCatalogServiceClient constructs a client for the tars.mcp.v1.MCPCatalogService service. By
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
// connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewMCPCatalogServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) MCPCatalogServiceClient {
	baseURL = strings.TrimRight(baseURL, "/")
	mCPCatalogServiceMethods := v1.File_tars_mcp_v1_mcp_proto.Services().ByName("MCPCatalogService").Methods()
	return &mCPCatalogServiceClient{
		upsertCatalogServer: connect.NewClient[v1.UpsertCatalogServerRequest, v1.MCPCatalogServer](
			httpClient,
			baseURL+MCPCatalogServiceUpsertCatalogServerProcedure,
			connect.WithSchema(mCPCatalogServiceMethods.ByName("UpsertCatalogServer")),
			connect.WithClientOptions(opts...),
		),
		getCatalogServer: connect.NewClient[v1.GetCatalogServerRequest, v1.MCPCatalogServer](
			httpClient,
			baseURL+MCPCatalogServiceGetCatalogServerProcedure,
			connect.WithSchema(mCPCatalogServiceMethods.ByName("GetCatalogServer")),
			connect.WithIdempotency(connect.IdempotencyNoSideEffects),
			connect.WithClientOptions(opts...),
		),
		listCatalogServers: connect.NewClient[v1.ListCatalogServersRequest, v1.ListCatalogServersResponse](
			httpClient,
			baseURL+MCPCatalogServiceListCatalogServersProcedure,
			connect.WithSchema(mCPCatalogServiceMethods.ByName("ListCatalogServers")),
			connect.WithIdempotency(connect.IdempotencyNoSideEffects),
			connect.WithClientOptions(opts...),
		),
		setCatalogServerEnabled: connect.NewClient[v1.SetCatalogServerEnabledRequest, v1.MCPCatalogServer](
			httpClient,
			baseURL+MCPCatalogServiceSetCatalogServerEnabledProcedure,
			connect.WithSchema(mCPCatalogServiceMethods.ByName("SetCatalogServerEnabled")),
			connect.WithClientOptions(opts...),
		),
		deleteCatalogServer: connect.NewClient[v1.DeleteCatalogServerRequest, emptypb.Empty](
			httpClient,
			baseURL+MCPCatalogServiceDeleteCatalogServerProcedure,
			connect.WithSchema(mCPCatalogServiceMethods.ByName("DeleteCatalogServer")),
			connect.WithClientOptions(opts...),
		),
	}
}

// mCPCatalogServiceClient implements MCPCatalogServiceClient.
type mCPCatalogServiceClient struct {
	upsertCatalogServer     *connect.Client[v1.UpsertCatalogServerRequest, v1.MCPCatalogServer]
	getCatalogServer        *connect.Client[v1.GetCatalogServerRequest, v1.MCPCatalogServer]
	listCatalogServers      *connect.Client[v1.ListCatalogServersRequest, v1.ListCatalogServersResponse]
	setCatalogServerEnabled *connect.Client[v1.SetCatalogServerEnabledRequest, v1.MCPCatalogServer]
	deleteCatalogServer     *connect.Client[v1.DeleteCatalogServerRequest, emptypb.Empty]
}

// UpsertCatalogServer calls tars.mcp.v1.MCPCatalogService.UpsertCatalogServer.
func (c *mCPCatalogServiceClient) UpsertCatalogServer(ctx context.Context, req *connect.Request[v1.UpsertCatalogServerRequest]) (*connect.Response[v1.MCPCatalogServer], error) {
	return c.upsertCatalogServer.CallUnary(ctx, req)
}

// GetCatalogServer calls tars.mcp.v1.MCPCatalogService.GetCatalogServer.
func (c *mCPCatalogServiceClient) GetCatalogServer(ctx context.Context, req *connect.Request[v1.GetCatalogServerRequest]) (*connect.Response[v1.MCPCatalogServer], error) {
	return c.getCatalogServer.CallUnary(ctx, req)
}

// ListCatalogServers calls tars.mcp.v1.MCPCatalogService.ListCatalogServers.
func (c *mCPCatalogServiceClient) ListCatalogServers(ctx context.Context, req *connect.Request[v1.ListCatalogServersRequest]) (*connect.Response[v1.ListCatalogServersResponse], error) {
	return c.listCatalogServers.CallUnary(ctx, req)
}

// SetCatalogServerEnabled calls tars.mcp.v1.MCPCatalogService.SetCatalogServerEnabled.
func (c *mCPCatalogServiceClient) SetCatalogServerEnabled(ctx context.Context, req *connect.Request[v1.SetCatalogServerEnabledRequest]) (*connect.Response[v1.MCPCatalogServer], error) {
	return c.setCatalogServerEnabled.CallUnary(ctx, req)
}

// DeleteCatalogServer calls tars.mcp.v1.MCPCatalogService.DeleteCatalogServer.
func (c *mCPCatalogServiceClient) DeleteCatalogServer(ctx context.Context, req *connect.Request[v1.DeleteCatalogServerRequest]) (*connect.Response[emptypb.Empty], error) {
	return c.deleteCatalogServer.CallUnary(ctx, req)
}

// MCPCatalogServiceHandler is an implementation of the tars.mcp.v1.MCPCatalogService service.
type MCPCatalogServiceHandler interface {
	// UpsertCatalogServer creates or replaces a catalog entry. Idempotent
	// on `id`. Operator-only.
	UpsertCatalogServer(context.Context, *connect.Request[v1.UpsertCatalogServerRequest]) (*connect.Response[v1.MCPCatalogServer], error)
	// GetCatalogServer returns a single catalog entry by id.
	GetCatalogServer(context.Context, *connect.Request[v1.GetCatalogServerRequest]) (*connect.Response[v1.MCPCatalogServer], error)
	// ListCatalogServers returns every catalog entry, including disabled
	// rows so operators can re-enable them. The dashboard's read-only
	// view filters to is_enabled=true.
	ListCatalogServers(context.Context, *connect.Request[v1.ListCatalogServersRequest]) (*connect.Response[v1.ListCatalogServersResponse], error)
	// SetCatalogServerEnabled flips the operator visibility toggle on a
	// catalog entry. Split from UpsertCatalogServer so a re-upsert that
	// refreshes content fields (display_name, url, ...) cannot silently
	// re-enable a previously-disabled row through the proto bool zero
	// value.
	SetCatalogServerEnabled(context.Context, *connect.Request[v1.SetCatalogServerEnabledRequest]) (*connect.Response[v1.MCPCatalogServer], error)
	// DeleteCatalogServer removes a catalog entry by id. Operator-only.
	DeleteCatalogServer(context.Context, *connect.Request[v1.DeleteCatalogServerRequest]) (*connect.Response[emptypb.Empty], error)
}

// NewMCPCatalogServiceHandler builds an HTTP handler from the service implementation. It returns
// the path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewMCPCatalogServiceHandler(svc MCPCatalogServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
	mCPCatalogServiceMethods := v1.File_tars_mcp_v1_mcp_proto.Services().ByName("MCPCatalogService").Methods()
	mCPCatalogServiceUpsertCatalogServerHandler := connect.NewUnaryHandler(
		MCPCatalogServiceUpsertCatalogServerProcedure,
		svc.UpsertCatalogServer,
		connect.WithSchema(mCPCatalogServiceMethods.ByName("UpsertCatalogServer")),
		connect.WithHandlerOptions(opts...),
	)
	mCPCatalogServiceGetCatalogServerHandler := connect.NewUnaryHandler(
		MCPCatalogServiceGetCatalogServerProcedure,
		svc.GetCatalogServer,
		connect.WithSchema(mCPCatalogServiceMethods.ByName("GetCatalogServer")),
		connect.WithIdempotency(connect.IdempotencyNoSideEffects),
		connect.WithHandlerOptions(opts...),
	)
	mCPCatalogServiceListCatalogServersHandler := connect.NewUnaryHandler(
		MCPCatalogServiceListCatalogServersProcedure,
		svc.ListCatalogServers,
		connect.WithSchema(mCPCatalogServiceMethods.ByName("ListCatalogServers")),
		connect.WithIdempotency(connect.IdempotencyNoSideEffects),
		connect.WithHandlerOptions(opts...),
	)
	mCPCatalogServiceSetCatalogServerEnabledHandler := connect.NewUnaryHandler(
		MCPCatalogServiceSetCatalogServerEnabledProcedure,
		svc.SetCatalogServerEnabled,
		connect.WithSchema(mCPCatalogServiceMethods.ByName("SetCatalogServerEnabled")),
		connect.WithHandlerOptions(opts...),
	)
	mCPCatalogServiceDeleteCatalogServerHandler := connect.NewUnaryHandler(
		MCPCatalogServiceDeleteCatalogServerProcedure,
		svc.DeleteCatalogServer,
		connect.WithSchema(mCPCatalogServiceMethods.ByName("DeleteCatalogServer")),
		connect.WithHandlerOptions(opts...),
	)
	return "/tars.mcp.v1.MCPCatalogService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		switch r.URL.Path {
		case MCPCatalogServiceUpsertCatalogServerProcedure:
			mCPCatalogServiceUpsertCatalogServerHandler.ServeHTTP(w, r)
		case MCPCatalogServiceGetCatalogServerProcedure:
			mCPCatalogServiceGetCatalogServerHandler.ServeHTTP(w, r)
		case MCPCatalogServiceListCatalogServersProcedure:
			mCPCatalogServiceListCatalogServersHandler.ServeHTTP(w, r)
		case MCPCatalogServiceSetCatalogServerEnabledProcedure:
			mCPCatalogServiceSetCatalogServerEnabledHandler.ServeHTTP(w, r)
		case MCPCatalogServiceDeleteCatalogServerProcedure:
			mCPCatalogServiceDeleteCatalogServerHandler.ServeHTTP(w, r)
		default:
			http.NotFound(w, r)
		}
	})
}

// UnimplementedMCPCatalogServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedMCPCatalogServiceHandler struct{}

func (UnimplementedMCPCatalogServiceHandler) UpsertCatalogServer(context.Context, *connect.Request[v1.UpsertCatalogServerRequest]) (*connect.Response[v1.MCPCatalogServer], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.MCPCatalogService.UpsertCatalogServer is not implemented"))
}

func (UnimplementedMCPCatalogServiceHandler) GetCatalogServer(context.Context, *connect.Request[v1.GetCatalogServerRequest]) (*connect.Response[v1.MCPCatalogServer], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.MCPCatalogService.GetCatalogServer is not implemented"))
}

func (UnimplementedMCPCatalogServiceHandler) ListCatalogServers(context.Context, *connect.Request[v1.ListCatalogServersRequest]) (*connect.Response[v1.ListCatalogServersResponse], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.MCPCatalogService.ListCatalogServers is not implemented"))
}

func (UnimplementedMCPCatalogServiceHandler) SetCatalogServerEnabled(context.Context, *connect.Request[v1.SetCatalogServerEnabledRequest]) (*connect.Response[v1.MCPCatalogServer], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.MCPCatalogService.SetCatalogServerEnabled is not implemented"))
}

func (UnimplementedMCPCatalogServiceHandler) DeleteCatalogServer(context.Context, *connect.Request[v1.DeleteCatalogServerRequest]) (*connect.Response[emptypb.Empty], error) {
	return nil, connect.NewError(connect.CodeUnimplemented, errors.New("tars.mcp.v1.MCPCatalogService.DeleteCatalogServer is not implemented"))
}
