Blog

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.

Different ways to use swytchcode
Chaitrali Kakde

DevRel Engineer

Aug 21, 2026

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:

  1. Install the CLI
npm install -g swytchcode

swy works as a shorter alias for swytchcode.

  1. Initialize a project
swy init

This creates a .swytchcode/ folder and a tooling.json file, which tracks the integrations and tools your project trusts. It starts empty.

  1. Find and download an integration
swy search github
   swy get github

swy 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.

  1. Enable a tool
swy add github.issues.create

This resolves a method from the downloaded bundle and adds it to tooling.json, which determines what your project is allowed to execute.

  1. Connect an account
swy auth connect github

This opens a browser window to authorize the connection. You can check the status with swy auth status.

  1. 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:

  1. swy list tooling (see what's enabled),
  2. swy info <canonical_id> (view a tool's schema),
  3. swy discover "<intent>" (find a tool by describing it in plain English),
  4. 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:

  1. Install the CLI
npm install -g swytchcode
  1. Initialize your project
swy init
  1. 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 -d

Some editors can be configured automatically. For Cursor, for example:

swy init --editor=cursor

This 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"]
       }
     }
   }
  1. 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):

  1. Install the CLI and SDK
npm install -g swytchcode
   npm install @swytchcode/runtime @anthropic-ai/sdk
  1. Initialize the project and enable a tool
swy init
   swy get github
   swy add method github.user.starred.update
   swy auth connect github
  1. 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}`;
  1. 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.
  2. Run the file
node main.js

The 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

ApproachRequires CodeBest For
CLINORunning and managing tools directly from the terminal
MCPNOTerminal AI agents and IDE-based coding assistants
Native SDK'sYESCustom 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

Ready to build?

Install the CLI and connect your first API in minutes. Free tier included, no credit card required.

More from the blog