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.

OpenClaw gives you a personal AI assistant you can chat with from apps like Telegram, Slack, Discord, and WhatsApp. Swytchcode gives that assistant a safe way to actually act on real APIs, with authentication, retries, and policy checks built in. Connect the two, and your OpenClaw agent stops being just a chatbot and starts being able to look things up and take real actions in the tools you already use, without you handing it your raw API keys.
This guide covers what OpenClaw is, why pairing it with Swytchcode is useful, how to connect the two, and a real example project that shows the pattern in action.
What Is OpenClaw?
OpenClaw is a free, open-source, self-hosted personal AI assistant. It runs on your own machine or server and acts as a gateway between messaging apps you already use, such as Telegram, Slack, Discord, WhatsApp, and iMessage, and an underlying AI model like Claude or GPT. Instead of opening a separate chatbot window, you message your assistant the same way you message a friend.
OpenClaw extends what the assistant can do through a skills system: small instruction packs that teach the agent how to carry out a specific kind of task. This is the same layer where a Swytchcode connection fits in, giving the agent verified tools to call instead of just instructions to follow.
Why Connect Swytchcode to OpenClaw?
OpenClaw handles the conversation. Swytchcode handles what happens when that conversation needs to touch a real system. Together they cover both sides of building a useful agent:
- A chat interface people already use. No separate app or dashboard. Requests and replies happen in Telegram, Slack, or whichever channel you've connected.
- Safe execution underneath. Every action Swytchcode carries out on the agent's behalf goes through authentication, input validation, retries, and your project's policies before it touches a real API.
- An audit trail. Every tool call is logged, so you can see exactly what your agent did and when.
- No raw credentials in the chat. OpenClaw never needs to hold your API keys directly. Swytchcode manages the credentials and only exposes approved tools.
How to Connect Swytchcode to OpenClaw
Step 1: Install the Swytchcode CLI
npm install -g swytchcodeswy works as a shorter alias for swytchcode in every command below.
Step 2: Initialize Swytchcode for OpenClaw
From your project folder, run:
cd /path/to/your/project
swy init --editor=openclaw --mode=sandboxThis sets up three things at once:
.swytchcode/withtooling.json: the trust boundary listing exactly which tools OpenClaw is allowed to callOPENCLAW.mdin your repo root: the agent contract file describing the available tools and conventions for OpenClaw to follow~/.openclaw/settings.json: the MCP server configuration OpenClaw needs to reach Swytchcode
Step 3: Fetch an Integration
Search for an available integration, or browse the full list at swytchcode.com/apis:
swy searchThen fetch one. For example, to work with Stripe:
swy get stripeStep 4: Add Tools to the Trust Boundary
Add a specific method:
swy add stripe.charge.createOr add every tool from an integration at once:
swy add method --all stripeConfirm what's enabled:
swy list toolingStep 5: Start the MCP Server
The server starts automatically once OpenClaw connects through the configuration written in Step 2. To start it manually instead:
swy mcp serveStep 6: Use OpenClaw
Open your project in OpenClaw. The agent now has access to your enabled Swytchcode tools. You can give it a plain-language prompt, for example:
Create a Stripe charge for $50 for customer cus_123.Behind the scenes,
- OpenClaw checks
swy list toolingto confirm the tool exists, - calls
swy info stripe.charge.createto inspect its schema, - and generates the runtime code using
swy execto actually make the call.
Setting up a different editor instead of OpenClaw? See our full guide on connecting Swytchcode to MCP for Cursor, Claude Code, Windsurf, and every other supported client.
Example: A Multi-API Onboarding Agent Built with OpenClaw and Swytchcode
Swytchcode's official examples repository includes a hands-on demo built for this integration: an OpenClaw agent that chains three separate services, a CRM, a billing platform, and an email service, into one deterministic run, entirely through Swytchcode's sandboxed execution layer.
What it does:
- Creates a contact in HubSpot
- Creates a customer in Stripe
- Charges that customer's card
- Sends a welcome email through Resend
All four steps run through OpenClaw talking to Swytchcode over MCP, with no custom integration code written for any of the three services.
Where to find it: swytchcode-refund-agent-openclaw on GitHub
What it demonstrates:
- Multi-API orchestration: authenticates and executes across HubSpot, Stripe, and Resend without custom integration code
- Idempotency: safely retries sensitive operations, like a card charge or an email send, without duplicating the side effect
- Local policy enforcement: blocks unauthorized outbound requests locally, before they ever leave your machine
- Audit trails: every AI tool execution is logged centrally
Try It Yourself
Prerequisites: Node.js v18 or later, and the Swytchcode CLI installed globally (npm install -g swytchcode).
Clone the repo and set up your environment file:
git clone https://github.com/swytchcodehq/swytchcode-examples.git
cd swytchcode-examples/swytchcode-refund-agent-openclaw
cp .env.example .envFill in .env with test credentials:
- Stripe test-mode secret key,
- HubSpot private app token,
- Resend API key,
- and your own email address (Resend's free tier only delivers test emails to a verified address).
Run the full workflow:
node run-workflow.jsThis creates the HubSpot contact, creates the Stripe customer, charges $20, and sends the welcome email, all in one run. You can check the HubSpot and Stripe dashboards, and your inbox, to see each result.
Test idempotency:
node demo-idempotency.jsRun it twice in a row. Both runs return a successful response, but only one welcome email actually arrives, since Swytchcode's idempotency key stops the second run from repeating the side effect.
Test local policy enforcement:
Open .swytchcode/tooling.json, remove "api.hubapi.com" from the permissions.network array, and run the workflow again. The request to HubSpot gets blocked locally with a permission_denied error before it reaches the network at all. Add the entry back when you're done testing.
If you want a second reference point, the same examples repository also includes a GitHub Issue Triage Bot built the same way: OpenClaw classifies and triages incoming GitHub issues, posts templated comments, and logs every action through Swytchcode.
Frequently Asked Questions
- What is OpenClaw? OpenClaw is a free, open-source, self-hosted personal AI assistant that connects messaging apps like Telegram, Slack, Discord, and WhatsApp to an AI model, so you can chat with your assistant from apps you already use.
- Can I use Swytchcode with OpenClaw? Yes. Running
swy init --editor=openclaw --mode=sandboxsets up the project's trust boundary, theOPENCLAW.mdcontract file, and the MCP server configuration OpenClaw needs, all in one step. - What is OPENCLAW.md? It's the agent contract file that Swytchcode generates in your project root when you initialize for OpenClaw. It describes the available tools and the conventions OpenClaw should follow when calling them.
- Do I need to write code to connect Swytchcode to OpenClaw? No. Connecting them only takes CLI commands: install, initialize with the OpenClaw flag, fetch an integration, enable the tools you want, and start the server. Writing code is only needed if you're building a custom agent, like the example project covered above.
- What does the OpenClaw example project actually do? Despite its folder name, it demonstrates a multi-API customer onboarding workflow: creating a HubSpot contact, creating and charging a Stripe customer, and sending a Resend welcome email, all through Swytchcode.
- Do I need real API keys to run the example? Yes, test-mode keys for Stripe, HubSpot, and Resend, plus your own email address for Resend's free-tier delivery requirement. Copy
.env.exampleto.envand fill them in before running the scripts. - Which other AI editors can I connect to Swytchcode besides OpenClaw? Cursor, Claude Code, Windsurf, GitHub Copilot, Gemini CLI, Codex, and Hermes are all supported through the same MCP server.
Where to Go Next
- OpenClaw Quickstart: the official Swytchcode documentation for this integration
- tooling.json Reference: how the trust boundary file works
- MCP Server Reference: full server configuration, transport options, and tool profiles
- Cookbook: more real-world agent examples built on Swytchcode
- swytchcode-examples repository: every official example project, including the onboarding automation demo covered above
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 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.
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.
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.
