Smithery Tokens
smithery/smithery-tokensFreeBlock
A component for managing Smithery API tokens with selection and creation capabilities.
Install it
npx shadcn@latest add https://smithery.chat/r/smithery-tokens.jsonSource
1"use client";23import { useAtom } from "jotai";4import { Loader2, Plus, Trash2 } from "lucide-react";5import { useState } from "react";6import {7 CodeBlock,8 CodeBlockCopyButton,9} from "@/components/ai-elements/code-block";10import { Button } from "@/components/ui/button";11import {12 Dialog,13 DialogContent,14 DialogHeader,15 DialogTitle,16 DialogTrigger,17} from "@/components/ui/dialog";18import { Input } from "@/components/ui/input";19import {20 Select,21 SelectContent,22 SelectItem,23 SelectTrigger,24 SelectValue,25} from "@/components/ui/select";26import { selectedTokenAtom, tokensCreatedAtom } from "@/hooks/use-smithery";27import { useSmitheryContext } from "@/registry/new-york/smithery/smithery-provider";2829function formatTimeRemaining(expiresAt: string): string {30 if (!expiresAt || expiresAt === "never") return "1 hour";31 const expiresDate = new Date(expiresAt);32 const now = new Date();33 const diffMs = expiresDate.getTime() - now.getTime();34 if (diffMs <= 0) return "expired";35 const diffMins = Math.floor(diffMs / 60000);36 if (diffMins < 60) {37 return `${diffMins} minute${diffMins !== 1 ? "s" : ""}`;38 }39 const diffHours = Math.floor(diffMins / 60);40 return `${diffHours} hour${diffHours !== 1 ? "s" : ""}`;41}4243export function Tokens() {44 const [tokensCreated, setTokensCreated] = useAtom(tokensCreatedAtom);45 const [selectedToken, setSelectedToken] = useAtom(selectedTokenAtom);46 const [isOpen, setIsOpen] = useState(false);47 const [isCreatingToken, setIsCreatingToken] = useState(false);48 const [isCreatingNamespace, setIsCreatingNamespace] = useState(false);49 const [newNamespaceName, setNewNamespaceName] = useState("");50 const [showNamespaceInput, setShowNamespaceInput] = useState(false);5152 const {53 createToken,54 createNamespace,55 loading,56 namespace,57 namespaces,58 setNamespace,59 sandboxMode,60 tokenExpiresAt,61 } = useSmitheryContext();62 const [namespaceError, setNamespaceError] = useState<string | null>(null);6364 const handleRemoveToken = () => {65 if (!selectedToken) return;6667 setTokensCreated((prev) =>68 prev.filter((token) => token.token !== selectedToken.token),69 );70 setSelectedToken(null);71 };7273 const handleCreateToken = async () => {74 setIsCreatingToken(true);75 try {76 await createToken();77 } finally {78 setIsCreatingToken(false);79 }80 };8182 const handleCreateNamespace = async () => {83 if (!newNamespaceName.trim()) return;84 setIsCreatingNamespace(true);85 setNamespaceError(null);86 try {87 await createNamespace(newNamespaceName.trim());88// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from smithery
All 10 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Smitherysmithery | smithery | Blocks | Free | 9 deps · 11 files | |
| Smithery Connection Contextsmithery-connection-context | smithery | Blocks | Free | no deps | |
| Smithery Connectionssmithery-connections | smithery | Blocks | Free | 8 deps · 9 files | |
| Smithery Schema Formsmithery-schema-form | smithery | Blocks | Free | 1 dep | |
| Smithery Server Searchsmithery-server-search | smithery | Blocks | Free | 3 deps · 3 files | |
| Smithery Tool Cardsmithery-tool-card | smithery | Blocks | Free | 5 deps · 4 files | |
| Smithery Tool Detail Dialogsmithery-tool-detail-dialog | smithery | Blocks | Free | 5 deps · 3 files | |
| Smithery Tools Panelsmithery-tools-panel | smithery | Blocks | Free | 5 deps · 5 files |
