Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 0 additions & 92 deletions app/actions/create-token.ts

This file was deleted.

2 changes: 1 addition & 1 deletion app/api/chat/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Connection } from "@smithery/api/resources/experimental/connect/connections.mjs";
import type { Connection } from "@smithery/api/resources/connections/connections.mjs";
import {
createAgentUIStreamResponse,
ToolLoopAgent,
Expand Down
2 changes: 1 addition & 1 deletion app/api/tool-search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import type { Tool } from "@modelcontextprotocol/sdk/types.js";
import { Smithery } from "@smithery/api";
import { createConnection } from "@smithery/api/lib/mcp-transport.mjs";
import type { Connection } from "@smithery/api/resources/experimental/connect/connections";
import type { Connection } from "@smithery/api/resources/connections/connections.mjs";
import { Index } from "flexsearch";
import { estimateTokenCount } from "tokenx";
import type {
Expand Down
12 changes: 10 additions & 2 deletions app/docs/docs-layout-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ import { Suspense } from "react";
import { SharedSidebar } from "@/components/shared-sidebar";
import { SmitheryProvider } from "@/registry/new-york/smithery/smithery-provider";

export function DocsLayoutClient({ children }: { children: React.ReactNode }) {
interface DocsLayoutClientProps {
children: React.ReactNode;
smitheryApiKey?: string;
}

export function DocsLayoutClient({
children,
smitheryApiKey,
}: DocsLayoutClientProps) {
return (
<SmitheryProvider>
<SmitheryProvider smitheryApiKey={smitheryApiKey}>
<SharedSidebar>
<Suspense
fallback={
Expand Down
6 changes: 5 additions & 1 deletion app/docs/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ export default function DocsLayout({
}: {
children: React.ReactNode;
}) {
return <DocsLayoutClient>{children}</DocsLayoutClient>;
return (
<DocsLayoutClient smitheryApiKey={process.env.SMITHERY_API_KEY}>
{children}
</DocsLayoutClient>
);
}
33 changes: 8 additions & 25 deletions app/docs/tokens/page.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Tokens

The Tokens component provides a token selector and manager for Smithery API authentication. It allows users to manage multiple API tokens, switch between them, and create new ones.
The Tokens component displays the configured Smithery API key and namespace settings. It reads the API key from the server and renders token details client-side.

The preview for this component is displayed in the header above - click "Modify" to see the token management dialog.
The preview for this component is displayed in the header above. Click "Settings" to manage namespace selection and creation.

## Installation

Expand All @@ -13,35 +13,18 @@ The preview for this component is displayed in the header above - click "Modify"
```tsx
import { Tokens } from "@/registry/new-york/smithery/tokens"

// You need an initial token response from your server
const initialTokenResponse = {
token: "your-api-token",
expiresAt: "2024-12-31T23:59:59Z" // or "never"
}

export function MyApp() {
return (
<Tokens
initialTokenResponse={initialTokenResponse}
onCreateToken={async () => {
// Optional: fetch a new token from your server
const response = await fetch("/api/create-token")
return response.json()
}}
/>
)
return <Tokens />
}
```

## Props

- `initialTokenResponse` (required): The initial token to display, with `token` and `expiresAt` fields
- `onCreateToken` (optional): Async function to create a new token. If not provided, the "Create New Token" button won't appear
- This component has no direct props. It consumes `useSmitheryContext` from `SmitheryProvider`.

## Features

- Display the currently selected token (masked for security)
- Switch between multiple tokens via a dropdown
- Remove expired or unused tokens
- Create new tokens via the optional callback
- Persists tokens to localStorage using jotai atoms
- Display the configured API key in masked form
- Show the currently selected namespace
- Switch namespaces from a dropdown
- Create new namespaces directly from the settings dialog
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HomePage } from "@/components/home";

export default function Home() {
return <HomePage />;
return <HomePage smitheryApiKey={process.env.SMITHERY_API_KEY} />;
}
2 changes: 1 addition & 1 deletion components/chat-block.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
import { useChat } from "@ai-sdk/react";
import type { Connection } from "@smithery/api/resources/experimental/connect/connections.mjs";
import type { Connection } from "@smithery/api/resources/connections/connections.mjs";
import {
DefaultChatTransport,
lastAssistantMessageIsCompleteWithToolCalls,
Expand Down
5 changes: 2 additions & 3 deletions components/docs/component-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { createMCPClient } from "@ai-sdk/mcp";
import Smithery from "@smithery/api";
import { createConnection } from "@smithery/api/mcp";
import type { Connection } from "@smithery/api/resources/experimental/connect/connections.mjs";
import type { Connection } from "@smithery/api/resources/connections/connections.mjs";
import { useQuery } from "@tanstack/react-query";
import type { Tool, ToolExecutionOptions } from "ai";
import { useAtomValue } from "jotai";
Expand Down Expand Up @@ -40,8 +40,7 @@ function useConnections(
if (!token) throw new Error("Token required");
if (!namespace) throw new Error("Namespace required");
const client = getSmitheryClient(token);
const { connections } =
await client.experimental.connect.connections.list(namespace);
const { connections } = await client.connections.list(namespace);
return { connections, namespace };
},
enabled: !!token && !!namespace,
Expand Down
5 changes: 2 additions & 3 deletions components/docs/previews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { createMCPClient } from "@ai-sdk/mcp";
import Smithery from "@smithery/api";
import { createConnection } from "@smithery/api/mcp";
import type { Connection } from "@smithery/api/resources/experimental/connect/connections.mjs";
import type { Connection } from "@smithery/api/resources/connections/connections.mjs";
import { useQuery } from "@tanstack/react-query";
import type { ToolExecutionOptions } from "ai";
import { AlertCircle } from "lucide-react";
Expand Down Expand Up @@ -65,8 +65,7 @@ function useConnections(token: string, namespace: string) {
queryKey: ["connections", token, namespace],
queryFn: async () => {
const client = getSmitheryClient(token);
const { connections } =
await client.experimental.connect.connections.list(namespace);
const { connections } = await client.connections.list(namespace);
return { connections, namespace };
},
});
Expand Down
8 changes: 6 additions & 2 deletions components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import { Suspense } from "react";
import { SmitheryProvider } from "@/registry/new-york/smithery/smithery-provider";
import { RegistryBrowser } from "./registry-browser";

export function HomePage() {
interface HomePageProps {
smitheryApiKey?: string;
}

export function HomePage({ smitheryApiKey }: HomePageProps) {
return (
<Suspense>
<SmitheryProvider>
<SmitheryProvider smitheryApiKey={smitheryApiKey}>
<RegistryBrowser />
</SmitheryProvider>
</Suspense>
Expand Down
Loading