Content

Securely Connecting the Claude API to Your Agent

Connecting Claude and connecting your other tools are two different logins. Here is where each one should live if you are setting this up for the first time.

EngineeringOct 16, 2026

Key takeaways

  • -In this article we explore securely connecting the Claude API to an agent, and why the Claude API key is a different secret from a Gmail, Stripe, or Asana login.
  • -To understand how a secure Claude API connection works: the program that calls Claude holds the Anthropic API key, and the chat transcript should not contain it.
  • -Other tool logins are stored with swy auth connect, outside the project, and the agent does not see them. Swytchcode does not keep those logins in a project env file.
  • -Securely connecting the Claude API does not allow every action on a connected tool. After swy get and swy discover, swy add method turns on one action at a time.
  • -Sandbox mode is chosen once with swy init --mode=sandbox and saved in .swytchcode/tooling.json. It is not an environment variable the agent can change in the chat.

You want your assistant to use Claude, and you want that assistant to do things in your other tools: read a board, send an email, check a payment. Both of those need a login. They are not the same login, and putting them in the same file is how a chat ends up holding a key that can move money.

This article splits the two, in the order you will actually set them up. You do not need to know Swytchcode yet. Swytchcode is the program that makes the call to those other tools. It is not the thing that talks to Claude. Claude has its own key, from Anthropic.

Two logins, two jobs

Claude's key, sometimes called the Anthropic API key, lets your program send prompts to Claude and pay for that usage. Anyone who has it can spend that account. It does not, on its own, charge a card in Stripe or send a Brevo email.

A tool login is the key or the sign-in for that other service. Stripe, a bank, Asana, Brevo. Anyone who has it can do what that service allows. It does not call Claude.

If both sit in one file the assistant can open, a message that says "show me the keys" gets both. Keep them apart, so losing one is not the same as losing the other.

Where Claude's key should sit

The program that calls Claude needs the key. Anthropic's libraries look for it in that program's environment, which is the settings of the process, not a note inside the conversation. That is Anthropic's own pattern. Swytchcode does not store this key, and it does not read a project env file for its own logins.

Do not paste Claude's key into the instructions. Do not commit it to the repository. Do not hand it to a tool "so the assistant can refresh itself." The assistant does not need to see the key. The program around it already has the key. The chat transcript should not.

In an editor, use the editor's secret storage, or the environment of the editor process. A file in the project with a tempting name is the wrong place, because the assistant can open project files.

Where the other logins should sit

Tool logins go through swy auth connect, followed by the service name. They are stored on your machine, outside the project folder, not in the chat and not in the repository. When a call runs, Swytchcode adds the login after it has checked your rules. The assistant supplies what it wants done, not the secret.

Follow these steps for each other tool. Replace <provider> with the service name, such as stripe or asana. Do not put Claude's key in any of these steps.

1. Follow this step to install the CLI

Pick the one that matches your computer.

If you already use Node.js:

npm install -g swytchcode

On Windows, open PowerShell and run:

irm https://cli.swytchcode.com/install.ps1 | iex

On macOS or Linux:

curl -fsSL https://cli.swytchcode.com/install.sh | sh

Then check that the install worked:

swy --version

A version number means the CLI is on your machine. The rest of the install walkthrough is in the CLI quickstart.

2. Follow this step to sign in

swy login

A browser window opens so you can create a Swytchcode account or sign in. This is not where Claude's key goes. Your first two calls that actually reach a service can run before you have an account. After those, you need to be signed in. How accounts and service logins work is in the authentication docs.

3. Follow this step to start a test project

Use the line for the editor you already have.

swy init --editor=claude --mode=sandbox

If you use Cursor, change claude to cursor. If you use Codex, change it to codex. --mode=sandbox means test mode. That choice is saved in the project file tooling.json. It is not an environment variable, and the assistant does not pick it in the chat. What this command creates is in Set up a project.

4. Follow this step to download the service

swy get <provider>

This downloads that service. It does not turn every action on, and it does not store Claude's key.

5. Follow this step to find the action you want

swy discover "<what you want done>" --project <provider>

This searches that service, in plain English, and prints the current name of the action. Use the name it prints, because names change. Do not copy a name from an old note, including this article. --project keeps the search inside that service.

6. Follow this step to see what that action needs

swy info <id from discover>

Replace <id from discover> with the name from step 5. This shows the fields. It only works after step 4.

7. Follow this step to turn that one action on

swy add method <id from discover>

Until you add an action, the assistant cannot run it.

8. Follow this step to connect that service

swy auth connect <provider>

This is the sign-in for Stripe, Asana, Brevo, or whichever service you named. The login stays on your machine. The assistant can be shown a form that includes a field called "token." That field is still not a place to paste the real secret. Swytchcode fills the login in. Explore this article for the longer explanation: credential brokering. A wider checklist for the assistant, not only the keys, is the AI assistant security checklist.

Connected does not mean allowed to do everything

Turning on a service is not the same as turning on every action it offers. If you connect Stripe and then allow payouts, refunds, and deleting customers, you have a tidy login and a very wide assistant.

Turn on the actions the task needs. A second file, the policy, can allow a call, refuse it, or pause it for a person, and it can look at the details, such as the amount. The pause, sent to Slack or Telegram, is on Business and Enterprise. If nobody approves within 48 hours, the call never runs. Free and Pro can allow or refuse, without that pause. How to write the rule is Policy-as-Code for AI Agents.

Test mode and live mode are chosen once, in step 3, and saved in a file called tooling.json. The assistant does not pick this in the chat, and you do not swap it by editing an environment variable in the prompt.

If a call might have worked and the assistant tries again from scratch, you can get two charges or two emails. Swytchcode retries that kind of call only when it carries the same reference as the first try. The friendly version of that idea is Idempotency Explained.

One worked example, for Stripe inside Claude Code, is How to Connect Stripe to Claude Code. Connecting the editor itself is How to Connect the Swytchcode MCP Server.

FAQ

How do I connect Claude to my assistant?

Give Claude's key to the program that calls Claude, outside the chat and outside the repository. Connect each other service with the steps in this article. Do not put those secrets in the same file as Claude's key if the assistant can open that file.

Should the assistant pass my Claude key into tools?

No. The tools do not need it. The program that talks to Claude already has it. If a tool's form asks for Claude's key, leave that field alone.

If the assistant can call Stripe, can it print my Stripe key?

Not from Swytchcode. The login is added at the moment of the call. It is not in the conversation, so a message that asks for the key has nothing to copy. The assistant can still run the actions you turned on, so keep that list short.

Is Claude's key enough to keep the other calls safe?

No. Claude's key only proves who is talking to Anthropic. Safety on the other side is which actions you turned on, the rules around them, the login staying out of the chat, and not repeating a payment or an email as if it were new.

A simple way to begin

If you have not installed the CLI yet, start at step 1 in this article. Claude's key stays with the program that calls Claude. Every other login goes through step 8.

You can also give Claude Code, Cursor, or Codex skills.md and ask it to follow those steps in test mode, for the editor you are using.

If you are not sure whether a file is visible to the assistant, or a tool is asking you to paste a token, stop and ask before you paste it. Discord is an easy place to ask. The contact form is there if you do not want the details in a public channel. Describe what you were connecting and what the screen asked for. That is enough.

More content