> ## Documentation Index
> Fetch the complete documentation index at: https://docs.barndoor.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Apify MCP Server

export default function ServerDetails({serverName: initialServerName = null}) {
  const ITEMS_PER_PAGE = 20;
  const CUSTOM_API_PORT = 3001;
  const CACHE_DURATION = 3600000;
  const isLocalhost = typeof window !== "undefined" && window.location.hostname === "localhost";
  const getCachedData = key => {
    if (isLocalhost) return null;
    try {
      const cached = localStorage.getItem(key);
      if (!cached) return null;
      const {data, timestamp} = JSON.parse(cached);
      if (Date.now() - timestamp > CACHE_DURATION) {
        localStorage.removeItem(key);
        return null;
      }
      return data;
    } catch {
      return null;
    }
  };
  const setCachedData = (key, data) => {
    if (isLocalhost) return;
    try {
      localStorage.setItem(key, JSON.stringify({
        data,
        timestamp: Date.now()
      }));
    } catch (e) {
      console.warn('Cache storage failed:', e);
    }
  };
  const [serverName, setServerName] = useState(initialServerName);
  const [serverInfo, setServerInfo] = useState(null);
  const [allTools, setAllTools] = useState([]);
  const [tab, setTab] = useState("tools");
  const [policies, setPolicies] = useState([]);
  const [setupInstructions, setSetupInstructions] = useState([]);
  const [toolsLoading, setToolsLoading] = useState(true);
  const [policiesLoading, setPoliciesLoading] = useState(false);
  const [setupLoading, setSetupLoading] = useState(false);
  const [toolsError, setToolsError] = useState(null);
  const [policiesError, setPoliciesError] = useState(null);
  const [setupError, setSetupError] = useState(null);
  const [policiesCount, setPoliciesCount] = useState(0);
  const [setupCount, setSetupCount] = useState(0);
  const [searchTerm, setSearchTerm] = useState("");
  const [currentPage, setCurrentPage] = useState(1);
  const [policiesListFetched, setPoliciesListFetched] = useState(false);
  const [setupListFetched, setSetupListFetched] = useState(false);
  const [policiesCountFetched, setPoliciesCountFetched] = useState(false);
  const [setupCountFetched, setSetupCountFetched] = useState(false);
  const SERVER_DB_MAPPINGS = {
    bamboohr: {
      OVERVIEW_DB_ID: "0ad4c7fe2e0b82b7879981fa776dd073",
      TOOLS_DB_ID: "2ab4c7fe2e0b8380815001c58a0ac1ac",
      POLICIES_DB_ID: "aeb4c7fe2e0b83908810818a8e18d8a1",
      INSTRUCTIONS_DB_ID: "8e04c7fe2e0b82628e9d01a903c82da4"
    },
    langfuse: {
      OVERVIEW_DB_ID: "37b4c7fe2e0b81178dbfce2b8c4f46e8",
      TOOLS_DB_ID: "37b4c7fe2e0b81a4ac55ff994dac67e6",
      POLICIES_DB_ID: "37b4c7fe2e0b813ab74ff5c98c3a54cd",
      INSTRUCTIONS_DB_ID: "37b4c7fe2e0b8107acc3f37e702a0450"
    },
    context7: {
      OVERVIEW_DB_ID: "3794c7fe2e0b815c8aabf9912e5ea307",
      TOOLS_DB_ID: "3794c7fe2e0b818ab5acc27dd72bd360",
      POLICIES_DB_ID: "3794c7fe2e0b816ebd83f01b6027ee3b",
      INSTRUCTIONS_DB_ID: "3794c7fe2e0b8146a038d360caab6031"
    },
    googleanalytics: {
      OVERVIEW_DB_ID: "3794c7fe2e0b8110901bc6c3c1c9a83e",
      TOOLS_DB_ID: "3794c7fe2e0b81e39b39dd71c526213f",
      POLICIES_DB_ID: "3794c7fe2e0b81b79af4f60631aa1733",
      INSTRUCTIONS_DB_ID: "3794c7fe2e0b81e1ad3fe86dedc2d580"
    },
    googleads: {
      OVERVIEW_DB_ID: "3794c7fe2e0b810bb966d7657d5da688",
      TOOLS_DB_ID: "3794c7fe2e0b813d981bdec859129e26",
      POLICIES_DB_ID: "3794c7fe2e0b81c186a4d84d30aed559",
      INSTRUCTIONS_DB_ID: "3794c7fe2e0b813dbb76c6ceb8580a94"
    },
    outlookmail: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81098411eeeb50713624",
      TOOLS_DB_ID: "3374c7fe2e0b812aaa0cf3ed9d0c71a6",
      POLICIES_DB_ID: "3374c7fe2e0b81b5af9afcefdff7c637",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b811fb801db3a5ddfe53d"
    },
    outlookcalendar: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81249227cfc63a8017e7",
      TOOLS_DB_ID: "3374c7fe2e0b816291edd6c2513086e2",
      POLICIES_DB_ID: "3374c7fe2e0b819489bce660396b5a97",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b81c89bc5da13e6774410"
    },
    otter: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81eda5c4d447d3599f95",
      TOOLS_DB_ID: "3374c7fe2e0b81a383f5da047e8d39ae",
      POLICIES_DB_ID: "3374c7fe2e0b819b80c1cb62ac0eb2cc",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b81b1bb6fea918e7ec895"
    },
    onenote: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81e9be9cca1dc600c2f3",
      TOOLS_DB_ID: "3374c7fe2e0b81e09ae2c5dd787811dd",
      POLICIES_DB_ID: "3374c7fe2e0b81399d9bd01be47eb467",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b81d9b4edfbbbc3235e5f"
    },
    planner: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81dfb2d1f5e09711b9e0",
      TOOLS_DB_ID: "3374c7fe2e0b815482cde51a20cb5c97",
      POLICIES_DB_ID: "3374c7fe2e0b8121b131c82f1c19c612",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b81d583fbec264e4e03f1"
    },
    onedrive: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81c79856e712f3dd81af",
      TOOLS_DB_ID: "3374c7fe2e0b8174ad5adac81b9b63ca",
      POLICIES_DB_ID: "3374c7fe2e0b810caa3cf2bf5f4e6664",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b8190bd87ccb8da561584"
    },
    excelonline: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81f09966dbad01c458d8",
      TOOLS_DB_ID: "3374c7fe2e0b81d7892de3487b42a8df",
      POLICIES_DB_ID: "3374c7fe2e0b81efb407eb1c11edb806",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b812cbd56ef2427fac281"
    },
    powerpointonline: {
      OVERVIEW_DB_ID: "3484c7fe2e0b8157a16ae88cf6ac622f",
      TOOLS_DB_ID: "3484c7fe2e0b81cca5eeec1e1592fe8e",
      POLICIES_DB_ID: "3484c7fe2e0b8103a863efe5daa0ea45",
      INSTRUCTIONS_DB_ID: "3484c7fe2e0b81f9a3b9d1c0953894ab"
    },
    granola: {
      OVERVIEW_DB_ID: "3374c7fe2e0b810b9270c0a4e7458fb7",
      TOOLS_DB_ID: "3374c7fe2e0b8103b215e029e5528955",
      POLICIES_DB_ID: "3374c7fe2e0b81c7b512cfc527ed07a7",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b81ab8cc8f185ba1cee50"
    },
    fireflies: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81c9ab42f22b3cdd37f8",
      TOOLS_DB_ID: "3374c7fe2e0b81ff92e4f583e7dd4da9",
      POLICIES_DB_ID: "3374c7fe2e0b81c1a2cdfba3b06e307e",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b81f9a142de4eb65e35d6"
    },
    datadog: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81229f51db72ac014cff",
      TOOLS_DB_ID: "3374c7fe2e0b817b9e9ec750d8908759",
      POLICIES_DB_ID: "3374c7fe2e0b8149aa99e5592a6800b6",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b8130ae67c7635724beb0"
    },
    apollo: {
      OVERVIEW_DB_ID: "3374c7fe2e0b8125afa2d3dfa8a01f09",
      TOOLS_DB_ID: "3374c7fe2e0b81e3a104dd6aae5279fe",
      POLICIES_DB_ID: "3374c7fe2e0b81c7b47ed29b7ccf5649",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b8187b764cc0cdc791237"
    },
    apify: {
      OVERVIEW_DB_ID: "0034c7fe2e0b8326be8e019944ac6430",
      TOOLS_DB_ID: "a574c7fe2e0b83f89b8a81096fc8335d",
      POLICIES_DB_ID: "04f4c7fe2e0b8333ba7f0185c06c5bd1",
      INSTRUCTIONS_DB_ID: "4054c7fe2e0b8213ba61811b1f3a5a26"
    },
    airtable: {
      OVERVIEW_DB_ID: "35e4c7fe2e0b817ebae0d09f30c1a1d8",
      TOOLS_DB_ID: "35e4c7fe2e0b8166a127c0e1ae664b52",
      POLICIES_DB_ID: "35e4c7fe2e0b8149b0efd4a4948c8065",
      INSTRUCTIONS_DB_ID: "35e4c7fe2e0b819d9edfcb84f381c38c"
    },
    bigquery: {
      OVERVIEW_DB_ID: "cbc4c7fe2e0b83f38d080101885bf8c3",
      TOOLS_DB_ID: "8a04c7fe2e0b83d396e701d64561e178",
      POLICIES_DB_ID: "a664c7fe2e0b8252911e0107d9993550",
      INSTRUCTIONS_DB_ID: "40d4c7fe2e0b83f2bc03016debe2fe5f"
    },
    amplitude: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81abb99ae241c62e9382",
      TOOLS_DB_ID: "3374c7fe2e0b81a49f45cdc7df092a46",
      POLICIES_DB_ID: "3374c7fe2e0b81fb8537f43ace808dc9",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b81909ef8cfd0482a475d"
    },
    aha: {
      OVERVIEW_DB_ID: "3364c7fe2e0b815e8caeca1ccef204f9",
      TOOLS_DB_ID: "3364c7fe2e0b8162b4d4eb062dd8385e",
      POLICIES_DB_ID: "3364c7fe2e0b8159937cd1669a313168",
      INSTRUCTIONS_DB_ID: "3364c7fe2e0b81c88f47f68905f684da"
    },
    atlassian: {
      OVERVIEW_DB_ID: "2b74c7fe2e0b801fb156c20cb5319e6a",
      TOOLS_DB_ID: "2ae4c7fe2e0b80d383c6e52921a2f222",
      POLICIES_DB_ID: "2aa4c7fe2e0b80bc88fedd03a7703852",
      INSTRUCTIONS_DB_ID: "2b84c7fe2e0b80cdaa7fcb14ab62b2af"
    },
    github: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b81a7a94efea0c623e986",
      TOOLS_DB_ID: "2ba4c7fe2e0b81b383cbee87204d3f5b",
      POLICIES_DB_ID: "2ba4c7fe2e0b818f8e57e153b7f70e06",
      INSTRUCTIONS_DB_ID: "2bb4c7fe2e0b8088afc3fff76c8f2c1d"
    },
    asana: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b8137b2d9f7002cff2cb6",
      TOOLS_DB_ID_OLD: "2ba4c7fe2e0b81878e73f0a3c8049f37",
      TOOLS_DB_ID: "477f30cd950743458489c093e72aa99f",
      POLICIES_DB_ID: "2ba4c7fe2e0b815fbc79eac8eec9df87",
      INSTRUCTIONS_DB_ID: "2bb4c7fe2e0b80878f0cce377cf0a279"
    },
    monday: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b81ed9df3e9c781fc2e80",
      TOOLS_DB_ID: "2ba4c7fe2e0b814fabf8d82af1f7e432",
      POLICIES_DB_ID: "2ba4c7fe2e0b817d8de2d4b9fda8816a",
      INSTRUCTIONS_DB_ID: "2c14c7fe2e0b801cb80ccbc927de2ee3"
    },
    slack: {
      OVERVIEW_DB_ID: "2b84c7fe2e0b81f3be01f10057a8bb79",
      TOOLS_DB_ID: "2b84c7fe2e0b81138d1de2d0904c0b7a",
      POLICIES_DB_ID: "2b84c7fe2e0b817b9a4dd04e97456e31",
      INSTRUCTIONS_DB_ID: "2c14c7fe2e0b80f18fd3c33f74291920"
    },
    intercom: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b81d9b6c9f8c0a52f8f09",
      TOOLS_DB_ID: "2ba4c7fe2e0b81048be8e43c2daa5f6d",
      POLICIES_DB_ID: "2ba4c7fe2e0b8157bdd6e1eb9f490178",
      INSTRUCTIONS_DB_ID: "2c14c7fe2e0b80ceab8dca0c4851a26d"
    },
    zendesk: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b8195abd9ffa82d68c439",
      TOOLS_DB_ID: "2ba4c7fe2e0b81908fa3d5c99e918b6a",
      POLICIES_DB_ID: "2ba4c7fe2e0b81ae81e7ee5ec232d6e4",
      INSTRUCTIONS_DB_ID: "2c14c7fe2e0b8082ba83f4aad2b82c3b"
    },
    box: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b815ba18df862423999a8",
      TOOLS_DB_ID: "2ba4c7fe2e0b8158922df2700e5f9653",
      POLICIES_DB_ID: "2ba4c7fe2e0b8156943cde4197f9632b",
      INSTRUCTIONS_DB_ID: "2c14c7fe2e0b8050ab61ecc8bda39038"
    },
    notion: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b8175a936f7ca38fafe8d",
      TOOLS_DB_ID: "2ba4c7fe2e0b810ba932eb29f975d138",
      POLICIES_DB_ID: "2ba4c7fe2e0b813f8a57c60a37905b49",
      INSTRUCTIONS_DB_ID: "2c34c7fe2e0b8099b990fc402374d4a0"
    },
    google_drive: {
      OVERVIEW_DB_ID: "3364c7fe2e0b8110a445f1d2105201cf",
      TOOLS_DB_ID: "3364c7fe2e0b8183bd6dce92ededbea7",
      POLICIES_DB_ID: "3364c7fe2e0b81ecbe50c67cecb6633c",
      INSTRUCTIONS_DB_ID: "3364c7fe2e0b81e4b03cc27074c87017"
    },
    sharepoint: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b81219e43c75b39a17ea4",
      TOOLS_DB_ID: "2ba4c7fe2e0b8187bc03fa516797401b",
      POLICIES_DB_ID: "2ba4c7fe2e0b817da7b4edd194f87a43",
      INSTRUCTIONS_DB_ID: "2c34c7fe2e0b80d79792c7414b6f21c2"
    },
    snowflake: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b81aeb9abd8fb816290df",
      TOOLS_DB_ID: "2ba4c7fe2e0b816ebbc6d4ad2a34afba",
      POLICIES_DB_ID: "2ba4c7fe2e0b810eaff8cf6bc15e1aa8",
      INSTRUCTIONS_DB_ID: "2c34c7fe2e0b80b29d81c05f400e48ce"
    },
    google_sheets: {
      OVERVIEW_DB_ID: "3364c7fe2e0b815dab3adbd2d9174b3b",
      TOOLS_DB_ID: "3364c7fe2e0b8106b619e4c3c4ff1845",
      POLICIES_DB_ID: "3364c7fe2e0b8123a87ccc04a992d9a9",
      INSTRUCTIONS_DB_ID: "3364c7fe2e0b811c82ede6f79dd6fe57"
    },
    sonar_qube: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b81d79b35e8fcb0652cae",
      TOOLS_DB_ID: "2ba4c7fe2e0b81a3be8ae17eb7eae866",
      POLICIES_DB_ID: "2ba4c7fe2e0b81a185c9dc8e9bc6c5f8",
      INSTRUCTIONS_DB_ID: "2c04c7fe2e0b8023a34bd11465793376"
    },
    harness: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b81daacf0ddd315b6cff4",
      TOOLS_DB_ID: "2ba4c7fe2e0b81a4aa0ff22b1a706c01",
      POLICIES_DB_ID: "2ba4c7fe2e0b81febbc4da5cdfff3916",
      INSTRUCTIONS_DB_ID: "2c04c7fe2e0b80a988dadbd498cfcacb"
    },
    service_now: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b8112ae3fcf659d228538",
      TOOLS_DB_ID: "2ba4c7fe2e0b81b0b89efc9bacf33c47",
      POLICIES_DB_ID: "2ba4c7fe2e0b81789033f0ee16e14028",
      INSTRUCTIONS_DB_ID: "2c04c7fe2e0b80e3ae51e92b36e16231"
    },
    finch: {
      OVERVIEW_DB_ID: "3134c7fe2e0b817c9b42de4b21167723",
      TOOLS_DB_ID: "3134c7fe2e0b815c8519e5c48ccfb271",
      POLICIES_DB_ID: "3134c7fe2e0b81f69c02e6f1235c6598",
      INSTRUCTIONS_DB_ID: "3134c7fe2e0b812b8b63f4d6ff28cf2b"
    },
    hubspot: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b8127a9eff5a969907201",
      TOOLS_DB_ID: "2ba4c7fe2e0b8197bd73db6c92e3ae3f",
      POLICIES_DB_ID: "2ba4c7fe2e0b81bfba84ede19e13ce33",
      INSTRUCTIONS_DB_ID: "3614c7fe2e0b80c6b2fceec6988d1c8a"
    },
    salesforce: {
      OVERVIEW_DB_ID: "2b84c7fe2e0b81e7bf3ddbcb63de05cd",
      TOOLS_DB_ID: "2b84c7fe2e0b81f8bc2aec7c41ee1662",
      POLICIES_DB_ID: "2b84c7fe2e0b817cb242ce333f1de770",
      INSTRUCTIONS_DB_ID: "2c04c7fe2e0b80da8900e338fd9d70be"
    },
    microsoft_dynamics: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b81f18bbccbde91c9b34b",
      TOOLS_DB_ID: "2ba4c7fe2e0b81ecb76ad052c6f6a961",
      POLICIES_DB_ID: "2ba4c7fe2e0b81989713d9d6abddf24a",
      INSTRUCTIONS_DB_ID: "2c04c7fe2e0b805e95eac101fabd235e"
    },
    shopify: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b81ca95d7cbdc75507c80",
      TOOLS_DB_ID: "2ba4c7fe2e0b81598b54ddab0f56710c",
      POLICIES_DB_ID: "2ba4c7fe2e0b81e59dfbdc70f3a4788e",
      INSTRUCTIONS_DB_ID: "2c04c7fe2e0b80b7b556dd59293ef9be"
    },
    gmail: {
      OVERVIEW_DB_ID: "3364c7fe2e0b8132aa81e1e0e53d3034",
      TOOLS_DB_ID: "3364c7fe2e0b819487cff28fec18e5cc",
      POLICIES_DB_ID: "3364c7fe2e0b81e79e6fdbf23d3cc6f9",
      INSTRUCTIONS_DB_ID: "3364c7fe2e0b8140b006dfa769458a4e"
    },
    google_calendar: {
      OVERVIEW_DB_ID: "3364c7fe2e0b81a8a35ae00e40e04e16",
      TOOLS_DB_ID: "3364c7fe2e0b8169ac4fd884f29f31ab",
      POLICIES_DB_ID: "3364c7fe2e0b816ca662f774f6de1692",
      INSTRUCTIONS_DB_ID: "3364c7fe2e0b810695dcf0d237934a3a"
    },
    google_docs: {
      OVERVIEW_DB_ID: "3364c7fe2e0b81289f27fd47937a7f94",
      TOOLS_DB_ID: "3364c7fe2e0b8120b98be647767edcf0",
      POLICIES_DB_ID: "3364c7fe2e0b81c793c7d1e3258fc047",
      INSTRUCTIONS_DB_ID: "3364c7fe2e0b81cbb862f3f264647103"
    },
    google_slides: {
      OVERVIEW_DB_ID: "3364c7fe2e0b812288f6f5e34feacbdc",
      TOOLS_DB_ID: "3364c7fe2e0b8132993ae8a1813afc49",
      POLICIES_DB_ID: "3364c7fe2e0b81eca932c2fa50213b58",
      INSTRUCTIONS_DB_ID: "3364c7fe2e0b818384aee8fa474388f3"
    },
    googletagmanager: {
      OVERVIEW_DB_ID: "3764c7fe2e0b81b483f4f3939c233f0a",
      TOOLS_DB_ID: "3764c7fe2e0b818baf05c76dfb45e759",
      POLICIES_DB_ID: "3764c7fe2e0b8129a156d2b7fff4972d",
      INSTRUCTIONS_DB_ID: "3764c7fe2e0b81e8ab2ae41166dfc62a"
    },
    persona: {
      OVERVIEW_DB_ID: "37f4c7fe2e0b811eb1eccb2745565602",
      TOOLS_DB_ID: "37f4c7fe2e0b816e825dec4cb25959f2",
      POLICIES_DB_ID: "37f4c7fe2e0b8198987acc5edcd7cd32",
      INSTRUCTIONS_DB_ID: "37f4c7fe2e0b81e69629c816724484a5"
    },
    plaid: {
      OVERVIEW_DB_ID: "2b84c7fe2e0b81ee97c1f86628f81432",
      TOOLS_DB_ID: "2b84c7fe2e0b8123b330e962e9626196",
      POLICIES_DB_ID: "2b84c7fe2e0b81b7a0fee5636e92519b",
      INSTRUCTIONS_DB_ID: "2c04c7fe2e0b80a489d6f826176d91bc"
    },
    xero: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b818a9839c626118d5dc2",
      TOOLS_DB_ID: "2ba4c7fe2e0b81af8355fa6767076f11",
      POLICIES_DB_ID: "2ba4c7fe2e0b8187a332cd8b16878a67",
      INSTRUCTIONS_DB_ID: "2dc4c7fe2e0b80b9a371ee87a25f75eb"
    },
    quickbooks: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b8129b6c9ffa82d68c43a",
      TOOLS_DB_ID: "2ba4c7fe2e0b81088fa3d5c99e918b6b",
      POLICIES_DB_ID: "2ba4c7fe2e0b81be81e7ee5ec232d6e5",
      INSTRUCTIONS_DB_ID: "2c04c7fe2e0b80a988dadbd498cfcacb"
    },
    stripe: {
      OVERVIEW_DB_ID: "3374c7fe2e0b81829da9ffcb8c926068",
      TOOLS_DB_ID: "3374c7fe2e0b81ee96c8c5cdd1e40df6",
      POLICIES_DB_ID: "3374c7fe2e0b812bbd06ca7113fca590",
      INSTRUCTIONS_DB_ID: "3374c7fe2e0b81f4be6ed0f7c758ffd3"
    },
    sardine: {
      OVERVIEW_DB_ID: "3754c7fe2e0b8168a4b9e99657a66095",
      TOOLS_DB_ID: "3754c7fe2e0b81db840cf2386b0d72be",
      POLICIES_DB_ID: "3754c7fe2e0b811b8d78e27fb6d0a3aa",
      INSTRUCTIONS_DB_ID: "3754c7fe2e0b81f1a515ff2e0b4e068d"
    },
    linear: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b81fd8089deb5917c5df5",
      TOOLS_DB_ID: "2ba4c7fe2e0b812fae56f98ab271efdf",
      POLICIES_DB_ID: "2ba4c7fe2e0b81529cf4fc86d5f5623d",
      INSTRUCTIONS_DB_ID: "2fd4c7fe2e0b8069a4aacc1148b1876d"
    },
    dropbox: {
      OVERVIEW_DB_ID: "88e4c7fe2e0b8376926c81f4cbbbf912",
      TOOLS_DB_ID: "1014c7fe2e0b83f883c10183c99047b5",
      POLICIES_DB_ID: "63f4c7fe2e0b8232ab5601e467057f81",
      INSTRUCTIONS_DB_ID: "0514c7fe2e0b83e6b25381f419317e4f"
    },
    close: {
      OVERVIEW_DB_ID: "30e4c7fe2e0b8159be5cf057545f1faa",
      TOOLS_DB_ID: "30e4c7fe2e0b81709ce4cfec82f66f87",
      POLICIES_DB_ID: "30e4c7fe2e0b81dea588e438a6e4fcc9",
      INSTRUCTIONS_DB_ID: "30e4c7fe2e0b8150a8dbf039ef377751"
    },
    figma: {
      OVERVIEW_DB_ID: "30e4c7fe2e0b81f1969de8e6c27087f7",
      TOOLS_DB_ID: "30e4c7fe2e0b81378e67e6cd1ca72edd",
      POLICIES_DB_ID: "30e4c7fe2e0b8190abcecf7ee7db36af",
      INSTRUCTIONS_DB_ID: "30e4c7fe2e0b8145bf6acf4703e271cf"
    },
    grafana: {
      OVERVIEW_DB_ID: "30e4c7fe2e0b811881c2cd6b8e333954",
      TOOLS_DB_ID: "30e4c7fe2e0b819a9bcee856dbb0ef8b",
      POLICIES_DB_ID: "30e4c7fe2e0b81b18fb3db12339e691b",
      INSTRUCTIONS_DB_ID: "30e4c7fe2e0b81108b22dfdc2814ea4b"
    },
    klaviyo: {
      OVERVIEW_DB_ID: "a534c7fe2e0b83afb51481bd86047d33",
      TOOLS_DB_ID: "5e84c7fe2e0b836080e88126975393c9",
      POLICIES_DB_ID: "6574c7fe2e0b83e48d22010e004a8ffc",
      INSTRUCTIONS_DB_ID: "9fb4c7fe2e0b820ebfbe012dcb225ff5"
    },
    gong: {
      OVERVIEW_DB_ID: "3534c7fe2e0b817f8ab7dfe056502154",
      TOOLS_DB_ID: "3534c7fe2e0b818fb044c49e899de4a8",
      POLICIES_DB_ID: "3534c7fe2e0b8127a8ecf3c788f46dfd",
      INSTRUCTIONS_DB_ID: "3534c7fe2e0b818bbfc1eef0bddf3eba"
    },
    gitlab: {
      OVERVIEW_DB_ID: "30d4c7fe2e0b8133b5c1e49e34e2b914",
      TOOLS_DB_ID: "30d4c7fe2e0b8155b35bd1653554c8cf",
      POLICIES_DB_ID: "30d4c7fe2e0b81608059fe0287e81026",
      INSTRUCTIONS_DB_ID: "30d4c7fe2e0b818f9adce1576b7ade55"
    },
    zoho: {
      OVERVIEW_DB_ID: "3104c7fe2e0b81a1b320debfd02e455e",
      TOOLS_DB_ID: "3104c7fe2e0b814ca67ee2710991429e",
      POLICIES_DB_ID: "3104c7fe2e0b8162acd6e2ce01a95f31",
      INSTRUCTIONS_DB_ID: "3104c7fe2e0b819881b6e275695310bb"
    },
    octagon: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b810b8008f14be3790cf1",
      TOOLS_DB_ID: "2ba4c7fe2e0b81dc9b71fe35b2a54a54",
      POLICIES_DB_ID: "2ba4c7fe2e0b81558da5ca3680aca441",
      INSTRUCTIONS_DB_ID: "3104c7fe2e0b802fa26cf35f44daf323"
    },
    zoom: {
      OVERVIEW_DB_ID: "3334c7fe2e0b81be82d9c5f094621b77",
      TOOLS_DB_ID: "3334c7fe2e0b817aa337df8040c94a77",
      POLICIES_DB_ID: "3334c7fe2e0b819688ddc0f1e7904639",
      INSTRUCTIONS_DB_ID: "3334c7fe2e0b81c9a0becf3ed0dad40f"
    },
    freshdesk: {
      OVERVIEW_DB_ID: "3494c7fe2e0b819ab3abf9ef0aac7290",
      TOOLS_DB_ID: "3494c7fe2e0b814594fad041626a5ccd",
      POLICIES_DB_ID: "3494c7fe2e0b81f2b4a7c29e1b985af1",
      INSTRUCTIONS_DB_ID: "3494c7fe2e0b8128b0f6c6a9cfbdf0d2"
    },
    basecamp: {
      OVERVIEW_DB_ID: "3534c7fe2e0b81108bd1e7fc150df72b",
      TOOLS_DB_ID: "3534c7fe2e0b813a9f90eabff7a847c8",
      POLICIES_DB_ID: "3534c7fe2e0b815aa014cba33f6d9487",
      INSTRUCTIONS_DB_ID: "3534c7fe2e0b81688414f7cc76d5b3bb"
    },
    attio: {
      OVERVIEW_DB_ID: "3584c7fe2e0b81149edfc6ab9b0efe4c",
      TOOLS_DB_ID: "3584c7fe2e0b813c9cc3e937f07d37a6",
      POLICIES_DB_ID: "3584c7fe2e0b81cdb682fec34dc6993c",
      INSTRUCTIONS_DB_ID: "3584c7fe2e0b81b78696df9381dd3b59"
    },
    sentry: {
      OVERVIEW_DB_ID: "3584c7fe2e0b81cd84c7dca98061d72a",
      TOOLS_DB_ID: "3584c7fe2e0b8131b531ef2af4c3a11d",
      POLICIES_DB_ID: "3584c7fe2e0b811aa677e38f577170b8",
      INSTRUCTIONS_DB_ID: "3584c7fe2e0b81da917ef43e596806f8"
    },
    microsoftteams: {
      OVERVIEW_DB_ID: "3584c7fe2e0b815f8f86e6d6a53e109e",
      TOOLS_DB_ID: "3584c7fe2e0b81a4962bf6ab8acaffaa",
      POLICIES_DB_ID: "3584c7fe2e0b81168320e7aff8052002",
      INSTRUCTIONS_DB_ID: "3584c7fe2e0b8167aafeef0f48fa6b77"
    },
    hex: {
      OVERVIEW_DB_ID: "3594c7fe2e0b811caaf5c2595880847a",
      TOOLS_DB_ID: "3594c7fe2e0b8110865ce492d41f9df1",
      POLICIES_DB_ID: "3594c7fe2e0b81ba80dac233edf00d6e",
      INSTRUCTIONS_DB_ID: "3594c7fe2e0b818ab282eb137512cc65"
    },
    wordonline: {
      OVERVIEW_DB_ID: "35a4c7fe2e0b810d8b09f393de07fc85",
      TOOLS_DB_ID: "35a4c7fe2e0b81d8984bffcd7c916dfa",
      POLICIES_DB_ID: "35a4c7fe2e0b81af9edef17a8549c4ec",
      INSTRUCTIONS_DB_ID: "35a4c7fe2e0b8199b24ff355e8eabc60"
    },
    buildkite: {
      OVERVIEW_DB_ID: "35e4c7fe2e0b8165bb70d68c0e15ca04",
      TOOLS_DB_ID: "35e4c7fe2e0b81e19923ccee79deb9ee",
      POLICIES_DB_ID: "3814c7fe2e0b812faa50da43625fb2eb",
      INSTRUCTIONS_DB_ID: "35e4c7fe2e0b8170abb7c1d96e1b3558"
    },
    ahrefs: {
      OVERVIEW_DB_ID: "35e4c7fe2e0b818c9191c542c3bca56e",
      TOOLS_DB_ID: "35e4c7fe2e0b812397fbe504505f85e2",
      POLICIES_DB_ID: "35e4c7fe2e0b8125bed9dbc0a2b4ff51",
      INSTRUCTIONS_DB_ID: "35e4c7fe2e0b810197e8ff972eb186ab"
    },
    cloudflare: {
      OVERVIEW_DB_ID: "3814c7fe2e0b815e9948e34502f74f54",
      TOOLS_DB_ID: "3814c7fe2e0b81f286d2e184089406b2",
      POLICIES_DB_ID: "3814c7fe2e0b812faa50da43625fb2eb",
      INSTRUCTIONS_DB_ID: "3814c7fe2e0b8122b48af18b14c66ee2"
    },
    cloud66: {
      OVERVIEW_DB_ID: "0b24c7fe2e0b82a6a3f501521bbe4b26",
      TOOLS_DB_ID: "5d24c7fe2e0b8322ba0481d869fc02b1",
      POLICIES_DB_ID: "3d24c7fe2e0b82db822c01d8392b1464",
      INSTRUCTIONS_DB_ID: "7004c7fe2e0b83ddb6f681d6c0d48283"
    },
    cloudflare_dns_analytics: {
      OVERVIEW_DB_ID: "cec4c7fe2e0b839fa0cf81c0bbb5528e",
      TOOLS_DB_ID: "d504c7fe2e0b82e689000118236da8f3",
      POLICIES_DB_ID: "5954c7fe2e0b825f92d981b1b90b2e40",
      INSTRUCTIONS_DB_ID: "6ab4c7fe2e0b822aaacd811e2a5a219c"
    },
    supabase: {
      OVERVIEW_DB_ID: "35e4c7fe2e0b815283c3e007eb8224a0",
      TOOLS_DB_ID: "35e4c7fe2e0b8152a2c7f0f08b89323b",
      POLICIES_DB_ID: "35e4c7fe2e0b8161928fe4c42818e072",
      INSTRUCTIONS_DB_ID: "35e4c7fe2e0b81e98f17c730f414b4c1"
    },
    statsig: {
      OVERVIEW_DB_ID: "3834c7fe2e0b81ac9f70c46de222e53f",
      TOOLS_DB_ID: "3834c7fe2e0b817b93e4d46bd7d423b9",
      POLICIES_DB_ID: "3834c7fe2e0b81c78d7adc6e2f9fe312",
      INSTRUCTIONS_DB_ID: "3834c7fe2e0b81d3a016e2138f77ffc0"
    },
    excalidraw: {
      OVERVIEW_DB_ID: "3644c7fe2e0b815681b2d98ad4983bd1",
      TOOLS_DB_ID: "3644c7fe2e0b819c9cebc90ff065ce47",
      POLICIES_DB_ID: "3644c7fe2e0b81209dadee054182300a",
      INSTRUCTIONS_DB_ID: "3654c7fe2e0b80a58909eb9d6f33ba62"
    },
    railway: {
      OVERVIEW_DB_ID: "3794c7fe2e0b813d8db3f8632cb37f34",
      TOOLS_DB_ID: "3794c7fe2e0b81689e96f3d6fe6912b9",
      POLICIES_DB_ID: "3794c7fe2e0b8152bf49c58376816cc9",
      INSTRUCTIONS_DB_ID: "3794c7fe2e0b81de8176de0c34357c03"
    },
    ramp: {
      OVERVIEW_DB_ID: "5254c7fe2e0b835ebdb581b8cf2681e7",
      TOOLS_DB_ID: "b554c7fe2e0b8334a9168133848eda68",
      POLICIES_DB_ID: "7784c7fe2e0b82c88d55015d2ba34727",
      INSTRUCTIONS_DB_ID: "8334c7fe2e0b83899550012ed08cb2ad"
    },
    default: {
      OVERVIEW_DB_ID: "2ba4c7fe2e0b8175a936f7ca38fafe8d",
      TOOLS_DB_ID: "2ae4c7fe2e0b80d383c6e52921a2f222",
      POLICIES_DB_ID: "2aa4c7fe2e0b80bc88fedd03a7703852",
      INSTRUCTIONS_DB_ID: "2b84c7fe2e0b80cdaa7fcb14ab62b2af"
    }
  };
  const TAB_ANCHORS = {
    tools: "tools",
    policies: "policies",
    setup: "setup-instructions"
  };
  const TAB_ANCHOR_STYLE = {
    scrollMarginTop: "120px"
  };
  const tagStyle = {
    display: "inline-block",
    padding: "4px 8px",
    marginRight: "8px",
    borderRadius: "4px",
    fontSize: "0.85em",
    fontWeight: "normal",
    backgroundColor: "#e6f7ff",
    color: "#224035",
    border: "1px solid #FA7A54"
  };
  function timeAgo(dateString) {
    if (!dateString) return "—";
    const now = new Date();
    const past = new Date(dateString);
    const seconds = Math.floor((now - past) / 1000);
    if (isNaN(seconds) || seconds < 0) return "—";
    const intervals = [{
      label: "year",
      seconds: 31536000
    }, {
      label: "month",
      seconds: 2592000
    }, {
      label: "week",
      seconds: 604800
    }, {
      label: "day",
      seconds: 86400
    }, {
      label: "hour",
      seconds: 3600
    }, {
      label: "minute",
      seconds: 60
    }, {
      label: "second",
      seconds: 1
    }];
    for (const interval of intervals) {
      const count = Math.floor(seconds / interval.seconds);
      if (count >= 1) {
        return `${count} ${interval.label}${count > 1 ? "s" : ""} ago`;
      }
    }
    return "just now";
  }
  const summarySectionStyle = {
    padding: "20px",
    border: "1px solid #ddd",
    borderRadius: "8px"
  };
  const headerCell = {
    borderBottom: "1px solid #ccc",
    padding: "8px 12px",
    background: "#f7f7f7",
    fontWeight: "bold",
    textAlign: "left"
  };
  const cell = {
    borderBottom: "1px solid #eee",
    padding: "8px 12px"
  };
  const resolveToolType = (tool = {}) => {
    const typeValue = tool.toolType || tool.type || tool.actionType || tool.category || "";
    return typeof typeValue === "string" ? typeValue : String(typeValue || "");
  };
  const filteredTools = useMemo(() => {
    const lowerCaseSearchTerm = searchTerm.toLowerCase();
    const filtered = allTools.filter(tool => {
      const name = (tool.name || "").toLowerCase();
      const type = resolveToolType(tool).toLowerCase();
      const description = (tool.description || "").toLowerCase();
      return name.includes(lowerCaseSearchTerm) || type.includes(lowerCaseSearchTerm) || description.includes(lowerCaseSearchTerm);
    });
    filtered.sort((a, b) => {
      const nameA = (a.name || "").toLowerCase();
      const nameB = (b.name || "").toLowerCase();
      return nameA.localeCompare(nameB);
    });
    if (currentPage > Math.ceil(filtered.length / ITEMS_PER_PAGE)) {
      setCurrentPage(1);
    }
    return filtered;
  }, [allTools, searchTerm, currentPage]);
  const totalPages = Math.ceil(filteredTools.length / ITEMS_PER_PAGE);
  const paginatedTools = useMemo(() => {
    const start = (currentPage - 1) * ITEMS_PER_PAGE;
    const end = start + ITEMS_PER_PAGE;
    return filteredTools.slice(start, end);
  }, [filteredTools, currentPage]);
  const currentDbIds = useMemo(() => {
    if (!serverName) return null;
    const normalized = serverName.toLowerCase();
    const mapping = SERVER_DB_MAPPINGS[normalized] || SERVER_DB_MAPPINGS.default;
    return mapping;
  }, [serverName]);
  const wistiaId = useMemo(() => {
    return serverInfo?.demo?.split("/")?.pop()?.replace(".js", "")?.trim() || null;
  }, [serverInfo]);
  useEffect(() => {
    if (typeof window === "undefined") return;
    const pathMatch = window.location.pathname.match(/\/mcp-servers\/([^/?]+)/i);
    const fromPath = pathMatch ? pathMatch[1] : null;
    const params = new URLSearchParams(window.location.search);
    const fromQuery = params.get("name");
    const resolvedName = fromPath || fromQuery || initialServerName || "default";
    setServerName(resolvedName.toLowerCase());
  }, [initialServerName]);
  useEffect(() => {
    if (typeof window === "undefined") return;
    const hash = window.location.hash.replace("#", "");
    const nextTabKey = Object.entries(TAB_ANCHORS).find(([, anchor]) => anchor === hash)?.[0] || null;
    if (nextTabKey && nextTabKey !== tab) {
      setTab(nextTabKey);
    }
  }, [tab]);
  useEffect(() => {
    setPolicies([]);
    setPoliciesListFetched(false);
    setPoliciesCountFetched(false);
    setPoliciesCount(0);
    setSetupInstructions([]);
    setSetupListFetched(false);
    setSetupCountFetched(false);
    setSetupCount(0);
  }, [currentDbIds]);
  useEffect(() => {
    if (!currentDbIds) return;
    if (tab === "policies" && policies.length === 0 && !policiesLoading && !policiesListFetched) {
      fetchTabContent(currentDbIds.POLICIES_DB_ID, {
        setter: setPolicies,
        loadingSetter: setPoliciesLoading,
        errorSetter: setPoliciesError,
        countSetter: setPoliciesCount,
        transform: filterPublishedPolicies
      }).then(() => setPoliciesListFetched(true));
    }
    if (tab === "setup" && setupInstructions.length === 0 && !setupLoading && !setupListFetched) {
      fetchTabContent(currentDbIds.INSTRUCTIONS_DB_ID, {
        setter: setSetupInstructions,
        loadingSetter: setSetupLoading,
        errorSetter: setSetupError,
        countSetter: setSetupCount
      }).then(() => setSetupListFetched(true));
    }
  }, [tab, currentDbIds, policies.length, policiesListFetched, policiesLoading, setupInstructions.length, setupLoading, setupListFetched]);
  useEffect(() => {
    if (!serverName || !currentDbIds) return;
    let isMounted = true;
    async function loadCoreData() {
      try {
        setToolsLoading(true);
        setToolsError(null);
        const cacheKey = `mcp:${currentDbIds.OVERVIEW_DB_ID}:${currentDbIds.TOOLS_DB_ID}`;
        const cachedData = getCachedData(cacheKey);
        if (cachedData && isMounted) {
          console.log(`Using cached core data for ${serverName}`);
          const overview = cachedData.overview || ({});
          setServerInfo({
            name: overview["Server Name"] || serverName?.toUpperCase() || "MCP Server",
            logo: overview.Logo || "https://via.placeholder.com/150?text=Logo",
            summary: overview.Summary || "No summary available.",
            howTo: overview.HowTo || "",
            category: overview.Category || "Uncategorized",
            managedBy: overview["Managed by"] || null,
            lastUpdated: overview.lastUpdated || null,
            demo: overview.Demo || null
          });
          setAllTools(cachedData.notion_tools || []);
          setToolsLoading(false);
          return;
        }
        const isDev = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
        const apiUrl = isDev ? `http://localhost:${CUSTOM_API_PORT}/api/notion-mcp` : `https://docs-theta-navy-53.vercel.app/api/notion-mcp`;
        const response = await fetch(apiUrl, {
          method: "POST",
          headers: {
            "Content-Type": "application/json"
          },
          body: JSON.stringify({
            overviewDbId: currentDbIds.OVERVIEW_DB_ID,
            toolsDbId: currentDbIds.TOOLS_DB_ID
          })
        });
        if (!response.ok) {
          throw new Error(`Failed to fetch core data: Status ${response.status}`);
        }
        const data = await response.json();
        setCachedData(cacheKey, data);
        if (isMounted) {
          const overview = data.overview || ({});
          const lastUpdatedRaw = overview["Last Updated"] || overview.lastUpdated || overview.updatedAt || null;
          const parsedLastUpdated = lastUpdatedRaw ? new Date(lastUpdatedRaw) : null;
          const normalizedLastUpdated = parsedLastUpdated && !isNaN(parsedLastUpdated.getTime()) ? parsedLastUpdated.toISOString() : null;
          setServerInfo({
            name: overview["Server Name"] || serverName?.toUpperCase() || "MCP Server",
            logo: overview.Logo || "https://via.placeholder.com/150?text=Logo",
            summary: overview.Summary || "No summary available.",
            howTo: overview.HowTo || "",
            category: overview.Category || "Uncategorized",
            managedBy: overview["Managed by"] || "Barndoor",
            lastUpdated: overview.lastUpdated || null,
            demo: overview.Demo || null
          });
          setAllTools(data.notion_tools || []);
        }
      } catch (err) {
        console.error("Core Data Load Error:", err);
        if (isMounted) {
          setToolsError(`Unable to load core server data: ${err.message}`);
          setAllTools([]);
        }
      } finally {
        if (isMounted) {
          setToolsLoading(false);
        }
      }
    }
    loadCoreData();
    return () => {
      isMounted = false;
    };
  }, [serverName, currentDbIds]);
  useEffect(() => {
    if (!currentDbIds) return;
    if (!policiesCountFetched) {
      fetchTabContent(currentDbIds.POLICIES_DB_ID, {
        countSetter: setPoliciesCount,
        transform: filterPublishedPolicies
      }).then(() => setPoliciesCountFetched(true));
    }
    if (!setupCountFetched) {
      fetchTabContent(currentDbIds.INSTRUCTIONS_DB_ID, {
        countSetter: setSetupCount
      }).then(() => setSetupCountFetched(true));
    }
  }, [currentDbIds, policiesCountFetched, setupCountFetched]);
  function filterPublishedPolicies(list = []) {
    return list.filter((item = {}) => !item.unpublished);
  }
  const fetchTabContent = async (dbId, {setter, loadingSetter, errorSetter, countSetter, transform} = {}) => {
    if (!dbId) return;
    loadingSetter?.(true);
    errorSetter?.(null);
    try {
      const cacheKey = `tab:${dbId}`;
      const cachedData = getCachedData(cacheKey);
      if (cachedData) {
        console.log(`Using cached tab content for ${dbId}`);
        const rawContent = cachedData.content || [];
        const content = transform ? transform(rawContent) : rawContent;
        setter?.(content);
        countSetter?.(content.length);
        loadingSetter?.(false);
        return content;
      }
      const isDev = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
      const apiUrl = isDev ? `http://localhost:${CUSTOM_API_PORT}/api/notion-tab-content` : `https://docs-theta-navy-53.vercel.app/api/notion-tab-content`;
      const response = await fetch(apiUrl, {
        method: "POST",
        headers: {
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          dbId
        })
      });
      if (!response.ok) {
        throw new Error(`Failed to fetch content for DB ${dbId}. Status: ${response.status}`);
      }
      const data = await response.json();
      setCachedData(cacheKey, data);
      const rawContent = data.content || [];
      const content = transform ? transform(rawContent) : rawContent;
      setter?.(content);
      countSetter?.(content.length);
      return content;
    } catch (err) {
      console.error(`Tab Content Load Error for DB ${dbId}:`, err);
      errorSetter?.(`Error loading content: ${err.message}`);
      throw err;
    } finally {
      loadingSetter?.(false);
    }
  };
  const handleTabClick = (newTab, options = {
    updateURL: true
  }) => {
    setTab(newTab);
    if (!currentDbIds) return;
    const anchorId = TAB_ANCHORS[newTab];
    if (options.updateURL && anchorId) {
      const {pathname, search} = window.location;
      window.history.replaceState({}, "", `${pathname}${search}#${anchorId}`);
    }
    if (newTab === "policies" && policies.length === 0 && !policiesLoading && !policiesListFetched) {
      fetchTabContent(currentDbIds.POLICIES_DB_ID, {
        setter: setPolicies,
        loadingSetter: setPoliciesLoading,
        errorSetter: setPoliciesError,
        countSetter: setPoliciesCount,
        transform: filterPublishedPolicies
      }).then(() => setPoliciesListFetched(true));
    }
    if (newTab === "setup" && setupInstructions.length === 0 && !setupLoading && !setupListFetched) {
      fetchTabContent(currentDbIds.INSTRUCTIONS_DB_ID, {
        setter: setSetupInstructions,
        loadingSetter: setSetupLoading,
        errorSetter: setSetupError,
        countSetter: setSetupCount
      }).then(() => setSetupListFetched(true));
    }
  };
  const parseMarkdown = text => {
    if (!text) return null;
    const lines = text.split("\n");
    const result = [];
    let i = 0;
    while (i < lines.length) {
      const line = lines[i];
      const isCodeFence = l => l.trim().startsWith("```") || l.trim() === "`";
      if (isCodeFence(line)) {
        const fenceContent = line.trim().startsWith("```") ? line.slice(line.indexOf("```") + 3) : "";
        const codeBlock = fenceContent.trim() ? [fenceContent] : [];
        i++;
        while (i < lines.length && !isCodeFence(lines[i])) {
          codeBlock.push(lines[i]);
          i++;
        }
        if (i < lines.length) i++;
        result.push(<pre key={`code-${result.length}`} style={{
          margin: "12px 0",
          padding: "12px",
          background: "#f4f4f4",
          border: "1px solid #ddd",
          borderRadius: "4px",
          fontSize: "0.9em",
          overflowX: "auto",
          whiteSpace: "pre-wrap",
          fontFamily: 'Menlo, Monaco, "Courier New", monospace'
        }}>
            <code>{codeBlock.join("\n")}</code>
          </pre>);
      } else if (line.trim() === "") {
        result.push(<br key={`br-${result.length}`} />);
        i++;
      } else {
        result.push(<div key={`line-${result.length}`}>
            {parseInlineMarkdown(line)}
          </div>);
        i++;
      }
    }
    return result;
  };
  const parseInlineMarkdown = text => {
    const elements = [];
    function parseSegment(segment, key) {
      if (typeof segment !== "string") return segment;
      let result = [];
      let remaining = segment;
      let keyCounter = 0;
      while (remaining) {
        let earliestMatch = null;
        let matchType = null;
        const linkMatch = (/\[([^\]]+)\]\(([^)]+)\)/).exec(remaining);
        if (linkMatch && (!earliestMatch || linkMatch.index < earliestMatch.index)) {
          earliestMatch = linkMatch;
          matchType = "link";
        }
        const boldMatch = (/\*\*([^*]+)\*\*/).exec(remaining);
        if (boldMatch && (!earliestMatch || boldMatch.index < earliestMatch.index)) {
          earliestMatch = boldMatch;
          matchType = "bold";
        }
        const codeMatch = (/`([^`]+)`/).exec(remaining);
        if (codeMatch && (!earliestMatch || codeMatch.index < earliestMatch.index)) {
          earliestMatch = codeMatch;
          matchType = "code";
        }
        const italicMatch = (/\*([^*]+)\*(?!\*)/).exec(remaining);
        if (italicMatch && (!earliestMatch || italicMatch.index < earliestMatch.index)) {
          earliestMatch = italicMatch;
          matchType = "italic";
        }
        const underitalicMatch = (/_([^_]+)_/).exec(remaining);
        if (underitalicMatch && (!earliestMatch || underitalicMatch.index < earliestMatch.index)) {
          earliestMatch = underitalicMatch;
          matchType = "underitalic";
        }
        if (!earliestMatch) {
          if (remaining) result.push(remaining);
          break;
        }
        if (earliestMatch.index > 0) {
          result.push(remaining.slice(0, earliestMatch.index));
        }
        const matchContent = earliestMatch[1];
        let element;
        switch (matchType) {
          case "link":
            element = <a key={`${key}-link-${keyCounter++}`} href={earliestMatch[2]} target="_blank" rel="noopener noreferrer" style={{
              color: "#2563eb",
              textDecoration: "underline",
              cursor: "pointer"
            }}>
                {parseSegment(matchContent, `${key}-link-${keyCounter}`)}
              </a>;
            break;
          case "bold":
            element = <strong key={`${key}-bold-${keyCounter++}`}>
                {parseSegment(matchContent, `${key}-bold-${keyCounter}`)}
              </strong>;
            break;
          case "code":
            element = <code key={`${key}-code-${keyCounter++}`} style={{
              background: "#f0f0f0",
              padding: "2px 6px",
              borderRadius: "3px",
              fontFamily: 'Menlo, Monaco, "Courier New", monospace',
              fontSize: "0.9em"
            }}>
                {matchContent}
              </code>;
            break;
          case "italic":
            element = <em key={`${key}-italic-${keyCounter++}`}>
                {parseSegment(matchContent, `${key}-italic-${keyCounter}`)}
              </em>;
            break;
          case "underitalic":
            element = <em key={`${key}-underitalic-${keyCounter++}`}>
                {parseSegment(matchContent, `${key}-underitalic-${keyCounter}`)}
              </em>;
            break;
        }
        result.push(element);
        remaining = remaining.slice(earliestMatch.index + earliestMatch[0].length);
      }
      return result.length > 0 ? result : segment;
    }
    return parseSegment(text, "inline");
  };
  function ToolsTable({tools}) {
    return <table style={{
      width: "100%",
      borderCollapse: "collapse",
      marginTop: 8
    }}>
        <thead>
          <tr>
            <th style={{
      ...headerCell,
      width: "25%"
    }}>Tool Name</th>
            <th style={{
      ...headerCell,
      width: "55%"
    }}>Tool Description</th>
            <th style={{
      ...headerCell,
      width: "20%"
    }}>Tool Type</th>
          </tr>
        </thead>
        <tbody>
          {tools.length === 0 && searchTerm === "" ? <tr>
              <td style={cell} colSpan={3}>
                No tools have been documented yet.
              </td>
            </tr> : tools.length === 0 && searchTerm !== "" ? <tr>
              <td style={cell} colSpan={3}>
                No tools match your search criteria.
              </td>
            </tr> : tools.map((tool, idx) => <tr key={idx}>
                <td style={{
      ...cell,
      width: "25%"
    }}>{tool.name || "—"}</td>
                <td style={{
      ...cell,
      width: "55%"
    }}>
                  {tool.description || "—"}
                </td>
                <td style={{
      ...cell,
      width: "20%"
    }}>
                  {resolveToolType(tool) || "—"}
                </td>
              </tr>)}
        </tbody>
      </table>;
  }
  function PaginationControls({position = "bottom"}) {
    const [hoveredButton, setHoveredButton] = useState(null);
    const startIndex = filteredTools.length === 0 ? 0 : (currentPage - 1) * ITEMS_PER_PAGE + 1;
    const endIndex = Math.min(filteredTools.length, currentPage * ITEMS_PER_PAGE);
    const showingLabel = filteredTools.length === 0 ? "No tools to display" : `Showing ${startIndex}-${endIndex} of ${filteredTools.length}`;
    const buttonStyle = (disabled, isHovered) => ({
      display: "flex",
      alignItems: "center",
      justifyContent: "center",
      padding: "0 12px",
      cursor: disabled ? "not-allowed" : "pointer",
      border: `1px solid ${disabled ? "#e5e7eb" : isHovered ? "#d1d5db" : "#e9e9e9"}`,
      borderRadius: "8px",
      background: isHovered && !disabled ? "#f3f4f6" : "#ffffff",
      color: disabled ? "#9ca3af" : "#374151",
      width: "36px",
      height: "36px",
      minWidth: "36px",
      minHeight: "36px",
      gap: "8px",
      opacity: disabled ? 0.6 : 1,
      transition: "all 0.2s ease",
      fontSize: "16px",
      fontWeight: "500"
    });
    return <div style={{
      display: "flex",
      justifyContent: "space-between",
      alignItems: "center",
      gap: "16px",
      flexWrap: "wrap",
      marginTop: position === "top" ? "0" : "0px",
      marginBottom: position === "top" ? "0px" : "0",
      padding: "12px 0",
      borderTop: "none",
      borderBottom: position === "bottom" ? "1px solid #e5e7eb" : "none",
      background: "#ffffff"
    }}>
        <div style={{
      display: "flex",
      flexDirection: "column",
      gap: "4px"
    }}>
          <div style={{
      fontSize: "0.95em",
      color: "#374151",
      fontWeight: 500
    }}>
            {filteredTools.length === 0 ? "No tools to display" : `Page ${currentPage} of ${totalPages}`}
          </div>
          <div style={{
      fontSize: "0.85em",
      color: "#6b7280"
    }}>
            {showingLabel}
          </div>
        </div>
        <nav style={{
      display: "flex",
      gap: "4px",
      alignItems: "center"
    }}>
          <button onClick={() => setCurrentPage(1)} disabled={currentPage === 1} title="First page" onMouseEnter={() => setHoveredButton("first")} onMouseLeave={() => setHoveredButton(null)} style={buttonStyle(currentPage === 1, hoveredButton === "first")}>
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
              <path d="M6 2L2 8L6 14M10 2L6 8L10 14" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
          </button>
          <button onClick={() => setCurrentPage(prev => Math.max(1, prev - 1))} disabled={currentPage === 1} title="Previous page" onMouseEnter={() => setHoveredButton("prev")} onMouseLeave={() => setHoveredButton(null)} style={buttonStyle(currentPage === 1, hoveredButton === "prev")}>
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
              <path d="M10 2L4 8L10 14" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
          </button>
          <button onClick={() => setCurrentPage(prev => Math.min(totalPages, prev + 1))} disabled={currentPage === totalPages || totalPages === 0} title="Next page" onMouseEnter={() => setHoveredButton("next")} onMouseLeave={() => setHoveredButton(null)} style={buttonStyle(currentPage === totalPages || totalPages === 0, hoveredButton === "next")}>
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
              <path d="M6 2L12 8L6 14" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
          </button>
          <button onClick={() => setCurrentPage(totalPages)} disabled={currentPage === totalPages || totalPages === 0} title="Last page" onMouseEnter={() => setHoveredButton("last")} onMouseLeave={() => setHoveredButton(null)} style={buttonStyle(currentPage === totalPages || totalPages === 0, hoveredButton === "last")}>
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
              <path d="M10 2L14 8L10 14M6 2L10 8L6 14" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
          </button>
        </nav>
      </div>;
  }
  function PoliciesTable({policies, loading, error}) {
    const [copiedIndex, setCopiedIndex] = useState(null);
    if (loading) return <p>Loading Policies...</p>;
    if (error) return <p style={{
      color: "#b91c1c"
    }}>Error loading policies: {error}</p>;
    if (policies.length === 0) {
      return <div style={{
        paddingTop: "10px",
        paddingBottom: "10px"
      }}><p>There are no policy examples for this MCP server.</p></div>;
    }
    const gridTemplate = "minmax(100px, 0.4fr) minmax(260px, 0.8fr) minmax(360px, 1.2fr)";
    const headerRowStyle = {
      display: "grid",
      gridTemplateColumns: gridTemplate,
      background: "#f8fafc",
      borderBottom: "2px solid #e2e8f0",
      fontWeight: 600,
      fontSize: "0.95rem"
    };
    const bodyRowStyle = {
      display: "grid",
      gridTemplateColumns: gridTemplate,
      borderBottom: "1px solid #e2e8f0"
    };
    const headerCellStyle = {
      padding: "14px 12px",
      lineHeight: 1.4
    };
    const cellStyle = {
      padding: "16px 12px",
      lineHeight: 1.5,
      wordBreak: "break-word",
      overflowWrap: "break-word",
      whiteSpace: "normal",
      background: "#fff"
    };
    const getPrettyPrintedCode = code => {
      try {
        const parsed = JSON.parse(code.trim());
        return JSON.stringify(parsed, null, 2);
      } catch (e) {
        return code.trim();
      }
    };
    const handleCopy = (code, idx) => {
      if (typeof navigator === "undefined" || !navigator.clipboard) return;
      navigator.clipboard.writeText(getPrettyPrintedCode(code)).catch(() => {});
      setCopiedIndex(idx);
      setTimeout(() => setCopiedIndex(null), 2000);
    };
    return <div style={{
      overflowX: "auto"
    }}>
        <div style={{
      width: "100%",
      minWidth: "720px",
      border: "1px solid #e2e8f0",
      borderRadius: "12px",
      background: "#ffffff",
      boxShadow: "0 1px 3px rgba(15, 23, 42, 0.05)"
    }}>
          <div style={headerRowStyle}>
            <div style={headerCellStyle}>Policy Title</div>
            <div style={headerCellStyle}>Policy Description</div>
            <div style={headerCellStyle}>Policy Definition</div>
          </div>

          {policies.length === 0 ? <div style={{
      padding: "20px",
      textAlign: "center",
      color: "#64748b"
    }}>
              No policies have been documented yet.
            </div> : policies.map((policy, idx) => <div key={idx} style={bodyRowStyle}>
                <div style={{
      ...cellStyle,
      fontWeight: 500
    }}>{policy.name || "—"}</div>
                <div style={cellStyle}>{policy.description || "—"}</div>
                <div style={{
      ...cellStyle,
      padding: "12px"
    }}>
                  {policy.code ? <div style={{
      position: "relative"
    }}>
                      <button type="button" onClick={() => handleCopy(policy.code, idx)} title="Copy to clipboard" style={{
      position: "absolute",
      top: 6,
      right: 6,
      display: "inline-flex",
      alignItems: "center",
      justifyContent: "center",
      width: "32px",
      height: "32px",
      border: "1px solid #e5e7eb",
      borderRadius: "6px",
      background: "white",
      cursor: "pointer",
      zIndex: 10,
      transition: "all 0.2s ease",
      color: copiedIndex === idx ? "#22c55e" : "#374151"
    }} onMouseEnter={e => {
      if (copiedIndex !== idx) {
        e.currentTarget.style.backgroundColor = "#f3f4f6";
      }
    }} onMouseLeave={e => {
      e.currentTarget.style.backgroundColor = "white";
    }}>
                        {copiedIndex === idx ? <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{
      width: "16px",
      height: "16px"
    }}>
                            <path d="M20 6 9 17l-5-5"></path>
                          </svg> : <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{
      width: "16px",
      height: "16px"
    }}>
                            <rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect>
                            <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path>
                          </svg>}
                      </button>
                      <div style={{
      overflowX: "auto",
      maxWidth: "100%"
    }}>
                        <pre style={{
      margin: 0,
      padding: "10px",
      fontSize: "0.82rem",
      fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
      background: "#f1f5f9",
      borderRadius: "6px",
      whiteSpace: "pre",
      lineHeight: "1.45",
      color: "#1e293b",
      minWidth: "fit-content"
    }}>
                          <code>{getPrettyPrintedCode(policy.code)}</code>
                        </pre>
                      </div>
                    </div> : <span style={{
      color: "#94a3b8"
    }}>—</span>}
                </div>
              </div>)}
        </div>
      </div>;
  }
  function SetupInstructions({instructions, loading, error, serverInfo}) {
    if (loading) return <p>Loading Setup Instructions...</p>;
    if (error) return <p style={{
      color: "#b91c1c"
    }}>Error loading instructions: {error}</p>;
    if (instructions.length === 0) {
      return <p style={{
        paddingTop: "10px",
        paddingBottom: "10px"
      }}>There are no special setup instructions for this MCP server.</p>;
    }
    const instructionItemStyle = {
      padding: "16px 0",
      borderBottom: "1px solid #e9e9e9",
      listStyleType: "none"
    };
    const lastItemStyle = {
      ...instructionItemStyle,
      borderBottom: "none"
    };
    return <div style={{
      padding: "16px",
      background: "#ffffff",
      borderRadius: "8px",
      boxShadow: "0 1px 3px rgba(0,0,0,0.05)"
    }}>
        <h3 style={{
      borderBottom: "2px solid #224035",
      color: "#224035",
      paddingBottom: "8px",
      marginBottom: "16px"
    }}>
          Setup Guide for {serverInfo.name}
        </h3>
        <ol style={{
      padding: 0,
      margin: 0,
      counterReset: "step-counter"
    }}>
          {instructions.map((item, idx) => {
      const isLast = idx === instructions.length - 1;
      const currentStyle = isLast ? lastItemStyle : instructionItemStyle;
      return <li key={idx} style={currentStyle}>
                <div style={{
        display: "flex",
        alignItems: "flex-start",
        gap: "12px"
      }}>
                  <div style={{
        background: "#224035",
        color: "white",
        borderRadius: "50%",
        width: "28px",
        height: "28px",
        display: "flex",
        alignItems: "center",
        justifyContent: "center",
        fontWeight: "bold",
        fontSize: "0.9em",
        flexShrink: 0
      }}>
                    {idx + 1}
                  </div>

                  <div>
                    {item.name && <strong style={{
        display: "block",
        color: "#224035",
        marginBottom: "4px"
      }}>
                        {item.name}
                      </strong>}

                    <div style={{
        margin: 0,
        color: "#444",
        lineHeight: 1.6
      }}>
                      {parseMarkdown(item.description)}
                    </div>

                    {item.code && <pre style={{
        margin: "12px 0 0 0",
        padding: "12px",
        background: "#f4f4f4",
        border: "1px solid #ddd",
        borderRadius: "4px",
        fontSize: "0.9em",
        overflowX: "auto",
        whiteSpace: "pre-wrap"
      }}>
                        {item.code}
                      </pre>}
                  </div>
                </div>
              </li>;
    })}
        </ol>
      </div>;
  }
  if (!serverInfo) {
    if (toolsError && !toolsLoading) {
      return <div className="flex flex-col items-center justify-center py-32 text-center">
          <p className="text-lg text-red-600 mb-4">
            Unable to load server details.
          </p>
          <p className="text-gray-500">{toolsError}</p>
        </div>;
    }
    return <div className="flex items-center justify-center py-32">
        <p className="text-lg text-gray-500">Loading MCP Server details...</p>
      </div>;
  }
  const lastUpdatedDate = serverInfo?.lastUpdated ? new Date(serverInfo.lastUpdated) : null;
  const hasValidLastUpdated = lastUpdatedDate && !isNaN(lastUpdatedDate.getTime());
  const displayedPoliciesCount = policies.length > 0 ? policies.length : policiesCount;
  const hasPolicies = policies.length > 0 ? true : policiesCountFetched ? policiesCount > 0 : true;
  return <div className="not-prose space-y-8">
      {serverInfo && <div className="not-prose -mx-6 sm:-mx-8 lg:mx-0">
          <div className="border-b border-gray-200 bg-white serverContentMain">
            <div className="px-6 py-12 sm:px-8 lg:px-16">
              <div className="mx-auto max-w-7xl">
                <div className="flex flex-col gap-10 lg:flex-row lg:items-start lg:gap-16">

                  {}
                  <div className="flex-1">

                    {}
                    <div className="flex items-center gap-5">
                      <img src={serverInfo.logo} alt={`${serverInfo.name} Logo`} className="h-16 w-16 rounded-xl shadow-lg ring-1 ring-black/5 serverInfoLogo" />
                      <h1 className="text-4xl font-bold tracking-tight text-gray-900 serverInfoName">
                        {serverInfo.name}
                      </h1>
                    </div>

                    <div className="mt-4 flex flex-wrap items-center gap-3 serverInfoCapsules">
                      <span className="inline-flex items-center gap-2 rounded-lg bg-gray-100 px-4 py-2 text-sm font-medium text-gray-700 ring-1 ring-gray-600/20">
                        Secure
                      </span>
                      <span className="inline-flex items-center gap-2 rounded-lg bg-green-50 px-4 py-2 text-sm font-medium text-green-700 ring-1 ring-green-600/20">
                        {serverInfo.managedBy === "Barndoor" || serverInfo.managedBy === "N/A" ? "Barndoor Managed" : serverInfo.managedBy === "Remote" ? "Official Remote" : serverInfo.managedBy}
                      </span>
                      <span className="inline-flex items-center gap-2 rounded-lg bg-blue-50 px-4 py-2 text-sm font-medium text-blue-700 ring-1 ring-blue-600/20">
                        {serverInfo?.category || "Uncategorized"}
                      </span>
                    </div>

                    <div className="mt-6 space-y-4 text-lg leading-8 text-gray-600 max-w-5xl not-prose serverInfoSummaryAndHowTo">
                      {serverInfo.summary && <>
                          <p>
                            <strong>Summary:</strong> {serverInfo.summary}
                          </p> <br /> <br /></>}

                      {serverInfo.howTo && <p>
                          <strong>How Teams Use It:</strong> {serverInfo.howTo}
                        </p>}
                    </div>

                    {wistiaId && <div className="mt-6 max-w-lg" style={{
    marginLeft: "auto",
    marginRight: "auto"
  }}>
                        <div style={{
    position: "relative",
    paddingBottom: "56.25%",
    height: 0,
    width: "100%",
    maxWidth: "680px",
    borderRadius: "12px",
    overflow: "hidden",
    boxShadow: "0 10px 25px rgba(15, 23, 42, 0.1)"
  }}>
                          <iframe src={`https://fast.wistia.net/embed/iframe/${wistiaId}?seo=false&videoFoam=true`} title={`${serverInfo.name} demo video`} allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowFullScreen style={{
    position: "absolute",
    top: 0,
    left: 0,
    width: "100%",
    height: "100%",
    border: 0
  }}></iframe>
                        </div>
                      </div>}



                  </div>
                  <div className="w-full max-w-md lg:w-auto">
                    <dl className="grid grid-cols-1 gap-6 sm:grid-cols-3 lg:grid-cols-1 lg:gap-8">
                      <div className="rounded-xl bg-gray-50 px-6 py-5">
                        <dt className="text-sm font-medium text-gray-500">Tools</dt>
                        <dd className="mt-2 text-3xl font-semibold tracking-tight text-gray-900">
                          {allTools.length.toLocaleString()}
                        </dd>
                      </div>

                      {hasPolicies && <div className="rounded-xl bg-gray-50 px-6 py-5">
                          <dt className="text-sm font-medium text-gray-500">Policies</dt>
                          <dd className="mt-2 text-3xl font-semibold tracking-tight text-gray-900">
                            {displayedPoliciesCount.toLocaleString()}
                          </dd>
                        </div>}



                      {}
                      {}
                    </dl>

                  </div>

                </div>
              </div>
            </div>
          



            {}
            <div className="border-b border-gray-200 xl:-mx-20 bg-white">
              <div className="mint-px-6 sm:mint-px-8 lg:mint-px-16" style={{
    paddingTop: "30px",
    paddingBottom: "0px"
  }}>
                <div className="mx-auto max-w-7xl">
                  <nav className="-mb-px flex space-x-8" style={{
    marginBottom: "-1px"
  }}>
                  {[{
    id: "tools",
    label: `Tools (${allTools.length})`
  }, {
    id: "policies",
    label: "Policy Examples"
  }, {
    id: "setup",
    label: "Setup Instructions"
  }].map(item => <button key={item.id} onClick={() => handleTabClick(item.id)} className={`
                  whitespace-nowrap border-b-2 px-1 pt-4 pb-4 text-sm font-medium transition-colors
                  ${tab === item.id ? "border-blue-600 text-blue-600" : "border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700"}
                `}>
                      {item.label}
                    </button>)}
                  </nav>
                </div>
              </div>
            </div>

            <div className="px-6 sm:px-8 lg:px-16">
              <div className="mx-auto max-w-7xl">


              {}
              <div id={TAB_ANCHORS.tools} style={TAB_ANCHOR_STYLE} />
              {tab === "tools" && <>
                  {toolsError && <p style={{
    color: "#b91c1c",
    marginTop: 12
  }}>{toolsError}</p>}
                  {toolsLoading ? <p>Loading Tools...</p> : <>
                      <div style={{
    padding: "0 16px",
    marginTop: "5px"
  }}>
                        <PaginationControls position="top" />
                      </div>
                      <div style={{
    padding: "8px 16px"
  }}>
                        <input type="text" placeholder="Search tools by name, type, or description..." value={searchTerm} onChange={e => {
    setSearchTerm(e.target.value);
    setCurrentPage(1);
  }} style={{
    width: "calc(100% - 20px)",
    padding: "10px",
    marginTop: "0",
    border: "1px solid #ddd",
    borderRadius: "6px",
    fontSize: "1em"
  }} />
                      </div>
                      <div style={{
    padding: "0 16px"
  }}>
                        <ToolsTable tools={paginatedTools} />
                      </div>
                      {filteredTools.length > ITEMS_PER_PAGE && <div style={{
    padding: "0 16px"
  }}>
                          <PaginationControls position="bottom" />
                        </div>}
                    </>}
                </>}

              <div id={TAB_ANCHORS.policies} style={TAB_ANCHOR_STYLE} />
              {tab === "policies" && <div style={{
    paddingTop: "10px"
  }}>
                  <PoliciesTable policies={policies} loading={policiesLoading} error={policiesError} />
                </div>}

              <div id={TAB_ANCHORS.setup} style={TAB_ANCHOR_STYLE} />
              {tab === "setup" && serverInfo && <div style={{
    paddingTop: "10px",
    paddingBottom: "10px"
  }}>
                  <SetupInstructions instructions={setupInstructions} loading={setupLoading} error={setupError} serverInfo={serverInfo} />
                </div>}
              </div>
            </div>
          </div>
        </div>}

    </div>;
}

<ServerDetails serverName="apify" />
