Why Smithery?
Smithery lets you add MCP server integrations to your app without managing the complexity yourself:- Zero OAuth configuration — No redirect URIs, client IDs, or secrets to configure. Smithery maintains OAuth apps for popular integrations.
- Automatic token refresh — Tokens refresh automatically before expiry. If a refresh fails, the connection status changes to
auth_required. - Secure credential storage — Credentials are encrypted and write-only. They can be used to make requests but never read back.
- Stateless for you — Smithery manages connection lifecycle. Make requests without worrying about reconnects, keepalives, or session state.
- Scoped service tokens — Mint short-lived tokens for browser or mobile clients to call tools directly, scoped to specific users and namespaces.
Quick Start
- CLI
- AI SDK
- MCP TypeScript SDK
- Typed SDK
Servers with Configuration
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
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.Multi-User Setup
When your agent serves multiple users, you’ll need to track which connections belong to which user. Use themetadata field to associate connections with your users, then filter by metadata to retrieve a specific user’s connections.
1. Create a Connection for a User
When a user wants to connect an integration (e.g., GitHub), create a connection with theiruserId in metadata:
- CLI
- TypeScript
2. List a User’s Connections
When your agent needs to know what tools are available for a user, list their connections:- CLI
- TypeScript
3. Use Tools Across Connections
Create MCP clients for each connection and aggregate their tools:- CLI
- TypeScript
Namespace MCP Endpoint
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: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.
Core Concepts
Namespaces
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.
Connections
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
metadatafor filtering (e.g.,userIdto associate connections with your users) - Returns
serverInfowith the MCP server’s name and version
createConnection Options
createConnection Options
Returns a SmitheryConnection object (transport, connectionId, url).
Throws
SmitheryAuthorizationError if OAuth authorization is required (see Handling Authorization).Connection Status
When you create or retrieve a connection, it includes astatus field:
Authentication
Smithery uses two authentication methods:
Get your API key from smithery.ai/account/api-keys.
OAuth Flow
When an MCP server requires OAuth:- Create a connection—the response status will be
auth_requiredwith a hostedsetupUrl - 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
Handling Authorization
When you need to send a user through OAuth, prefer creating or updating the connection first and redirecting to the hostedsetupUrl. That gives you a stable connectionId to retry with after the user returns to your app.
- CLI
- TypeScript
connectionId:
- CLI
- TypeScript
Handling Configuration (input_required)
When a server requires configuration that wasn’t provided, the connection returns input_required with:
setupUrl— a hosted Smithery setup page you can redirect the user to instead of building your own formhttp— the config schema (headers and query parameters the server accepts)missing— which fields still need to be provided
- CLI
- TypeScript
- cURL
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
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.- CLI
- TypeScript
- cURL
my-app where metadata.userId matches user-123. Initialize the client with the token:
- CLI
- TypeScript
Need workspace-level scoping, read-only tokens, or token narrowing? See Token Scoping for the full guide.
Advanced
For full API documentation, see the API Reference section in the sidebar.Calling tools
Use the CLI or an MCP client over your connection’s transport:- CLI
- TypeScript