"""Leaderboard benchmark data -- 201 popular MCP servers graded."""

# (server_id, display_name, score) sorted by score descending
LEADERBOARD = [
    ("awkoy-notion", "Notion MCP (awkoy)", 100.0),
    ("zapier-mcp", "zapier/zapier-mcp", 100.0),
    ("mysql-mcp", "MySQL MCP Server", 99.7),
    ("sqlite", "SQLite MCP Server", 99.7),
    ("e2b", "E2B MCP Server", 99.1),
    ("windbg", "WinDbg MCP", 99.1),
    ("mcp-gdrive", "Google Drive MCP (isaacphi)", 97.3),
    ("mcp-youtube", "mcp-youtube", 97.3),
    ("mcp-installer", "MCP Installer", 95.5),
    ("elasticsearch-mcp", "Elasticsearch MCP Server", 94.5),
    ("twilio-mcp", "Twilio SMS", 94.5),
    ("colab", "Google Colab MCP", 93.6),
    ("zoom-transcript-mcp", "Zoom Transcript MCP", 93.3),
    ("postgres", "PostgreSQL MCP Server", 92.0),
    ("time", "Time MCP Server", 91.9),
    ("axiom-mcp", "Axiom MCP Server", 91.4),
    ("flyio-mcp", "Fly.io MCP (Official)", 91.4),
    ("bigquery-mcp", "BigQuery MCP", 91.1),
    ("pinecone-official", "Pinecone Assistant MCP", 90.3),
    ("splunk-mcp", "Splunk MCP (Official)", 88.1),
    ("ytt-mcp", "ytt-mcp (YouTube Transcript)", 88.1),
    ("kafka-mcp", "kafka-mcp", 86.5),
    ("flightradar-mcp", "Flightradar24 MCP", 85.3),
    ("lancedb-mcp", "LanceDB MCP (Official)", 85.0),
    ("danhilse-notion", "Notion MCP (danhilse)", 84.0),
    ("homeassistant-mcp", "Home Assistant MCP", 83.4),
    ("mcp-feedback-enhanced", "MCP Feedback Enhanced", 83.4),
    ("git", "Git MCP Server", 82.0),
    ("eslint-mcp", "ESLint MCP Server", 82.0),
    ("google-tasks-mcp", "Google Tasks MCP", 81.9),
    ("metabase-mcp", "Metabase MCP (Community)", 81.9),
    ("vault-mcp", "HashiCorp Vault MCP", 81.4),
    ("calclavia-obsidian", "Obsidian MCP (calclavia)", 80.6),
    ("obsidian", "Obsidian MCP (MarkusPfundstein)", 80.6),
    ("mixpanel-moonbirdai", "moonbirdai/mixpanel-mcp-server", 80.5),
    ("discord-v3-mcp", "Discord MCP", 80.4),
    ("polygon-mcp", "Polygon.io MCP", 79.0),
    ("langfuse-mcp", "Langfuse MCP (Official)", 77.4),
    ("prometheus-mcp", "Prometheus MCP Server", 76.7),
    ("square-mcp", "Square MCP Server (Official)", 76.7),
    ("discord-hanweg", "Discord MCP (hanweg)", 76.4),
    ("qdrant", "Qdrant MCP", 74.9),
    ("dbhub", "dbhub", 74.3),
    ("weather-mcp", "OpenWeather MCP Server", 73.6),
    ("anyquery", "Anyquery", 71.4),
    ("brave", "Brave Search MCP Server", 70.3),
    ("mark3labs-filesystem", "Filesystem MCP Server (mark3labs)", 69.1),
    ("vercel-next", "Vercel Next DevTools", 67.3),
    ("newrelic-mcp", "New Relic MCP (Official)", 66.7),
    ("fetch", "Fetch MCP Server", 66.4),
    ("kagi-mcp", "Kagi Search MCP", 66.2),
    ("weaviate", "Weaviate MCP", 65.5),
    ("slack", "Slack MCP Server", 65.3),
    ("googlemaps", "Google Maps MCP Server", 65.0),
    ("sentry", "Sentry MCP Server", 64.6),
    ("atlassian", "Atlassian MCP Server", 62.2),
    ("browsermcp", "BrowserMCP", 61.2),
    ("browser-tools-mcp", "AgentDeskAI Browser Tools MCP", 60.0),
    ("mongodb-lens", "MongoDB Lens", 60.0),
    ("dagster-mcp", "Dagster MCP", 59.7),
    ("ros-mcp", "ROS MCP Server", 59.7),
    ("markdownify", "Markdownify MCP", 59.1),
    ("dynatrace-mcp", "Dynatrace MCP", 58.8),
    ("codex-mcp", "Codex MCP Server", 58.5),
    ("duckduckgo-mcp", "DuckDuckGo MCP", 58.1),
    ("temporal-mcp", "Temporal MCP (Community)", 56.7),
    ("puppeteer", "Puppeteer MCP Server", 55.2),
    ("pinecone-sirmews", "Pinecone MCP", 54.9),
    ("sourcegraph-mcp", "Sourcegraph MCP (Official)", 54.6),
    ("zendesk-mcp", "Zendesk MCP Server", 54.6),
    ("mcp-everything", "MCP Everything (Reference)", 54.6),
    ("shadcn", "shadcn-ui MCP", 53.4),
    ("klaviyo-mcp", "Klaviyo MCP (Community)", 53.1),
    ("hubspot-mcp", "HubSpot MCP Server", 52.8),
    ("hf-mcp", "HuggingFace MCP", 51.3),
    ("box-mcp", "Box MCP Server", 50.4),
    ("freshdesk-mcp", "Freshdesk MCP (Community)", 49.8),
    ("browserbase", "Browserbase MCP", 49.6),
    ("whatsapp", "WhatsApp MCP", 48.4),
    ("chunkhound", "chunkhound", 48.3),
    ("godot-mcp", "Godot MCP", 48.3),
    ("jina-mcp", "Jina AI MCP", 48.0),
    ("unity-mcp", "CoderGamester/mcp-unity", 48.0),
    ("deepwiki-mcp", "DeepWiki MCP", 46.3),
    ("monday-mcp", "monday.com MCP", 46.2),
    ("chroma", "Chroma MCP", 45.9),
    ("fastapi-mcp", "FastAPI-MCP", 45.6),
    ("groq-mcp", "Groq MCP Server", 45.6),
    ("clickup-mcp", "ClickUp MCP Server", 45.3),
    ("mem0", "Mem0 MCP", 44.7),
    ("linkedin", "LinkedIn MCP", 44.6),
    ("doppler-mcp", "Doppler MCP (Official)", 44.4),
    ("ghidra", "GhidraMCP", 44.4),
    ("trello-mcp", "delorenj/mcp-server-trello", 44.4),
    ("amplitude-mcp", "Amplitude MCP (Official)", 44.1),
    ("circleci-mcp", "CircleCI MCP Server", 43.8),
    ("airflow-mcp", "Apache Airflow MCP", 42.0),
    ("mongodb", "MongoDB MCP", 42.0),
    ("korotovsky-slack", "Slack MCP (korotovsky)", 41.1),
    ("xiaohongshu", "Xiaohongshu MCP Server", 40.2),
    ("plaid-mcp", "Plaid AI Coding Toolkit", 39.9),
    ("infisical-mcp", "Infisical MCP (Official)", 39.6),
    ("linear", "Linear MCP", 38.7),
    ("memory", "Memory MCP Server", 38.4),
    ("web-eval-agent", "Web Eval Agent", 38.1),
    ("upstash-mcp", "Upstash MCP (Official)", 38.1),
    ("webex-mcp", "Webex (Cisco)", 38.1),
    ("mobile-mcp", "Mobile MCP", 37.8),
    ("arxiv-mcp", "arXiv MCP Server", 37.4),
    ("argocd-mcp", "ArgoCD MCP", 37.2),
    ("filesystem", "Filesystem MCP Server", 36.9),
    ("spotify-mcp", "Spotify MCP", 36.6),
    ("universal-db", "Universal DB MCP", 36.6),
    ("planetscale-mcp", "planetscale/mcp-server", 36.4),
    ("line-bot-mcp", "LINE Bot MCP Server", 36.3),
    ("airtable-mcp", "Airtable MCP Server", 36.0),
    ("gsc-mcp", "Google Search Console MCP", 36.0),
    ("firecrawl", "Firecrawl MCP Server", 35.8),
    ("railway-mcp", "Railway MCP (Official)", 35.4),
    ("bitwarden-mcp", "Bitwarden", 34.5),
    ("apify", "Apify Actors MCP", 32.7),
    ("sendgrid-mcp", "SendGrid MCP", 32.7),
    ("auth0-mcp", "auth0/auth0-mcp-server", 31.8),
    ("excel", "Excel MCP Server", 31.8),
    ("supabase", "Supabase MCP", 31.5),
    ("databricks-mcp", "Databricks MCP", 29.7),
    ("dbt-mcp", "dbt MCP (Official)", 29.7),
    ("xero-mcp", "Xero MCP (Official)", 29.7),
    ("contentful-mcp", "Contentful MCP (Official)", 29.4),
    ("ea-playwright", "Playwright MCP (executeautomation)", 29.4),
    ("asana-mcp", "Asana MCP Server", 28.8),
    ("telegram-mcp", "Telegram MCP (chigwell)", 28.8),
    ("loom-mcp", "Loom MCP (Community)", 28.5),
    ("datadog-mcp", "Datadog MCP Server", 28.2),
    ("gmail-mcp", "Gmail MCP", 28.2),
    ("wandb-mcp", "W&amp;B MCP Server (Official)", 28.2),
    ("discord-barryyip", "Discord MCP (barryyip0625)", 27.9),
    ("milvus-mcp", "Milvus MCP (Official)", 27.9),
    ("resend", "Resend MCP", 27.9),
    ("todoist-mcp", "Todoist", 27.6),
    ("terraform", "Terraform MCP", 27.5),
    ("cloudinary-mcp", "Cloudinary", 27.3),
    ("playwright-ms", "Playwright MCP (Microsoft)", 27.3),
    ("docker-mcp", "Docker MCP", 27.0),
    ("playwright", "Playwright MCP Server", 27.0),
    ("serena", "Serena", 27.0),
    ("google-calendar-mcp", "Google Calendar", 26.7),
    ("okta-mcp", "Okta MCP Server (Official)", 26.7),
    ("algolia-mcp", "Algolia MCP (Official)", 26.4),
    ("miro-mcp", "Miro MCP Server", 26.4),
    ("shopify", "Shopify MCP Server", 26.1),
    ("google-sheets", "Google Sheets MCP", 25.8),
    ("sequentialthinking", "Sequential Thinking", 25.5),
    ("gitlab-mcp", "GitLab MCP Server", 25.5),
    ("pagerduty-mcp", "PagerDuty MCP Server", 25.5),
    ("mcp-taskmanager", "MCP Taskmanager", 25.2),
    ("chrome-devtools", "Chrome DevTools MCP Server", 24.9),
    ("drawio", "Draw.io MCP Server", 24.9),
    ("redis-mcp", "Redis MCP Server", 24.6),
    ("genai-toolbox", "Google genai-toolbox", 24.3),
    ("opensearch-mcp", "OpenSearch MCP Server (Official)", 24.3),
    ("prefect-mcp", "Prefect MCP (Official)", 24.3),
    ("salesforce-mcp", "Salesforce CLI MCP", 24.0),
    ("confluence-mcp", "Confluence MCP (aashari)", 23.7),
    ("firebase-mcp", "Firebase MCP Server (Official)", 23.7),
    ("neon", "Neon MCP", 23.7),
    ("google-workspace", "Google Workspace MCP", 22.8),
    ("influxdb-mcp", "InfluxDB MCP Server (Official)", 22.8),
    ("stripe", "Stripe Agent Toolkit MCP Server", 22.5),
    ("magic-mcp", "magic-mcp", 22.3),
    ("blender", "Blender MCP Server", 22.2),
    ("jira-mcp", "Jira MCP (aashari)", 22.2),
    ("azure-devops", "Azure DevOps MCP", 21.9),
    ("figma", "Figma-Context-MCP", 21.9),
    ("grafana", "Grafana MCP", 21.9),
    ("kubernetes", "Kubernetes MCP", 21.9),
    ("exa", "Exa MCP Server", 21.0),
    ("suekou-notion", "Notion MCP (suekou)", 20.4),
    ("github", "GitHub MCP Server", 20.1),
    ("github-official", "GitHub MCP Server (Official)", 20.1),
    ("postman-mcp", "Postman MCP Server", 20.1),
    ("confluent-mcp", "Confluent Kafka MCP", 19.8),
    ("notion", "Notion MCP Server", 19.8),
    ("snowflake-mcp", "Snowflake MCP Server", 19.5),
    ("mslearn", "Microsoft Learn MCP", 19.3),
    ("chart", "Chart MCP Server", 16.5),
    ("apple-docs", "Apple Docs MCP", 16.2),
    ("aws", "AWS MCP Server", 16.2),
    ("n8n-mcp", "n8n-mcp", 15.9),
    ("perplexity", "Perplexity MCP Server", 15.6),
    ("mcp-chrome", "mcp-chrome", 12.9),
    ("minimax", "MiniMax MCP", 12.6),
    ("cloudflare", "Cloudflare Radar MCP Server", 11.4),
    ("desktop-commander", "Desktop Commander MCP Server", 10.8),
    ("pal", "PAL MCP Server", 9.0),
    ("alexander-supabase", "Supabase MCP (alexander-zuev)", 8.4),
    ("tavily", "Tavily MCP Server", 8.1),
    ("context7", "Context7 MCP Server", 7.5),
    ("snyk-mcp", "Snyk MCP (Official)", 3.3),
    ("ga4", "Google Analytics (GA4) MCP Server", 0.0),
    ("sentry-official", "Sentry MCP (Official)", 0.0),
]



LEADERBOARD_URL = "https://0-co.github.io/company/leaderboard.html"


def get_leaderboard_position(score: float):
    """Return (rank, total, servers_above, servers_below) for a given score.

    rank: 1-based position (1 = best). Score *exactly* matching an entry ties at that rank.
    total: total number of entries in LEADERBOARD.
    servers_above: up to 2 (name, score) tuples with higher scores, sorted ascending by score.
    servers_below: up to 2 (name, score) tuples with lower scores, sorted descending by score.
    """
    above = [(name, s) for _, name, s in LEADERBOARD if s > score]
    below = [(name, s) for _, name, s in LEADERBOARD if s < score]

    # Stable sort: by score ascending for above (nearest = last), by score desc then name asc for below
    above.sort(key=lambda x: x[1])
    below.sort(key=lambda x: (-x[1], x[0]))

    rank = len(above) + 1
    total = len(LEADERBOARD)

    return rank, total, above[:2], below[:2]
