"use client"; import { useState } from "react"; import { api } from "~/trpc/react"; function CreateApiKeyForm() { const [name, setName] = useState(""); const [newKey, setNewKey] = useState(null); const [copied, setCopied] = useState(false); const trpcUtilities = api.useUtils(); const createKey = api.apiKey.create.useMutation({ onSuccess: async (data) => { setNewKey(data.apiKey); setName(""); await trpcUtilities.apiKey.invalidate(); }, }); const handleCopy = async () => { if (newKey) { await navigator.clipboard.writeText(newKey); setCopied(true); setTimeout(() => setCopied(false), 2000); } }; if (newKey) { return (

your new api key (copy it now - you will not be able to see it again):

{newKey}
); } return (
{ formEvent.preventDefault(); if (name.trim()) { createKey.mutate({ name }); } }} > setName(inputEvent.target.value)} placeholder="key name (e.g., development, claude-code)" value={name} />
); } function ApiKeyList() { const [keys] = api.apiKey.list.useSuspenseQuery(); const trpcUtilities = api.useUtils(); const revokeKey = api.apiKey.revoke.useMutation({ onSuccess: async () => { await trpcUtilities.apiKey.invalidate(); }, }); if (keys.length === 0) { return (

no api keys yet. create one to use with the mcp server.

); } return (
{keys.map((key) => (

{key.name}

imemio_{key.keyPrefix} ... |{" "} {key.lastUsedAt ? `last used ${key.lastUsedAt.toLocaleDateString()}` : "never used"}

))}
); } export function ApiKeySettings() { return (
); }