Use this file to discover all available pages before exploring further.
Smithery gives you a simple REST interface for connecting to MCP servers. Instead of implementing the MCP protocol directly, handling OAuth flows, and managing credentials yourself, Smithery handles all of it for you.The auth and credential layer is powered by the open-source agent.pw.
# 1. Log in to Smitherysmithery auth login# 2. Connect to the Exa search serversmithery mcp add exa --id exa# 3. List available toolssmithery tool list exa# 4. Call a toolsmithery tool call exa search '{"query": "latest news about MCP"}'
npm install @smithery/api @ai-sdk/mcp ai @ai-sdk/anthropic
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();
Some MCP servers require configuration like API keys or project IDs. How you pass each config value depends on the server’s schema — some values go as headers (typically API keys), while others go as query parameters in the MCP URL.Check the server’s page on smithery.ai to see what configuration it requires and where each value should go.
CLI
TypeScript
cURL
# 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"}'
import Smithery from '@smithery/api';import { createConnection } from '@smithery/api/mcp';const smithery = new Smithery();// 1. Create a connection with the server's config// - API keys go in `headers`// - Other config goes as query params in `mcpUrl`const conn = await smithery.connections.set('my-browserbase', { namespace: 'my-app', mcpUrl: 'https://mcp.browserbase.com/mcp?browserbaseProjectId=your-project-id', headers: { 'browserbaseApiKey': 'your-browserbase-api-key', },});// conn.status.state === "connected" — ready to use immediately// 2. Get a transport for the connectionconst { transport } = await createConnection({ client: smithery, namespace: 'my-app', connectionId: conn.connectionId,});
Unlike OAuth-based servers that return auth_required, servers configured with API keys return connected immediately when all required fields are provided upfront. If any required fields are missing, the connection returns input_required with the config schema and missing fields — see Handling Configuration below.
Each server’s config schema specifies whether a field is passed as a header or query parameter via the x-from metadata. See Session Configuration for details on how servers declare their config transport.
When your agent serves multiple users, you’ll need to track which connections belong to which user. Use the metadata field to associate connections with your users, then filter by metadata to retrieve a specific user’s connections.
When your agent needs to know what tools are available for a user, list their connections:
CLI
TypeScript
smithery mcp list --metadata '{"userId": "user-123"}'
const result = await smithery.connections.list('my-app', { metadata: { userId: 'user-123' }});// Show the user their connected integrationsfor (const conn of result.connections) { console.log(`${conn.name}: ${conn.status.state}`);}
Create MCP clients for each connection and aggregate their tools:
CLI
TypeScript
# List tools for a connectionsmithery tool list user-123-github# Call a toolsmithery tool call user-123-github search_repositories \ '{"query": "mcp"}'
const allTools = [];for (const conn of result.connections) { if (conn.status.state === 'connected') { const { transport } = await createConnection({ namespace: 'my-app', connectionId: conn.connectionId, }); const client = await createMCPClient({ transport }); allTools.push(...await client.tools()); }}// Now your agent has tools from all the user's connected integrationsconst { text } = await generateText({ model: anthropic('claude-sonnet-4-20250514'), tools: allTools, prompt: userMessage,});
Or skip the iteration entirely and hand a single namespace URL to an MCP client.
A namespace URL bundles all of a namespace’s connections behind one MCP endpoint, so the same set of tools is portable across clients (Claude.ai, Cursor, ChatGPT, MCP Inspector) without configuring each connection in each app:
https://mcp.smithery.run/{namespace}
Tool names come back prefixed with their connection ID — notion-personal.search, user-123-github.search_repositories — so they stay unique. On tools/call, Connect strips the prefix and forwards to the matching connection.To restrict the URL to one user’s connections, mint a service token scoped to metadata.userId — same metadata model as Multi-User Setup. The endpoint also advertises protected-resource metadata, so MCP clients run the OAuth flow on their own without extra wiring.
A namespace is a globally unique identifier that groups your connections. Create one namespace per application or environment (e.g., my-app, my-app-staging). If you don’t specify a namespace, the SDK uses your first existing namespace or creates one automatically.
A connection is a long-lived session to an MCP server that persists until terminated. Each connection:
Has a connectionId (developer-defined or auto-generated)
Stores credentials securely (write-only—credentials can never be read back, only used to execute requests)
Can include custom metadata for filtering (e.g., userId to associate connections with your users)
Returns serverInfo with the MCP server’s name and version
createConnection Options
Option
Type
Description
client
Smithery?
The Smithery client instance. If not provided, auto-created using SMITHERY_API_KEY env var
mcpUrl
string?
The MCP server URL. Required when connectionId is not provided
namespace
string?
If omitted, uses first existing namespace or creates one
connectionId
string?
If omitted, an ID is auto-generated
Returns a SmitheryConnection with { transport, connectionId, url }.
Throws SmitheryAuthorizationError if OAuth authorization is required (see Handling Authorization).
Create a connection—the response status will be auth_required with a hosted setupUrl
Redirect the user to setupUrl
User completes OAuth with the upstream provider (e.g., GitHub)
User is redirected back to your app
The connection is now ready—subsequent requests will succeed
You don’t need to register OAuth apps, configure redirect URIs, or handle token exchange. Smithery manages the OAuth relationship with upstream providers and stores credentials securely on your behalf.
When you need to send a user through OAuth, prefer creating or updating the connection first and redirecting to the hosted setupUrl. That gives you a stable connectionId to retry with after the user returns to your app.
CLI
TypeScript
# Connect to a server that requires OAuthsmithery mcp add github# 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
const conn = await smithery.connections.set('abc-123-github', { namespace: 'my-app', mcpUrl: 'https://github.run.tools',});if (conn.status?.state === 'auth_required') { redirect(conn.status.setupUrl);}// Save conn.connectionId and retry with it after the user returns
After the user completes authorization and returns to your app, retry with the saved connectionId:
CLI
TypeScript
# After authorization, the connection is readysmithery tool list abc-123-github
const { transport } = await createConnection({ connectionId: savedConnectionId,});const mcpClient = await createMCPClient({ transport });const tools = await mcpClient.tools();
const conn = await smithery.connections.set('my-browserbase', { namespace: 'my-app', mcpUrl: 'https://mcp.browserbase.com/mcp',});if (conn.status.state === 'input_required') { // Option 1: redirect(conn.status.setupUrl) // Option 2: render your own form from conn.status.http // conn.status.http has the config schema, conn.status.missing lists unfilled fields const updated = await smithery.connections.set('my-browserbase', { namespace: 'my-app', mcpUrl: 'https://mcp.browserbase.com/mcp?browserbaseProjectId=your-project-id', headers: { browserbaseApiKey: 'your-api-key' }, });}
# Create — returns input_required if config is missingcurl -X PUT "https://smithery.run/my-app/my-browserbase" \ -H "Authorization: Bearer $SMITHERY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"mcpUrl": "https://mcp.browserbase.com/mcp"}'# Update with required config (same endpoint, PUT is an upsert)curl -X PUT "https://smithery.run/my-app/my-browserbase" \ -H "Authorization: Bearer $SMITHERY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mcpUrl": "https://mcp.browserbase.com/mcp?browserbaseProjectId=your-project-id", "headers": { "browserbaseApiKey": "your-api-key" } }'
MCP requests to a connection in input_required state will be rejected until the required configuration is provided. While input_required, the mcpUrl can be updated with query parameters as long as the host and path remain the same.
Service tokens let you safely use Smithery from browsers, mobile apps, and AI agents without exposing your API key. Your backend mints a scoped token, then your client uses it to call tools directly.
Many MCP servers organize tools by category using dotted names (e.g. repo.search, repo.create, issue.create). Smithery surfaces these as slash-separated URL segments so you can browse them like folders:
# List every tool on the connectionGET /my-app/user-123-github/.tools# Category listing — returns all tools whose upstream name starts with "repo."GET /my-app/user-123-github/.tools/repo# Specific tool — corresponds to upstream MCP name "repo.search"GET /my-app/user-123-github/.tools/repo/search# Invoke the same toolPOST /my-app/user-123-github/.tools/repo/search
The server reverses the slashes back to dots before calling the upstream MCP server, so POST /.tools/repo/search becomes a tools/call with name: "repo.search". A trailing slash is ignored — /.tools/repo/ and /.tools/repo both return the same category listing.
Flat tool names (no dots) work without any special handling — /.tools/my_tool resolves to the tool named my_tool in one segment. The hierarchy only activates when a server publishes dotted names.