import { requireProjectPermission } from "../../../middleware/projectAccess.js";
import { OpenAPIHono } from "@hono/zod-openapi";
import { MCPCatalogListResponse, MCPTransportType, TenantProjectParamsSchema, commonGetErrorResponses, fetchComposioServers } from "@inkeep/agents-core";
import { createProtectedRoute } from "@inkeep/agents-core/middleware";

//#region src/domains/manage/routes/mcpCatalog.ts
const app = new OpenAPIHono();
const PREBUILT_MCP_SERVERS = [
	{
		id: "apify",
		name: "Apify",
		url: "https://mcp.apify.com",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://apify.com/img/apify-logo/logomark-32x32.svg",
		category: "automation",
		description: "Web scraping and automation platform"
	},
	{
		id: "asana",
		name: "Asana",
		url: "https://mcp.asana.com/sse",
		transport: MCPTransportType.sse,
		category: "project_management",
		description: "Project management and team collaboration"
	},
	{
		id: "atlassian",
		name: "Atlassian",
		url: "https://mcp.atlassian.com/v1/sse",
		transport: MCPTransportType.sse,
		category: "project_management",
		description: "Jira, Confluence, and other Atlassian products"
	},
	{
		id: "buildkite",
		name: "Buildkite",
		url: "https://mcp.buildkite.com/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://buildkite.com/_astro/buildkite-mark.D56ywXpU.svg",
		category: "ci_cd",
		description: "Continuous integration and deployment"
	},
	{
		id: "canva",
		name: "Canva",
		url: "https://mcp.canva.com/mcp",
		transport: MCPTransportType.streamableHttp,
		category: "design",
		description: "Graphic design and visual content creation"
	},
	{
		id: "carbon-voice",
		name: "Carbon Voice",
		url: "https://mcp.carbonvoice.app",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://static.wixstatic.com/shapes/e97c23_633874d233a944aea7b424ae16e9efec.svg",
		category: "communication",
		description: "Voice and audio communication"
	},
	{
		id: "close",
		name: "Close (CRM)",
		url: "https://mcp.close.com/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://cdn.prod.website-files.com/61717799a852418a278cfa9b/68793d8479790aec5ed95512_close-logo-color-atom.svg",
		category: "crm",
		description: "Customer relationship management"
	},
	{
		id: "cloudflare-docs",
		name: "Cloudflare Docs",
		url: "https://docs.mcp.cloudflare.com/sse",
		transport: MCPTransportType.sse,
		isOpen: true,
		imageUrl: "https://www.cloudflare.com/favicon.ico",
		category: "documentation",
		description: "Cloudflare documentation search"
	},
	{
		id: "cloudflare-observability",
		name: "Cloudflare Observability",
		url: "https://observability.mcp.cloudflare.com/sse",
		transport: MCPTransportType.sse,
		imageUrl: "https://www.cloudflare.com/favicon.ico",
		category: "monitoring",
		description: "Cloudflare observability and monitoring"
	},
	{
		id: "cloudflare-workers",
		name: "Cloudflare Workers Bindings",
		url: "https://bindings.mcp.cloudflare.com/sse",
		transport: MCPTransportType.sse,
		imageUrl: "https://www.cloudflare.com/favicon.ico",
		category: "infrastructure",
		description: "Cloudflare Workers and serverless functions"
	},
	{
		id: "cloudinary",
		name: "Cloudinary (Asset Management)",
		url: "https://asset-management.mcp.cloudinary.com/sse",
		transport: MCPTransportType.sse,
		imageUrl: "https://cloudinary.com/wp-content/uploads/sites/6/2020/09/favicon-32x32-1.png",
		category: "media",
		description: "Digital asset management and media optimization"
	},
	{
		id: "deepwiki",
		name: "DeepWiki",
		url: "https://mcp.deepwiki.com/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://deepwiki.org/apple-icon.png?a4f658907db0ab87",
		isOpen: true,
		category: "knowledge",
		description: "Knowledge base and documentation search"
	},
	{
		id: "dodo-payments",
		name: "Dodo Payments",
		url: "https://mcp.dodopayments.com/sse",
		transport: MCPTransportType.sse,
		imageUrl: "https://docs.dodopayments.com/mintlify-assets/_mintlify/favicons/dodopayments/O4gqzjfBTOvqqqpw/_generated/favicon/favicon-32x32.png",
		category: "payments",
		description: "Payment processing and billing"
	},
	{
		id: "egnyte",
		name: "Egnyte",
		url: "https://mcp-server.egnyte.com/sse",
		transport: MCPTransportType.sse,
		category: "storage",
		description: "Enterprise file sharing and collaboration"
	},
	{
		id: "fireflies",
		name: "Fireflies",
		url: "https://api.fireflies.ai/mcp",
		transport: MCPTransportType.streamableHttp,
		category: "communication",
		description: "Meeting notes and transcription"
	},
	{
		id: "globalping",
		name: "Globalping",
		url: "https://mcp.globalping.dev/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://globalping.io/icons/favicon-32x32.png",
		category: "monitoring",
		description: "Global network monitoring and testing"
	},
	{
		id: "huggingface",
		name: "Hugging Face",
		url: "https://huggingface.co/mcp?login",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://huggingface.co/front/assets/huggingface_logo-noborder.svg",
		category: "ai",
		description: "Machine learning models and datasets"
	},
	{
		id: "instant",
		name: "Instant (InstantDB)",
		url: "https://mcp.instantdb.com/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://www.instantdb.com/img/icon/logo-512.svg",
		category: "database",
		description: "Real-time database"
	},
	{
		id: "intercom",
		name: "Intercom",
		url: "https://mcp.intercom.com/mcp",
		transport: MCPTransportType.streamableHttp,
		category: "communication",
		description: "Customer messaging and support"
	},
	{
		id: "invideo",
		name: "Invideo",
		url: "https://mcp.invideo.io/sse",
		transport: MCPTransportType.sse,
		isOpen: true,
		imageUrl: "https://web-assets.invideo.io/favicons/prod/black_favicon.ico",
		category: "media",
		description: "Video creation and editing"
	},
	{
		id: "jam-dev",
		name: "Jam.dev",
		url: "https://mcp.jam.dev/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://jam.dev/favicon.ico?cache-bust=2",
		category: "development",
		description: "Bug reporting and debugging"
	},
	{
		id: "linear",
		name: "Linear",
		url: "https://mcp.linear.app/mcp",
		transport: MCPTransportType.streamableHttp,
		category: "project_management",
		description: "Issue tracking and project management"
	},
	{
		id: "monday",
		name: "Monday",
		url: "https://mcp.monday.com/sse",
		transport: MCPTransportType.sse,
		category: "project_management",
		description: "Work operating system and project management"
	},
	{
		id: "needle",
		name: "Needle",
		url: "https://mcp.needle-ai.com/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://needle.app/images/favicon.png",
		category: "ai",
		description: "AI-powered search and insights"
	},
	{
		id: "neon",
		name: "Neon",
		url: "https://mcp.neon.tech/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://neon.com/favicon/favicon.png",
		category: "database",
		description: "Serverless Postgres database"
	},
	{
		id: "netlify",
		name: "Netlify",
		url: "https://netlify-mcp.netlify.app/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://www.netlify.com/favicon/apple-touch-icon.png",
		category: "infrastructure",
		description: "Web hosting and deployment"
	},
	{
		id: "notion",
		name: "Notion",
		url: "https://mcp.notion.com/mcp",
		transport: MCPTransportType.streamableHttp,
		category: "knowledge",
		description: "Notes, docs, and knowledge management"
	},
	{
		id: "octagon-agents",
		name: "Octagon Agents (Market Intel)",
		url: "https://mcp.octagonagents.com/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://cdn.prod.website-files.com/67e20964923f8dc825a5dbd0/67e20964923f8dc825a5dc20_favico.png",
		category: "analytics",
		description: "Market intelligence and analytics"
	},
	{
		id: "paypal",
		name: "PayPal",
		url: "https://mcp.paypal.com",
		transport: MCPTransportType.streamableHttp,
		category: "payments",
		description: "Payment processing"
	},
	{
		id: "pipeboard-meta-ads",
		name: "Pipeboard – Meta Ads",
		url: "https://mcp.pipeboard.co/meta-ads-mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://pipeboard.co/favicon.ico",
		category: "marketing",
		description: "Meta (Facebook) advertising management"
	},
	{
		id: "posthog",
		name: "PostHog",
		url: "https://mcp.posthog.com/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://posthog.com/favicon.svg?v=6e5ac8d4a5b381b5caa29396fbf7c955",
		category: "analytics",
		description: "Analytics and event tracking"
	},
	{
		id: "prisma",
		name: "Prisma",
		url: "https://mcp.prisma.io/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://www.prisma.io/docs/img/favicon.png",
		category: "database",
		description: "Database ORM and toolkit"
	},
	{
		id: "ramp",
		name: "Ramp",
		url: "https://mcp.ramp.com/mcp",
		transport: MCPTransportType.streamableHttp,
		category: "finance",
		description: "Corporate cards and spend management"
	},
	{
		id: "rube",
		name: "Rube",
		url: "https://rube.app/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://rube.app/favicon.ico",
		category: "automation",
		description: "Workflow automation"
	},
	{
		id: "semgrep",
		name: "Semgrep",
		url: "https://mcp.semgrep.ai/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://semgrep.dev/build/assets/favicon-CIx-xpG_.svg",
		isOpen: true,
		category: "security",
		description: "Code security and static analysis"
	},
	{
		id: "sentry",
		name: "Sentry",
		url: "https://mcp.sentry.dev",
		transport: MCPTransportType.streamableHttp,
		category: "monitoring",
		description: "Error tracking and performance monitoring"
	},
	{
		id: "simplescraper",
		name: "Simplescraper",
		url: "https://mcp.simplescraper.io/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://simplescraper.io/favicon.ico",
		category: "automation",
		description: "Web scraping and data extraction"
	},
	{
		id: "square",
		name: "Square",
		url: "https://mcp.squareup.com/sse",
		transport: MCPTransportType.sse,
		imageUrl: "https://pw-renderer-production-c.squarecdn.com/c94e4b9deb6727292b842f0dc29355f408487bf2/_svelte/favicon.ico",
		category: "payments",
		description: "Point of sale and payment processing"
	},
	{
		id: "stripe",
		name: "Stripe",
		url: "https://mcp.stripe.com",
		transport: MCPTransportType.streamableHttp,
		category: "payments",
		description: "Payment processing and billing"
	},
	{
		id: "stytch",
		name: "Stytch",
		url: "https://mcp.stytch.dev/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://stytch.com/favicon.ico",
		category: "authentication",
		description: "User authentication and identity"
	},
	{
		id: "supabase",
		name: "Supabase",
		url: "https://mcp.supabase.com/mcp",
		transport: MCPTransportType.streamableHttp,
		category: "database",
		description: "Open source Firebase alternative"
	},
	{
		id: "telnyx",
		name: "Telnyx",
		url: "https://api.telnyx.com/v2/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://www.telnyx.com/favicon.ico",
		category: "communication",
		description: "Communications API platform"
	},
	{
		id: "thoughtspot",
		name: "ThoughtSpot",
		url: "https://agent.thoughtspot.app/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://developers.thoughtspot.com/docs/icons/icon-48x48.png?v=3959c799205dc2ce6e1f1d93fd74d630",
		category: "analytics",
		description: "Analytics and business intelligence"
	},
	{
		id: "vercel",
		name: "Vercel",
		url: "https://mcp.vercel.com",
		transport: MCPTransportType.streamableHttp,
		category: "infrastructure",
		description: "Web hosting and deployment platform"
	},
	{
		id: "waystation",
		name: "WayStation",
		url: "https://waystation.ai/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://waystation.ai/images/logo.svg",
		category: "ai",
		description: "AI infrastructure and deployment"
	},
	{
		id: "webflow",
		name: "Webflow",
		url: "https://mcp.webflow.com/sse",
		transport: MCPTransportType.sse,
		category: "design",
		description: "Website builder and CMS"
	},
	{
		id: "wix",
		name: "Wix",
		url: "https://mcp.wix.com/sse",
		transport: MCPTransportType.sse,
		imageUrl: "https://wix.com/favicon.ico",
		category: "design",
		description: "Website builder"
	},
	{
		id: "zapier",
		name: "Zapier",
		url: "https://mcp.zapier.com/api/mcp/mcp",
		transport: MCPTransportType.streamableHttp,
		category: "automation",
		description: "Workflow automation and integration"
	},
	{
		id: "zine",
		name: "Zine",
		url: "https://www.zine.ai/mcp",
		transport: MCPTransportType.streamableHttp,
		imageUrl: "https://www.zine.ai/_next/image?url=%2Fimages%2Fzine-logo.png&w=64&q=75",
		category: "ai",
		description: "AI-powered content creation"
	}
];
app.openapi(createProtectedRoute({
	method: "get",
	path: "/",
	summary: "List MCP Server Catalog",
	operationId: "list-mcp-catalog",
	tags: ["MCP Catalog"],
	description: "Get a list of available prebuilt MCP servers. If COMPOSIO_API_KEY is configured, also includes Composio servers for the tenant/project.",
	permission: requireProjectPermission("view"),
	request: { params: TenantProjectParamsSchema },
	responses: {
		200: {
			description: "List of available MCP servers",
			content: { "application/json": { schema: MCPCatalogListResponse } }
		},
		...commonGetErrorResponses
	}
}), async (c) => {
	c.req.valid("param");
	const composioServers = await fetchComposioServers();
	const allServers = [...PREBUILT_MCP_SERVERS, ...composioServers].sort((a, b) => a.name.localeCompare(b.name));
	return c.json({
		data: allServers,
		total: allServers.length
	});
});
var mcpCatalog_default = app;

//#endregion
export { mcpCatalog_default as default };