### Required Setup for Quick Start Source: https://smithery.ai/docs/use/triggers To get started, you need a Smithery namespace, an API key, an HTTPS endpoint for webhooks, and an active MCP session. ```plaintext \"You’ll need:\" ``` ```plaintext \"A Smithery namespace (e.g. \", \"_jsx(_components.code, {\n children: \"my-app\"\n }), \" ) — created on the \", \"_jsx(_components.a, {\n href: \"https://smithery.ai\",\n children: \"dashboard\"\n }), \" or via \", \"_jsx(_components.a, {\n href: \"/use/connect\",\n children: \"Connect\"\n }), \".\" ``` ```plaintext \"A \", \"_jsx(_components.code, {\n children: \"SMITHERY_API_KEY\"\n }), \" from your namespace settings.\" ``` ```plaintext An HTTPS endpoint that can receive webhooks. ``` ```plaintext \"An active MCP session to the connection (via the \", \"_jsx(_components.a, {\n href: \"/use/connect\",\n children: \"SDK\"\n }), \" or CLI).\" ``` -------------------------------- ### HTTP Transport Setup Example Source: https://smithery.ai/docs/use/deep-linking This example demonstrates setting up a client connection using an HTTP transport. It's suitable for scenarios where HTTP is the preferred communication protocol. ```typescript // Example with HTTP transport async function setupHttpMCP(url: string) { const config = handleDeepLink(url) } ``` -------------------------------- ### Quick Start: Required Setup Source: https://smithery.ai/docs/use/triggers Lists the prerequisites for using Smithery triggers, including namespace creation, API key, and an active MCP session. ```plaintext You’ll need: A Smithery namespace (e.g. my-app) — created on the dashboard or via Connect. A SMITHERY_API_KEY from your namespace settings. An HTTPS endpoint that can receive webhooks. An active MCP session to the connection (via the SDK or CLI). ``` -------------------------------- ### Example: Stdio MCP Configuration Source: https://smithery.ai/docs/use/deep-linking Configuration for connecting to an MCP server using stdio. Requires a command and arguments to start the server executable. ```typescript const config: MCPConfig = { type: "stdio", command: "npx", args: ["-y", "smithery@latest", "run", "@wonderwhy-er/desktop-commander"] }; ``` -------------------------------- ### Setup Stdio Transport for MCP Source: https://smithery.ai/docs/use/deep-linking This example shows how to set up a Multi-Channel Protocol (MCP) using the stdio transport. It's designed for scenarios where communication happens over standard input/output streams. ```typescript // Example with stdio transport async function setupStdioMCP(url: string ``` -------------------------------- ### JavaScript Example for Server Configuration Source: https://smithery.ai/docs/use/connect This example demonstrates how to configure a server in JavaScript, passing an API key as a header and a project ID as a query parameter. ```javascript import { Github } from "@smithery-ai/github"; const github = new Github({ apiKey: "your-api-key", projectId: "your-project-id", }); const result = await github.searchCode({ query: "example" }); ``` -------------------------------- ### CLI Connection Example Source: https://smithery.ai/docs/use/connect Example of how to initiate a connection using the CLI. This snippet shows a basic command to connect. ```shellscript smithery connect --url https://github.run.tools ``` -------------------------------- ### CLI Example for Server Configuration Source: https://smithery.ai/docs/use/connect This example shows how to configure a server using the CLI, passing an API key as a header and a project ID as a query parameter. ```shellscript export SMITHERY_API_KEY="your-api-key" mcp \\ --config "{\"projectId\": \"your-project-id\"}" \\ github \\ "search-code" \\ --query "example" ``` -------------------------------- ### Setup Client with Stdio Transport Source: https://smithery.ai/docs/llms-full.txt Example implementation for setting up a Smithery AI client using stdio transport based on a deep link configuration. Requires the 'StdioClientTransport' and 'Client' classes. ```typescript // Example with stdio transport async function setupStdioMCP(url: string) { const config = handleDeepLink(url) const transport = new StdioClientTransport({ command: config.command, args: config.args }) const client = new Client({ name: "Test client" }) await client.connect(transport) return client } ``` -------------------------------- ### Handling Authorization with Setup URL Source: https://smithery.ai/docs/use/connect When initiating an OAuth flow, use the provided setup URL to redirect users. This ensures a stable connection ID for subsequent retries. ```javascript When you need to send a user through OAuth, prefer creating or updating the connection first and redirecting to the hosted ", _jsx(_components.code, { children: "setupUrl" }), ". That gives you a stable ", _jsx(_components.code, { children: "connectionId" }), " to retry with after the user returns to your app." ``` -------------------------------- ### CLI Example: Aggregate Tools Across Connections Source: https://smithery.ai/docs/use/connect This example shows how to aggregate tools from multiple connections using the CLI. It's useful for managing and interacting with tools from various service endpoints. ```shellscript smithery mcp --connections "$(smithery conn)" ``` -------------------------------- ### Stdio-based Configuration Example Source: https://smithery.ai/docs/use/deep-linking An example JSON configuration for a stdio-based server connection. Specifies the type, command, and arguments for the server executable. ```json { "type": "stdio", "command": "npx", "args": [ "-y", "smithery@latest", "run", "@wonderwhy-er/desktop-commander" ] } ``` -------------------------------- ### Header Transformation Example Source: https://smithery.ai/docs/build/session-config This example demonstrates how to map a client-provided header 'x-from' to a server-expected header 'Authorization'. It also shows the mapping for 'x-to' to 'Authorization'. ```javascript _.jsxs(_.components.span, { className: "line", children: [ _jsx(_.components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"x-from\"" }), _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: ":" }), _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " { " }), _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: "header:" }), _jsx(_.components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"posthog-api-key\"" }), _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " }, " }), _jsx(_.components.span, { style: { color: "#6E7781", "--shiki-dark": "#6A9955" }, children: "// Client provides this header" }) ] }), "\n", _jsxs(_.components.span, { className: "line", children: [ _jsx(_.components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"x-to\"" }), _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: ":" }), _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " { " }), _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: "header:" }), _jsx(_.components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"Authorization\"" }), _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " } " }), _jsx(_.components.span, { style: { color: "#6E7781", "--shiki-dark": "#6A9955" }, children: "// PostHog expects Authorization" }) ] }), "\n", _jsx(_.components.span, { className: "line", children: _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " })" }) ]), "\n", _jsxs(_.components.span, { className: "line", children: [ _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " ." }), _jsx(_.components.span, { style: { color: "#8250DF", "--shiki-dark": "#DCDCAA" }, children: "describe" }), _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "(" }), _jsx(_.components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"Your PostHog API key\"" }), _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: ")," }) ] }), "\n", _jsx(_.components.span, { className: "line", children: _jsx(_.components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "});" }) ]) ``` -------------------------------- ### Read-Only Dashboard Token CLI Example Source: https://smithery.ai/docs/use/token-scoping This example demonstrates how to create a read-only token for dashboard access using the CLI. ```shellscript smithery token create --resource connections --operations read --ttl 1h ``` -------------------------------- ### Install Typed SDK for Exa Source: https://smithery.ai/docs/llms-full.txt Installs the typed TypeScript SDK for the Exa MCP server from the Smithery package registry. ```bash npm install https://pkg.smithery.ai/exa ``` -------------------------------- ### Install Smithery CLI Source: https://smithery.ai/docs/llms-full.txt Install the Smithery CLI globally using npm. Requires Node.js 20 or later. ```bash npm install -g smithery@latest ``` -------------------------------- ### Metadata AND Logic Example Source: https://smithery.ai/docs/use/token-scoping Demonstrates how metadata within a single object is ANDed. Use a list for OR logic. ```javascript { owner: 'alice', env: 'prod' } ``` ```javascript [{ owner: 'alice' }, { env: 'prod' }] ``` -------------------------------- ### Smithery CLI Examples Source: https://smithery.ai/docs/concepts/cli Common Smithery CLI commands for viewing help, authenticating, and searching for MCP servers. ```shellscript # Show the help menu smithery --help ``` ```shellscript # Authenticate with Smithery smithery auth login ``` ```shellscript # Search for MCP servers smithery ``` -------------------------------- ### Search for skills Source: https://smithery.ai/docs/concepts/cli Use this command to search for available skills. The example searches for skills related to 'code review'. ```bash smithery skill search "code review" ``` -------------------------------- ### Example Connection Configuration Source: https://smithery.ai/docs/use/connect This snippet shows how to configure a connection with a specific namespace and connection ID. Use this for establishing a connection to a service. ```javascript const exa = new Exa( { apiKey: "YOUR_API_KEY", // You can also pass in a connection ID connectionId: "exa", // Or a namespace namespace: "my-app", } ); ``` -------------------------------- ### Adding a Server with Configuration via CLI Source: https://smithery.ai/docs/use/connect Shows how to add a server using the CLI, specifying configuration parameters like an API key as a header and a project ID as a query parameter. ```shellscript # Add a server with config (API key as header, project ID as query param) smithery server add github \"https://api.github.com\" \"--header\" \"Authorization: token $GITHUB_API_TOKEN\" \"--query\" \"client_id=$GITHUB_CLIENT_ID\" ``` -------------------------------- ### Setup Client with HTTP Transport Source: https://smithery.ai/docs/llms-full.txt Example implementation for setting up a Smithery AI client using HTTP transport based on a deep link configuration. Requires the 'StreamableHTTPClientTransport' and 'Client' classes. ```typescript // Example with HTTP transport async function setupHttpMCP(url: string) { const config = handleDeepLink(url) const transport = new StreamableHTTPClientTransport(config.url) const client = new Client({ name: "Test client" }) await client.connect(transport) return client } ``` -------------------------------- ### CLI Connection Example Source: https://smithery.ai/docs/use/connect Use this command to establish a connection to a service via the CLI. Ensure you have the necessary authentication tokens. ```shellscript # Connect to a ``` -------------------------------- ### Get a namespace Source: https://smithery.ai/docs/api-reference/namespaces Get a single namespace by its name. ```APIDOC ## GET /namespaces/{name} ### Description Get a single namespace by its name. ### Method GET ### Endpoint /namespaces/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the namespace to retrieve. ### Response #### Success Response (200) - **name** (string) - The name of the namespace. - **owner** (string) - The owner of the namespace. - **createdAt** (string) - The timestamp when the namespace was created. ``` -------------------------------- ### CLI Quick Start for Smithery Source: https://smithery.ai/docs/use/connect Basic CLI commands to log in, add a server, list tools, and call a tool. ```bash smithery auth login smithery mcp add exa --id exa smithery tool list exa smithery tool call exa search '{"query": "latest news about MCP"}' ``` -------------------------------- ### Get a skill Source: https://smithery.ai/docs/api-reference/skills Get a single skill by its namespace and slug. ```APIDOC ## GET /skills/{namespace}/{slug} ### Description Get a single skill by its namespace and slug. ### Method GET ### Endpoint /skills/{namespace}/{slug} ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the skill. - **slug** (string) - Required - The slug of the skill. ### Response #### Success Response (200) - **title** (string) - The title of the skill. - **description** (string) - A brief description of the skill. - **namespace** (string) - The namespace the skill belongs to. - **slug** (string) - The unique slug for the skill. - **gitUrl** (string) - The GitHub repository URL for the skill. #### Response Example { "title": "Summarize Text", "description": "Summarizes a given piece of text.", "namespace": "example", "slug": "summarize-text", "gitUrl": "https://github.com/example/summarize-text.git" } ``` -------------------------------- ### Create a Token for Reading Servers Source: https://smithery.ai/docs/use/token-scoping This example shows how to create a token that allows read access to servers within the 'my-app' namespace. The token has a TTL of 1 hour. ```bash curl -X POST https://api.smithery.ai/v1/tokens \ -H "Authorization: Bearer $SMITHERY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "namespaces": "my-app", "resources": "servers", "operations": "read", "ttl": "1h" }' ``` -------------------------------- ### GET Get a server Source: https://smithery.ai/docs/api-reference/servers Retrieves details for a specific server. ```APIDOC ## GET /servers/{server_id} ### Description Retrieves details for a specific server. ### Method GET ### Endpoint /servers/{server_id} ### Parameters #### Path Parameters - **server_id** (string) - Required - The unique identifier of the server. ``` -------------------------------- ### Get Trigger Source: https://smithery.ai/docs/concepts/registry_search_servers Gets the schema for a single trigger type. ```APIDOC ## GET /connect/{namespace}/{connectionId}/.triggers/{triggerName} ### Description Gets the schema for a single trigger type. ### Method GET ### Endpoint /connect/{namespace}/{connectionId}/.triggers/{triggerName} ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the connection. - **connectionId** (string) - Required - The ID of the connection. - **triggerName** (string) - Required - The name of the trigger. ### Request Body (No request body details provided in the source) ### Response #### Success Response (200) (No response details provided in the source) #### Response Example (No response example provided in the source) ``` -------------------------------- ### Create a Multi-Resource Token Source: https://smithery.ai/docs/use/token-scoping This example shows how to create a token that grants access to multiple resources ('connections' and 'databases') and multiple operations ('execute' and 'read'). ```shell smithery token create \ -H "Content-Type: application/json" \ -d '{ "policy": [ { "namespaces": "my-app", "resources": ["connections", "databases"], "operations": ["execute", "read"], "metadata": { "userId": "user-123" }, "ttl": "30m" } ] }' ``` -------------------------------- ### Server Configuration Example Source: https://smithery.ai/docs/build/session-config This snippet shows how to define server configuration, including its name and version. It's used to set up the basic parameters for a session. ```javascript const config = { server: { name: "My Server", version: "1.0.0", }, }; ``` -------------------------------- ### GET Get a release Source: https://smithery.ai/docs/api-reference/servers Retrieves details for a specific release of a server. ```APIDOC ## GET /servers/{server_id}/releases/{release_id} ### Description Retrieves details for a specific release of a server. ### Method GET ### Endpoint /servers/{server_id}/releases/{release_id} ### Parameters #### Path Parameters - **server_id** (string) - Required - The unique identifier of the server. - **release_id** (string) - Required - The unique identifier of the release. ``` -------------------------------- ### Get Tool Source: https://smithery.ai/docs/concepts/registry_search_servers Gets one tool or lists tools under a slash-separated category. ```APIDOC ## GET /connect/{namespace}/{connectionId}/.tools/{toolName} ### Description Gets one tool or lists tools under a slash-separated category. ### Method GET ### Endpoint /connect/{namespace}/{connectionId}/.tools/{toolName} ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the connection. - **connectionId** (string) - Required - The ID of the connection. - **toolName** (string) - Required - The name of the tool or category. ### Request Body (No request body details provided in the source) ### Response #### Success Response (200) (No response details provided in the source) #### Response Example (No response example provided in the source) ``` -------------------------------- ### Advanced Smithery CLI Examples Source: https://smithery.ai/docs/llms-full.txt Demonstrates advanced usage of the Smithery CLI, including adding servers with configurations, JSON output, and publishing. ```bash # Add an MCP server to Claude Desktop smithery mcp add mcp-obsidian --client claude ``` ```bash # Add with pre-configured data (skips prompts) smithery mcp add mcp-obsidian --client claude --config '{"vaultPath":"path/to/vault"}' ``` ```bash # Remove a server from a client smithery mcp remove mcp-obsidian --client claude ``` ```bash # Search for MCP servers with JSON output smithery --json mcp search "database" ``` ```bash # List tools from a specific connection smithery tool list my-github ``` ```bash # Find tools by intent smithery tool find "create issue" ``` ```bash # Call a tool with JSON arguments smithery tool call my-github create_issue '{"title":"Bug fix","body":"..."}' ``` ```bash # Login and check auth smithery auth login smithery auth whoami ``` ```bash # Publish your MCP server smithery mcp publish "https://my-server.com" -n myorg/my-server ``` ```bash # Publish an MCPB bundle smithery mcp publish ./server.mcpb -n myorg/my-server ``` ```bash # Show help smithery --help ``` -------------------------------- ### Example Trigger Payload Source: https://smithery.ai/docs/use/triggers This is an example of a trigger payload that might be received. It contains an array of events. ```json { "events": [ { "id": "trigger-id-1", "name": "example.trigger.name", "description": "This is an example trigger.", "inputSchema": { "type": "object", "properties": { "message": { "type": "string" }, "count": { "type": "integer" } }, "required": [ "message" ] }, "outputSchema": { "type": "object", "properties": { "status": { "type": "string" }, "processed_count": { "type": "integer" } }, "required": [ "status" ] }, "tags": [ "example", "test" ] }, { "id": "trigger-id-2", "name": "another.trigger.name", "description": "Another example trigger.", "inputSchema": { "type": "object", "properties": { "data": { "type": "array", "items": { "type": "string" } } }, "required": [ "data" ] }, "outputSchema": { "type": "object", "properties": { "success": { "type": "boolean" } }, "required": [ "success" ] }, "tags": [ "example" ] } ] } ``` -------------------------------- ### Get Connection Source: https://smithery.ai/docs/concepts/registry_search_servers Gets details for a specific connection. Requires service token with connections:read scope. ```APIDOC ## GET /connect/{namespace}/{connectionId} ### Description Gets details for a specific connection. Requires service token with connections:read scope. ### Method GET ### Endpoint /connect/{namespace}/{connectionId} ### Parameters #### Path Parameters - **namespace** (string) - Required - The namespace of the connection. - **connectionId** (string) - Required - The ID of the connection. ### Request Body (No request body details provided in the source) ### Response #### Success Response (200) (No response details provided in the source) #### Response Example (No response example provided in the source) ``` -------------------------------- ### Call Tool Example Source: https://smithery.ai/docs/use/connect Demonstrates how to call a tool named 'search_repositories' with specific arguments using the MCP client. This snippet shows the structure for making tool calls. ```javascript _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " mcpClient" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "." }), _jsx(_components.span, { style: { color: "#8250DF", "--shiki-dark": "#DCDCAA" }, children: "callTool" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "({" }) , "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " name:" }), _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'search_repositories'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "," }) ] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " arguments:" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " { " }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: "query:" }), _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'mcp'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " }," }) ] }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "})" }) ) }) ``` -------------------------------- ### CLI Quick Start: Connect to Exa Search Source: https://smithery.ai/docs/use/connect This snippet shows the command-line steps to log in to Smithery and connect to the Exa search server using the CLI. ```shellscript # 1. Log in to Smithery smithery auth login # 2. Connect to the Exa search server smithery mcp add exa --id exa ``` -------------------------------- ### Example Deep Link Source: https://smithery.ai/docs/llms-full.txt An example illustrating the deep link format with a specific client scheme and handler. ```typescript // Example: // cursor://anysphere.cursor-deeplink/mcp/install?& ``` -------------------------------- ### Example Tool and Prompt Configuration Source: https://smithery.ai/docs/use/connect This snippet shows how to configure tools and prompts for use with Smithery AI. It demonstrates the structure for defining available tools and the user's message. ```javascript _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " tools:" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " allTools" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "," })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " prompt:" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: " userMessage" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "," })] }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "});" }) }), "\n"] }) ) ``` -------------------------------- ### Install AI SDK packages Source: https://smithery.ai/docs/llms-full.txt Installs necessary npm packages for using the AI SDK with MCP and Anthropic. ```bash npm install @smithery/api @ai-sdk/mcp ai @ai-sdk/anthropic ``` -------------------------------- ### Show Help Menu Source: https://smithery.ai/docs/concepts/cli Displays the main help menu for the Smithery CLI. ```bash smithery --help ``` -------------------------------- ### Client Initialization and Connection Source: https://smithery.ai/docs/use/deep-linking Demonstrates how to initialize a client and establish a connection using the provided transport. This is a common setup for interacting with services. ```typescript const client = new Client({ name: "Test client" }); await client.connect(transport) return client ``` -------------------------------- ### Example Trigger Payload Source: https://smithery.ai/docs/use/triggers This is an example of a trigger event payload that might be received. It contains an 'events' array with details about the trigger. ```json { "events": [ { "event": "example.trigger.name", "description": "This is an example trigger.", "input": { "type": "object", "properties": { "message": { "type": "string" }, "count": { "type": "integer" } }, "required": [ "message" ] }, "output": { "type": "object", "properties": { "status": { "type": "string" }, "processed_count": { "type": "integer" } }, "required": [ "status" ] } } ] } ``` -------------------------------- ### Http-based Configuration Example Source: https://smithery.ai/docs/use/deep-linking An example JSON configuration for an http-based server connection. Specifies the type and the URL of the MCP server. ```json { "type": "http", "url": "https://exa.run.tools" } ``` -------------------------------- ### Using MCP Client in JavaScript Source: https://smithery.ai/docs/use/connect Example of initializing and using the MCP client in JavaScript. This snippet demonstrates how to set up the client and close the connection. ```javascript tools, prompt: 'Search for the latest news about MCP.', }); await mcpClient.close(); ``` -------------------------------- ### Create a Single-Resource Token Source: https://smithery.ai/docs/use/token-scoping This example demonstrates how to create a token with a policy that grants access to a single resource ('connections') and a single operation ('execute'). ```shell smithery token create \ -H "Content-Type: application/json" \ -d '{ "policy": [ { "namespaces": "my-app", "resources": "connections", "operations": "execute", "metadata": { "userId": "user-123" }, "ttl": "30m" } ] }' ``` -------------------------------- ### Install MCP TypeScript SDK packages Source: https://smithery.ai/docs/llms-full.txt Installs the Smithery API and the Model Context Protocol (MCP) SDK client packages. ```bash npm install @smithery/api @modelcontextprotocol/sdk ``` -------------------------------- ### Install Vercel AI SDK Dependencies Source: https://smithery.ai/docs/llms-full.txt Install the necessary packages for Vercel AI SDK, MCP tools, Anthropic, and Smithery API. ```bash npm install ai @ai-sdk/mcp @ai-sdk/anthropic @smithery/api ``` -------------------------------- ### TypeScript Connection Setup Source: https://smithery.ai/docs/use/connect This TypeScript snippet demonstrates how to set up a Browserbase connection. It includes setting the namespace and MCP URL. ```typescript const conn = await smithery.connections.set( 'my-browserbase', { namespace: 'my-app', mcpUrl: 'https://mcp.browserbase.com/mcp' ``` -------------------------------- ### Initialize and Use MCP TypeScript SDK Source: https://smithery.ai/docs/use/connect A comprehensive example of initializing the MCP client and using it to generate text. This snippet covers setting up the client and making a request. ```typescript import { MCPClient } from "@modelcontextprotocol/sdk"; const mcpClient = new MCPClient({ // ... client configuration options }); async function main() { const response = await mcpClient.generateText({ model: "anthropic"( 'claude-sonnet-4-20250514' ), tools, prompt: 'Search for the latest news about MCP.', }); console.log(response); await mcpClient.close(); } main(); ``` -------------------------------- ### TypeScript Example for Token Scoping Source: https://smithery.ai/docs/use/token-scoping A TypeScript example demonstrating the structure for defining token scopes. This code illustrates how to programmatically construct the scope object. ```typescript const scope = { namespaces: "my-app", resources: "connections", operations: ["read", "execute"], metadata: { "userId": "user-123" }, ttl: "1h" }; ``` -------------------------------- ### Initialize Smithery Client Source: https://smithery.ai/docs/use/connect Instantiate the Smithery client. This is the first step before establishing any connections. ```javascript const smithery = new Smithery(); ``` -------------------------------- ### Creating MCP Clients for Connections (CLI) Source: https://smithery.ai/docs/use/connect This shell script example shows how to create MCP clients for each connection using the Smithery CLI. This is useful for managing multiple connections and their associated tools. ```shellscript smithery mcp --connection my-connection --connection another-connection ``` -------------------------------- ### Mint Token with OR Logic for Resources Source: https://smithery.ai/docs/use/token-scoping This example demonstrates minting a token that grants read access to 'alice's connections' OR read/write access to 'servers'. Metadata within a single object is AND’d, while a list of objects enables OR logic. ```shell curl -X POST https://api.smithery.ai/tokens \ -H "Authorization: Bearer $SMITHERY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "policy": [ { "resources": "connections", "operations": "read", "metadata": { "owner": "alice" } }, { "resources": "servers", "operations": ["read", "write"] } ] }' ``` -------------------------------- ### Example Deep Link Source: https://smithery.ai/docs/use/deep-linking An illustrative example of a deep link using the 'cursor' scheme, demonstrating the expected structure with a display name and encoded configuration. ```plaintext cursor://anysphere.cursor-deeplink/mcp/install?& ``` -------------------------------- ### Handling Authentication Required Source: https://smithery.ai/docs/use/connect When authentication is required, the CLI will output a setup URL. Visit this URL to authorize the connection, then retry the operation. ```text # If auth is required, the CLI outputs the setup URL: # → auth_required # → https://auth.smithery.ai/... # → connection_id: abc-123-github # Visit the URL to authorize, then retry ``` -------------------------------- ### Create Multi-Resource Token Source: https://smithery.ai/docs/use/token-scoping This example shows how to create a single token that grants access to multiple resources with different operations. This simplifies access management by consolidating permissions. ```bash smithery auth token --policy '[ { "namespaces": "my-app", "resources": "connections", "operations": ["read", "execute"], "metadata": { "userId": "user-123" }, "ttl": "1h" }, { "namespaces": "my-app", "resources": "servers", "operations": "read", "ttl": "1h" } ]' ``` -------------------------------- ### Get Connection Details with Smithery CLI Source: https://smithery.ai/docs/concepts/cli Use the 'smithery mcp get ' command to retrieve detailed information about a specific connection. Replace with the connection's ID. ```bash smithery mcp get # Get connection details ``` -------------------------------- ### Set Up a New Connection Source: https://smithery.ai/docs/use/connect Establish a connection to a specific Smithery namespace. Ensure the `mcpUrl` includes your `browserbaseProjectId`. ```javascript const conn = await smithery.connections.set( 'my-browserbase', { namespace: 'my-app', mcpUrl: 'https://mcp.browserbase.com/mcp?browserbaseProjectId=your-project-id', } ); ``` -------------------------------- ### Example Token Scope Definition Source: https://smithery.ai/docs/use/token-scoping Defines the scope for a token, specifying allowed resources and operations. This example shows a scope for 'servers' resource with 'read' and 'write' operations. ```json { "resources": { "servers": { "operations": ["read", "write"] } } } ``` -------------------------------- ### Execute-Only Agent Token CLI Example Source: https://smithery.ai/docs/use/token-scoping This example demonstrates how to create an agent token with execute-only permissions using the CLI. Ensure your SMITHERY_API_KEY environment variable is set. ```shellscript curl -X POST \ https://api.smithery.ai/tokens \ -H "Authorization: Bearer $SMITHERY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "policy": [ { "namespaces": "my-app", "resources": "connections", "operations": "execute", "ttl": "1h" } ] }' ``` -------------------------------- ### Example Tool Search Source: https://smithery.ai/docs/use/connect This snippet demonstrates how to use the search tool with a query. The SDK parses and validates structured data returned by tools. ```javascript const result = await exa.tools.search({ query: "latest news about MCP", }); ``` -------------------------------- ### Example Token with Scopes Source: https://smithery.ai/docs/use/token-scoping This example demonstrates a JSON Web Token (JWT) with defined scopes for resources and operations. It includes metadata like userId and a time-to-live (ttl). ```json { "policy": [ { "resources": "connections", "operations": "read", "metadata": {"userId": "user-123"}, "ttl": "20m" } ] } ``` -------------------------------- ### Create a Token with Specific Scopes Source: https://smithery.ai/docs/use/token-scoping This example demonstrates how to create a token with a policy that defines access to specific namespaces, resources, and operations. The policy includes metadata and a time-to-live (TTL). ```shell curl -X POST https://api.example.com/v1/tokens \ -H "Content-Type: application/json" \ -d '{ "policy": [ { "namespaces": "my-app", "resources": "connections", "operations": ["read", "execute"], "metadata": { "userId": "user-123", "tier": "pro" }, "ttl": "1h" } ] }' ``` -------------------------------- ### Browserbase MCP Connection Example Source: https://smithery.ai/docs/use/connect This snippet demonstrates how to establish an MCP connection to Browserbase, specifying the project ID, and providing API key headers. ```shell smithery mcp add '@browserbasehq/mcp-browserbase?browserbaseProjectId=your-project-id' \"\" --id my-browserbase --headers '{"browserbaseApiKey": "your-browserbase-api-key"}' ``` -------------------------------- ### Example Trigger Schema Source: https://smithery.ai/docs/use/triggers This is an example response showing the schema for an event trigger, including its name, description, delivery options, and input/payload schemas. Use this to understand event structure. ```json { "events": [ { "name": "page.updated", "description": "Fires when a page in the watched workspace is updated.", "delivery": ["webhook"], "inputSchema": { "type": "object", "properties": { "workspace_id": { "type": "string" } }, "required": ["workspace_id"] }, "payloadSchema": { "type": "object", "properties": { "page_id": { "type": "string" }, "updated_at": { "type": "string", "format": "date-time" } } } } ] } ``` -------------------------------- ### Direct Client Connection Example Source: https://smithery.ai/docs/use/deep-linking This snippet shows how to establish a direct connection to a client using a transport. It's useful for setting up real-time communication channels. ```typescript async function setupDirectClient(transport: string) { const client = await client.connect(transport) return client } ``` -------------------------------- ### Get Full Details for a Specific Tool Source: https://smithery.ai/docs/concepts/cli Retrieve comprehensive information about a particular tool using 'smithery tool get '. This command displays all available details for the specified tool. ```shellscript smithery tool get # Show full details for one tool ``` -------------------------------- ### JavaScript Connection Setup Source: https://smithery.ai/docs/use/connect Use this JavaScript snippet to set up a connection to Browserbase. It specifies the connection ID, namespace, and MCP URL. ```javascript _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " add" }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#D7BA7D" }, children: " \\\\"" })] }), "\\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'https://mcp.browserbase.com/mcp?browserbaseProjectId=your-project-id'" }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#D7BA7D" }, children: " \\\\"" })] }), "\\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0550AE", "--shiki-dark": "#569CD6" }, children: " --id" }), _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " my-browserbase" }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#D7BA7D" }, children: " \\\\"" })] }), "\\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0550AE", "--shiki-dark": "#569CD6" }, children: " --headers" }), _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " '{\\\"browserbaseApiKey\\\": \\\ ``` -------------------------------- ### Deep Link Example URL Source: https://smithery.ai/docs/use/deep-linking This is an example of a complete deep link URL for the 'mcp/install' path. It shows the expected format with placeholders for server display name and base64-encoded JSON configuration. ```text // cursor://anysphere.cursor-deeplink/mcp/install?& ``` -------------------------------- ### Initialize MCP Client Source: https://smithery.ai/docs/use/connect Instantiate the MCP client with a name and version. This is the first step to interacting with the MCP service. ```javascript const mcpClient = new Client({ name: 'my-app', version: '1.0.0' }); ``` -------------------------------- ### Install Next.js and MCP TypeScript SDK Source: https://smithery.ai/docs/llms-full.txt Installs the necessary dependencies for a new Next.js project and the MCP TypeScript SDK. Ensure you are in your project's root directory before running these commands. ```bash npx create-next-app@latest my-mcp-client cd my-mcp-client npm install @modelcontextprotocol/sdk ``` -------------------------------- ### Add Server with API Key and Project ID (Shell) Source: https://smithery.ai/docs/use/connect Use this command to add a new server connection. Configure API key as a header and project ID as a query parameter. ```shellscript # Add a server with config (API key as header, project ID as query param) smithery mcp add \"@browserbasehq/mcp-browserbase?browserbaseProjectId=your-project-id\" \" --id my-browserbase --headers '{\"browserbaseApiKey\": \"your-browserbase-api-key\"}' ``` -------------------------------- ### Create MCP client and generate text with AI SDK Source: https://smithery.ai/docs/llms-full.txt Demonstrates creating an MCP client and using the AI SDK to generate text, leveraging MCP tools. Ensure you have the necessary SDKs installed. ```typescript import { createMCPClient } from '@ai-sdk/mcp'; import { generateText } from 'ai'; import { anthropic } from '@ai-sdk/anthropic'; import { createConnection } from '@smithery/api/mcp'; const { transport } = await createConnection({ mcpUrl: 'https://mcp.exa.ai', }); const mcpClient = await createMCPClient({ transport }); const tools = await mcpClient.tools(); const { text } = await generateText({ model: anthropic('claude-sonnet-4-20250514'), tools, prompt: 'Search for the latest news about MCP.', }); await mcpClient.close(); ``` -------------------------------- ### TypeScript Example: Specifying Time-Based Scopes Source: https://smithery.ai/docs/use/token-scoping Demonstrates how to define time-based scopes for tokens, allowing for temporary access. This example shows how to specify a duration like '1h', '30m', or '20s', or a specific number of seconds. ```typescript // ttl: time-to-live { ttl: "1h" | "30m" | "20s" | number // e.g., \"1h\", \"30m\", \"20s\", 3600 } ```