Different Ways to Use Swytchcode: CLI, MCP, and SDK Guide
Swytchcode can be used through the CLI, MCP, or native SDKs. This guide breaks down each method with setup steps, code examples, and guidance on which one fits your workflow.

Swytchcode is an execution layer that sits between AI agents and the APIs they need to call. Instead of every project rebuilding its own logic for authentication, retries, policy control, and logging, Swytchcode provides one runtime that handles all of it. The platform is self-hosted, meaning it runs inside your own environment and you stay in control of where actions execute and how credentials are stored.
There is no single way to use Swytchcode. Depending on how you build with AI agents, you can connect to it through the CLI, through MCP, or through native SDKs. This guide walks through each option, what it is for, and how to get started with it.
What Swytchcode Handles for You
Before looking at the different ways to use it, it helps to know what Swytchcode is actually doing behind the scenes:
- Secure access: OAuth 2.0, API keys, bearer tokens, and credential management, including managed authentication .
- Reliable execution: automatic retries, idempotency, timeout handling, and request/response validation.
- Governance: policy enforcement, rate limits, usage limits, and control over which tools an agent is allowed to run.
- Observability: audit trails, execution history, and logs for every request.
Every request, no matter which method you use to reach Swytchcode, goes through this same execution pipeline. That means a tool call made from a terminal AI agent behaves identically to one made from a custom application.
At the core of all three methods below is the Swytchcode CLI. It is the foundation everything else is built on.
The Three Ways to Use Swytchcode
1. Swytchcode CLI
The CLI is the primary runtime. It manages your project, downloads integrations, tracks which tools are trusted, handles authentication, and executes API calls directly from the terminal. This is the most direct way to use Swytchcode and does not require writing any application code.
Getting started:
- Install the CLI
npm install -g swytchcodeswy works as a shorter alias for swytchcode.
- Initialize a project
swy initThis creates a .swytchcode/ folder and a tooling.json file, which tracks the integrations and tools your project trusts. It starts empty.
- Find and download an integration
swy search github
swy get githubswy search looks up integrations in the remote registry. swy get github downloads the integration bundle to disk. The full list of supported APIs is available at swytchcode.com/apis.
- Enable a tool
swy add github.issues.createThis resolves a method from the downloaded bundle and adds it to tooling.json, which determines what your project is allowed to execute.
- Connect an account
swy auth connect githubThis opens a browser window to authorize the connection. You can check the status with swy auth status.
- Execute the tool
swy exec github.issues.create --repo my-org/my-repo --title "Login page bug"Swytchcode validates the inputs against the tool's schema before making the request and returning a structured response.
A few other commands worth knowing:
swy list tooling(see what's enabled),swy info <canonical_id>(view a tool's schema),swy discover "<intent>"(find a tool by describing it in plain English),- and
swy doctor(diagnose your project setup).
The full list is in the CLI Reference.
Best for: developers who want to manage integrations and run API calls directly from the terminal, without connecting an editor or writing application code.
2. MCP (Model Context Protocol)
MCP is built directly into the CLI, so no separate installation is required. It exposes your trusted tools to AI coding assistants and agentic editors, letting them discover and execute Swytchcode tools as part of a conversation.
Swytchcode's MCP server works with:
Getting started:
- Install the CLI
npm install -g swytchcode- Initialize your project
swy init- Configure the MCP server
# Standard I/O (recommended for desktop editors)
swy mcp serve
# HTTP transport (remote or shared server)
swy mcp serve --transport http --port 5476
# Daemon (background) mode
swy mcp serve --transport http --port 5476 -dSome editors can be configured automatically. For Cursor, for example:
swy init --editor=cursorThis updates ~/.cursor/mcp.json to point at the Swytchcode MCP server. A manual configuration looks like this:
json
{
"mcpServers": {
"swytchcode": {
"command": "swy",
"args": ["mcp", "serve"]
}
}
}- Try it out Ask your editor or agent something like:
Connect GitHub and show me the tools available from the Swytchcode MCP server.Best for: developers already working inside a terminal AI agent or IDE-based coding assistant who want that agent to discover and run trusted tools without leaving the editor. For the complete set of server options, see the MCP Reference.
3. Native SDKs (Runtime SDKs)
For teams building custom AI applications, Swytchcode provides runtime SDKs for JavaScript/TypeScript and Python. These integrate directly with popular agent frameworks so that tool calling stays native to the framework, while Swytchcode handles execution, authentication, and policy checks in the background.
Supported frameworks currently include:
Getting started (using the Anthropic SDK as an example):
- Install the CLI and SDK
npm install -g swytchcode
npm install @swytchcode/runtime @anthropic-ai/sdk- Initialize the project and enable a tool
swy init
swy get github
swy add method github.user.starred.update
swy auth connect github- Initialize the provider in code
javascript
import Anthropic from "@anthropic-ai/sdk";
import { Swytchcode, TOOL_USE_INSTRUCTIONS } from "@swytchcode/runtime";
import { AnthropicProvider } from "@swytchcode/runtime/providers/anthropic";
const anthropic = new Anthropic();
const swx = new Swytchcode(new AnthropicProvider());
const tools = await swx.tools.get({ toolkits: ["github"] });
const system = `You are a helpful assistant.\n\n${TOOL_USE_INSTRUCTIONS}`;- Run the tool-use loop The application sends the user's message to the model along with the fetched tools. When the model requests a tool call,
swx.handleToolCalls(response)executes it through Swytchcode and returns the result, which is passed back to the model until it produces a final reply. - Run the file
node main.jsThe same pattern applies to OpenAI Agents SDK, Vercel AI SDK, LangGraph, and CrewAI: install the matching provider package, fetch tools with swx.tools.get(), and pass them into the framework's native tool-calling interface.
Best for: teams building production AI applications that need tool execution embedded directly in their own codebase, rather than run through a terminal or editor.
Choosing the Right Approach
| Approach | Requires Code | Best For |
|---|---|---|
| CLI | NO | Running and managing tools directly from the terminal |
| MCP | NO | Terminal AI agents and IDE-based coding assistants |
| Native SDK's | YES | Custom AI applications built on a specific agent framework |
All three methods run through the same execution pipeline underneath, so the behavior of a tool call (validation, retries, policy checks, logging) is consistent no matter which one you choose. Many teams start with the CLI or MCP to explore what an integration offers, then move to the runtime SDKs once they're building a production application.
Where to Go Next
- Quickstarts: step-by-step setup for each method
- CLI Reference: every command, flag, and exit code
- MCP Reference: complete MCP server configuration and options
- Cookbook: real-world agent workflows and integration patterns
- Runtime SDKs: full JavaScript and Python SDK documentation
- Authentication: how Swytchcode connects and manages provider credentials
- Policies & Approvals: setting rules for what tools an agent can execute
Ready to build?
Install the CLI and connect your first API in minutes. Free tier included, no credit card required.
More from the blog
How to Connect Swytchcode to OpenClaw: Setup Guide
Learn how to connect Swytchcode to OpenClaw so your AI assistant can safely call real APIs, plus a real working multi-API onboarding demo built with HubSpot, Stripe, and Resend.
How to Connect Swytchcode MCP Server: Setup Guide for Cursor, Claude Code, Windsurf & More
Learn how to connect the Swytchcode MCP server to Cursor, Claude Code, Windsurf, Copilot, and other AI editors, with exact setup commands, verification steps, and fixes for common connection issues.
Why Your AI Agent Breaks in Production: 7 Silent Failures Nobody Warns You About
AI agents can look flawless in testing but fail in production. From API errors and rate limits to authentication, schema validation, retries, and duplicate requests, here are 7 silent failures that can break your AI agent.
