from ..models import ServerDefinition, ArgPrompt, Runtime

BUILTIN_SERVERS: list[ServerDefinition] = [

    # ── FILESYSTEM & LOCAL ───────────────────────────────────────────────────

    ServerDefinition(
        name="filesystem",
        display_name="Filesystem",
        description="Read and write files within allowed directory paths.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-filesystem", "{allowed_path}"],
        env={},
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-filesystem",
        category="filesystem",
        tags=["files", "local", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        prompts=[ArgPrompt(
            key="allowed_path",
            description="Directory path to allow AI access to",
            default="~/Desktop",
            placeholder="{allowed_path}",
        )],
    ),

    ServerDefinition(
        name="memory",
        display_name="Memory",
        description="Persistent key-value memory store that survives across conversations.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-memory"],
        env={},
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-memory",
        category="productivity",
        tags=["memory", "persistence", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
    ),

    ServerDefinition(
        name="sequential-thinking",
        display_name="Sequential Thinking",
        description="Dynamic problem-solving through structured thought sequences.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-sequential-thinking"],
        env={},
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-sequential-thinking",
        category="productivity",
        tags=["reasoning", "thinking", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
    ),

    # ── VERSION CONTROL ──────────────────────────────────────────────────────

    ServerDefinition(
        name="github",
        display_name="GitHub",
        description="Search repos, read files, manage issues and PRs via the GitHub API.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-github"],
        env={"GITHUB_PERSONAL_ACCESS_TOKEN": "GitHub PAT with repo scope"},
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-github",
        category="dev-tools",
        tags=["github", "git", "vcs", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        requires_auth=True,
    ),

    ServerDefinition(
        name="gitlab",
        display_name="GitLab",
        description="Read and write GitLab repos, issues, and merge requests.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-gitlab"],
        env={
            "GITLAB_PERSONAL_ACCESS_TOKEN": "GitLab PAT with api scope",
            "GITLAB_API_URL": "https://gitlab.com/api/v4",
        },
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-gitlab",
        category="dev-tools",
        tags=["gitlab", "git", "vcs", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        requires_auth=True,
    ),

    # ── DATABASES ────────────────────────────────────────────────────────────

    ServerDefinition(
        name="postgres",
        display_name="PostgreSQL",
        description="Run read-only SQL queries against a PostgreSQL database.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-postgres", "{connection_string}"],
        env={},
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-postgres",
        category="database",
        tags=["postgres", "sql", "database", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        prompts=[ArgPrompt(
            key="connection_string",
            description="PostgreSQL connection string",
            default="postgresql://localhost/mydb",
            placeholder="{connection_string}",
        )],
    ),

    ServerDefinition(
        name="sqlite",
        display_name="SQLite",
        description="Query and analyze SQLite databases with built-in insight tools.",
        command="uvx",
        args=["mcp-server-sqlite", "--db-path", "{db_path}"],
        env={},
        runtime=Runtime.uvx,
        package="mcp-server-sqlite",
        category="database",
        tags=["sqlite", "sql", "database", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        prompts=[ArgPrompt(
            key="db_path",
            description="Path to the SQLite database file",
            default="~/data.db",
            placeholder="{db_path}",
        )],
    ),

    ServerDefinition(
        name="redis",
        display_name="Redis",
        description="Get, set, and query keys in a Redis instance.",
        command="npx",
        args=["-y", "mcp-redis", "--url", "{redis_url}"],
        env={},
        runtime=Runtime.npx,
        package="mcp-redis",
        category="database",
        tags=["redis", "cache", "database", "community"],
        homepage="https://github.com/redis/mcp-redis",
        author="Redis",
        prompts=[ArgPrompt(
            key="redis_url",
            description="Redis connection URL",
            default="redis://localhost:6379",
            placeholder="{redis_url}",
        )],
    ),

    # ── WEB & BROWSER ────────────────────────────────────────────────────────

    ServerDefinition(
        name="fetch",
        display_name="Fetch",
        description="Fetch web pages and convert them to Markdown for the AI to read.",
        command="uvx",
        args=["mcp-server-fetch"],
        env={},
        runtime=Runtime.uvx,
        package="mcp-server-fetch",
        category="web",
        tags=["fetch", "http", "web", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
    ),

    ServerDefinition(
        name="brave-search",
        display_name="Brave Search",
        description="Web and local search via the Brave Search API.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-brave-search"],
        env={"BRAVE_API_KEY": "Brave Search API key from brave.com/search/api"},
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-brave-search",
        category="web",
        tags=["search", "web", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        requires_auth=True,
    ),

    ServerDefinition(
        name="puppeteer",
        display_name="Puppeteer",
        description="Browser automation: screenshots, click, fill forms, scrape dynamic pages.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-puppeteer"],
        env={},
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-puppeteer",
        category="web",
        tags=["browser", "automation", "puppeteer", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
    ),

    ServerDefinition(
        name="playwright",
        display_name="Playwright",
        description="Full browser automation with Playwright - more capable than Puppeteer.",
        command="npx",
        args=["-y", "@playwright/mcp"],
        env={},
        runtime=Runtime.npx,
        package="@playwright/mcp",
        category="web",
        tags=["browser", "automation", "playwright", "community"],
        homepage="https://github.com/microsoft/playwright-mcp",
        author="Microsoft",
    ),

    ServerDefinition(
        name="firecrawl",
        display_name="Firecrawl",
        description="Crawl websites and extract clean Markdown content at scale.",
        command="npx",
        args=["-y", "firecrawl-mcp"],
        env={"FIRECRAWL_API_KEY": "Firecrawl API key from firecrawl.dev"},
        runtime=Runtime.npx,
        package="firecrawl-mcp",
        category="web",
        tags=["crawl", "scrape", "markdown", "community"],
        homepage="https://github.com/mendableai/firecrawl-mcp-server",
        author="Mendable",
        requires_auth=True,
    ),

    ServerDefinition(
        name="exa",
        display_name="Exa Search",
        description="Semantic web search with AI-native results via the Exa API.",
        command="npx",
        args=["-y", "exa-mcp-server"],
        env={"EXA_API_KEY": "Exa API key from exa.ai"},
        runtime=Runtime.npx,
        package="exa-mcp-server",
        category="web",
        tags=["search", "semantic", "community"],
        homepage="https://github.com/exa-labs/exa-mcp-server",
        author="Exa Labs",
        requires_auth=True,
    ),

    # ── CLOUD SERVICES ───────────────────────────────────────────────────────

    ServerDefinition(
        name="google-drive",
        display_name="Google Drive",
        description="Search and read files stored in Google Drive.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-gdrive"],
        env={},
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-gdrive",
        category="cloud",
        tags=["google", "drive", "files", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        requires_auth=True,
    ),

    ServerDefinition(
        name="google-maps",
        display_name="Google Maps",
        description="Geocoding, directions, place search, and distance matrix.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-google-maps"],
        env={"GOOGLE_MAPS_API_KEY": "Google Maps API key from console.cloud.google.com"},
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-google-maps",
        category="web",
        tags=["maps", "geocoding", "google", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        requires_auth=True,
    ),

    ServerDefinition(
        name="aws-kb",
        display_name="AWS Knowledge Base",
        description="Retrieve content from Amazon Bedrock Knowledge Bases using RAG.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-aws-kb-retrieval"],
        env={
            "AWS_ACCESS_KEY_ID": "AWS access key ID",
            "AWS_SECRET_ACCESS_KEY": "AWS secret access key",
            "AWS_REGION": "AWS region (e.g. us-east-1)",
        },
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-aws-kb-retrieval",
        category="cloud",
        tags=["aws", "bedrock", "rag", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        requires_auth=True,
    ),

    # ── PRODUCTIVITY & COMMUNICATION ─────────────────────────────────────────

    ServerDefinition(
        name="slack",
        display_name="Slack",
        description="Read channels, post messages, and search Slack workspace history.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-slack"],
        env={
            "SLACK_BOT_TOKEN": "Bot token starting with xoxb-",
            "SLACK_TEAM_ID": "Workspace team ID (e.g. T01234567)",
        },
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-slack",
        category="productivity",
        tags=["slack", "messaging", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        requires_auth=True,
    ),

    ServerDefinition(
        name="linear",
        display_name="Linear",
        description="Query and update Linear issues, projects, and cycles.",
        command="npx",
        args=["-y", "@linear/mcp-server"],
        env={"LINEAR_API_KEY": "Linear API key from linear.app/settings/api"},
        runtime=Runtime.npx,
        package="@linear/mcp-server",
        category="productivity",
        tags=["linear", "issues", "project-management", "community"],
        homepage="https://github.com/linear/linear-mcp-server",
        author="Linear",
        requires_auth=True,
    ),

    ServerDefinition(
        name="notion",
        display_name="Notion",
        description="Read and write Notion pages, databases, and blocks.",
        command="npx",
        args=["-y", "@notionhq/notion-mcp-server"],
        env={"NOTION_API_KEY": "Notion integration secret from notion.so/my-integrations"},
        runtime=Runtime.npx,
        package="@notionhq/notion-mcp-server",
        category="productivity",
        tags=["notion", "notes", "database", "community"],
        homepage="https://github.com/makenotion/notion-mcp-server",
        author="Notion",
        requires_auth=True,
    ),

    ServerDefinition(
        name="obsidian",
        display_name="Obsidian",
        description="Read and search notes inside an Obsidian vault.",
        command="npx",
        args=["-y", "mcp-obsidian", "{vault_path}"],
        env={},
        runtime=Runtime.npx,
        package="mcp-obsidian",
        category="productivity",
        tags=["obsidian", "notes", "markdown", "community"],
        homepage="https://github.com/calclavia/mcp-obsidian",
        author="calclavia",
        prompts=[ArgPrompt(
            key="vault_path",
            description="Absolute path to your Obsidian vault",
            default="~/Documents/ObsidianVault",
            placeholder="{vault_path}",
        )],
    ),

    # ── DEV TOOLS ────────────────────────────────────────────────────────────

    ServerDefinition(
        name="context7",
        display_name="Context7",
        description="Up-to-date library docs for any package, fetched at query time.",
        command="npx",
        args=["-y", "@upstash/context7-mcp"],
        env={},
        runtime=Runtime.npx,
        package="@upstash/context7-mcp",
        category="dev-tools",
        tags=["docs", "libraries", "context", "community"],
        homepage="https://github.com/upstash/context7",
        author="Upstash",
    ),

    ServerDefinition(
        name="sentry",
        display_name="Sentry",
        description="Query Sentry issues, events, and project data.",
        command="uvx",
        args=["mcp-server-sentry", "--auth-token", "{sentry_token}"],
        env={},
        runtime=Runtime.uvx,
        package="mcp-server-sentry",
        category="dev-tools",
        tags=["sentry", "errors", "monitoring", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        requires_auth=True,
        prompts=[ArgPrompt(
            key="sentry_token",
            description="Sentry auth token (from sentry.io/settings/auth-tokens)",
            default="",
            placeholder="{sentry_token}",
        )],
    ),

    ServerDefinition(
        name="docker",
        display_name="Docker",
        description="Manage Docker containers, images, volumes, and networks.",
        command="npx",
        args=["-y", "docker-mcp"],
        env={},
        runtime=Runtime.npx,
        package="docker-mcp",
        category="dev-tools",
        tags=["docker", "containers", "devops", "community"],
        homepage="https://github.com/ckreiling/mcp-server-docker",
        author="ckreiling",
    ),

    ServerDefinition(
        name="stripe",
        display_name="Stripe",
        description="Query Stripe customers, payments, subscriptions, and invoices.",
        command="npx",
        args=["-y", "@stripe/mcp", "--tools=all"],
        env={"STRIPE_SECRET_KEY": "Stripe secret key from dashboard.stripe.com/apikeys"},
        runtime=Runtime.npx,
        package="@stripe/mcp",
        category="cloud",
        tags=["stripe", "payments", "billing", "community"],
        homepage="https://github.com/stripe/agent-toolkit",
        author="Stripe",
        requires_auth=True,
    ),

    ServerDefinition(
        name="everart",
        display_name="EverArt",
        description="AI image generation via the EverArt API.",
        command="npx",
        args=["-y", "@modelcontextprotocol/server-everart"],
        env={"EVERART_API_KEY": "EverArt API key from everart.ai"},
        runtime=Runtime.npx,
        package="@modelcontextprotocol/server-everart",
        category="productivity",
        tags=["images", "ai", "generation", "official"],
        homepage="https://github.com/modelcontextprotocol/servers",
        author="Anthropic",
        requires_auth=True,
    ),
]

# Fast lookup dict
SERVERS_BY_NAME: dict[str, ServerDefinition] = {s.name: s for s in BUILTIN_SERVERS}
