Speaking twice at Dreamforce · Sept 15-17 →

Frameworks and protocols

US · Global

Which Salesforce orgs can your coding agent reach? Give it a scratch org, not a login

By Shivanath DevinarayananPublished 11 min read
Written forCIO, CISO, or compliance lead who approves agents on real systems“Who acted, and can we stop it?”

The short answer

Which Salesforce orgs can a coding agent reach, and should it be allowed to create its own scratch org?

Only the orgs you list in the Salesforce DX MCP Server's --orgs flag, and a Dev Hub in that list is often your production org. At Mindcat, we have a person create the scratch org and run the agent where only that org is signed in, with the metadata and testing tools switched on and nothing else.

A lamplit booth with one tool chest, locked cabinets behind, under: which Salesforce orgs can your coding agent reach

Takeaways

  1. 01The DX MCP Server reaches only orgs listed in --orgs. ALLOW_ALL_ORGS opens every org signed in, and Salesforce's own tip points to it.
  2. 02Creating a scratch org needs a Dev Hub login, often the production org. The create, snapshot, delete and open tools are non-GA.
  3. 03The --orgs flag is an editable config. The firmer limit is physical: run the agent where only its scratch org is signed in.
  4. 04An Enterprise Dev Hub allows 80 creations in 24 hours, shared by everyone. One new org per retry uses that up in a day.
  5. 05A scratch org starts empty, so a passing test says little about your real org until you use an org shape or snapshot.

Which orgs can a coding agent reach through the Salesforce DX MCP Server?

Only the ones you list, and the list has a loose setting. The Salesforce DX MCP Server is an npm package, @salesforce/mcp, that lets a coding tool such as Claude Code, Cursor or VS Code with Copilot deploy metadata, run Apex tests and query data in a Salesforce org. Salesforce says it carries more than 60 tools. Some Salesforce pages label the server Beta, and the tool reference marks several tools non-GA. This piece is about that tool on a developer's machine, not about an Agentforce agent writing to production. For the production write path, see how we test an approval.

You tell it which orgs it may touch with the required --orgs flag. The values are DEFAULT_TARGET_ORG, DEFAULT_TARGET_DEV_HUB, ALLOW_ALL_ORGS, or a specific username or alias. Salesforce recommends that you not hand over every org you have authorized, and name only the ones the server should use.

Two details matter. First, the server reads the encrypted auth files already on the machine and passes usernames to its tools, not tokens. An org is reachable only if someone signed in to it on that machine and you allowlisted it. Second, the two DEFAULT_TARGET_* values are not fixed. The project's README says they resolve on every tool call and follow whatever the default org is at that moment. If you want a fixed set, name the aliases.

If a coding agent is one of the identities that can change your org, our control plane page shows where the identity, the approval and the log sit.
Diagram: a coding agent reaches only agent-scratch-1 of three orgs signed in on the machine
Signed in on the machine is not the same as reachable. The --orgs list decides.
A lamplit workbench on a small raft by a harbour post, with a dark stone warehouse shut across the water
The agent gets a bench of its own. The warehouse stays shut.

Why is creating the scratch org the risky step?

Because creating one takes a Dev Hub login, and Salesforce says a Dev Hub is often your production org. Salesforce's page on scratch org editions opens with it: "Your Dev Hub org is often your production org." Its guide to the core MCP tools says that to create a scratch org through MCP, you must also authorize a Dev Hub org.

So the convenient setup, where the agent makes its own disposable org, is also the one where a production login sits on the machine, inside the allowlist. The risk starts when the allowlist includes the hub.

Four steps: the agent asks for a scratch org, needs a Dev Hub login, which is often production, and so holds that login
Why creating the org is the risky step.

The tool that does it is create_scratch_org, and Salesforce marks it NON-GA, not generally available. So are create_org_snapshot, delete_org and open_org. By default the server uses only generally available tools. You switch the others on with --allow-non-ga-tools. deploy_metadata, retrieve_metadata, run_apex_test and list_all_orgs are generally available.

The tool reference has one more line. delete_org is described as deleting a locally authorized scratch org or sandbox. With the non-GA flag on and a sandbox alias in --orgs, the agent is allowed to delete the sandbox.

The documentation also has a trap. Salesforce's troubleshooting tip says that if a scratch org you created by prompt does not show up when you list orgs, add its alias to --orgs or specify ALLOW_ALL_ORGS. The second fix removes the allowlist. Take the first.

Create scratch org, create snapshot, delete org and open org need an extra flag; deploy, retrieve and run tests do not
Four org tools sit behind the non-GA flag.

What does a loose setup look like next to a pinned one?

A loose one reaches every org on the machine and every tool. A pinned one reaches one disposable org and two toolsets. The flags below come from Salesforce's own examples and flag tables.

Two ways to start the DX MCP Server

CriterionFlagsWhat the agent can reach
Loose--orgs ALLOW_ALL_ORGS --toolsets all --allow-non-ga-toolsEvery org authorized on that machine, every tool, including creating a scratch org and deleting an org
Pinned--orgs agent-scratch-1 --toolsets metadata,testingOne named scratch org. Deploy, retrieve and test only. No create, delete or Dev Hub
Flags and tool names from the Salesforce DX Developer Guide and the salesforcecli/mcp README, read on 1 October 2026.

In the pinned setup a person creates agent-scratch-1 before the session and authorizes it on the machine. The agent gets the alias and nothing else. If a loop goes wrong, the damage is one org that was going to expire anyway.

ALLOW_ALL_ORGS reaches every org signed in on the machine; a pinned list reaches one named scratch org
The org list is the ceiling for every tool call.

Salesforce adds a client-side control you should use too. Its guide suggests configuring your MCP client to run read-only tools automatically and to ask for confirmation before a tool that changes your project or an org. That is a setting in the client, so it is only as strong as the person who owns the client's configuration. So there are three layers, weakest first: the client's prompt, the --orgs list, and which orgs are signed in on the machine at all. The next section explains why the third is the one to rely on.

What enforces the list, and how do you stop the agent?

Nothing in Salesforce's documentation, as we read it. The --orgs flag lives in the MCP client's config file on a developer's machine. A developer can edit it, and Salesforce's own tip tells them how. So treat the flag as a convention until something else holds it.

The stronger control is physical. The server can use only orgs that someone has authorized on that machine. Run the agent on a laptop profile or a CI runner where the only org signed in is agent-scratch-1, and ALLOW_ALL_ORGS would still allow only that one. An org that was never signed in cannot be reached, whatever the flag says. Review changes to the config file as you would any access change, and pin the package version. Salesforce recommends the @latest tag, which means the tool list can change under you, and a Beta server with non-GA tools is a decision to put on your approved-tools list, not a default.

On who acted: the server reads the auth files already on the machine, so by our reading the agent writes as whoever signed in. In a scratch org that is a throwaway login in a throwaway org, so the question barely matters. In a sandbox it matters, because the change appears under a person's name with nothing to mark it as the agent's. We would keep sandboxes off the list. If the agent must work in one, our practice is to sign it in with a dedicated user created for that purpose, so the audit log names the agent's login and not a developer's. Salesforce's documentation does not prescribe that, and we have not tested what the log shows.

In a pipeline, split the work in two jobs. The first holds the Dev Hub login in the pipeline's secret store and creates the scratch org. The second runs the agent and receives only that scratch org's sign-in, never the hub's.

The stop is simple when the agent has only a scratch org. Delete the scratch org or sign it out of the machine, and the agent has nothing left to reach. What you can show an auditor: the server's args, the output of list_all_orgs, the scratch org's expiry date, and the pull request with its test run. In SOC 2 terms, the AICPA groups logical access under its CC6 series and change management under CC8, so our reading is that the org list and signed-in orgs belong under CC6 and the pull request under CC8. We have not mapped them to NIST AI RMF or ISO 42001, and your auditor decides which clause applies.

What stops an agent loop from using up your scratch orgs?

The Dev Hub's allocation, and it stops everyone, the agent included. Your Dev Hub edition sets two numbers: how many scratch orgs can be active at once, and how many creations you can start in a rolling 24 hours.

Dev Hub editionActive at onceCreations in a rolling 24 hours
Developer Edition or trial36
Enterprise Edition4080
Unlimited Edition100200
Performance Edition100200

An agent that creates a fresh org for every retry reaches 80 on an Enterprise hub at one creation about every 18 minutes (24 hours divided by 80, our arithmetic). After that, nobody on the team can create a scratch org until older creations roll out of the window. Salesforce says an active allocation frees when you delete a scratch org or it expires. The daily limit counts creations, so by our reading a deletion does not lower it.

Dev Hub allocations: Developer 3 active and 6 a day, Enterprise 40 and 80, Unlimited and Performance 100 and 200
Allocations by Dev Hub edition, shared by everyone on the hub.

You can read what is left. Run sf limits api display --target-org <Dev Hub> and look at ActiveScratchOrgs and DailyScratchOrgs. The pinned setup above keeps the agent off the creation path altogether. If you do let it create orgs, set a short life. A scratch org lasts 7 days unless you set 1 to 30 with --duration-days, and an expired one cannot be restored.

Does a scratch org look like your real org?

Not until you make it. By default a scratch org is empty. Salesforce lists what is missing: custom objects and fields, profiles and permission sets, Apex classes and triggers, and sample data. An agent that deploys a change there and sees green tests has proven the change works in an empty org.

Salesforce gives two ways to close the gap. An org shape copies the features, settings, edition, licenses and limits of a source org, often production. A snapshot is a point-in-time copy of a scratch org with its packages, metadata and data. Snapshots leave out connected apps, external credentials and named credentials, because they could expose secrets. So an integration test that needs a credential will not run from a snapshot alone.

A scratch org starts without custom objects, profiles and permission sets, Apex code, or sample data
A pass in an empty org is not a pass in your real org.

Two cautions from the same pages. Salesforce says not to put personal data in scratch orgs. And scratch orgs are not a replacement for a sandbox when users test the result.

One related fact from our own reading of the billing rules: Salesforce does not meter registered-agent calls in scratch orgs, so you can count an agent's calls there before you see them on a bill. That is in what Salesforce says about agent call billing.

What do these docs not tell you?

Several things. We read the documentation. We did not run these flags against a live org for this piece, so treat the setups above as a design from the docs, and test them in a sandbox of your own.

Some Salesforce pages label the server Beta and others do not, and the tool flags can change. Check the version you install. The same Salesforce pages disagree on scratch org data storage, 500 MB on one and 200 MB on another, so we left the figure out.

The docs we read also do not say how an admin tells a change the agent made from one a person made. The server uses a login that was already authorized on the machine, so our reading is that the org sees that login. That is a question for your own audit log, and we did not verify it. The hosted MCP servers work differently and are covered in switching on read first.

What would we do first?

We would take one agent task a developer does today and run it in a pinned setup. At Mindcat, we start any work by reading what already exists, then writing down what is worth fixing. For a coding agent that means reading the MCP config on the machine, the orgs authorized there, and which of them is a Dev Hub.

Then we would do five things, in this order:

  1. 01Run the agent where only the scratch org is signed in. Sign out of the Dev Hub and any sandbox.
  2. 02Have a person or a pipeline create the scratch org, with a 1 to 3 day life, and give the agent its alias.
  3. 03Start the server with that alias after --orgs and the metadata and testing toolsets. Leave the non-GA flag off.
  4. 04Run the task. Read what was deployed and which tests ran, not the agent's summary.
  5. 05Open a pull request for a person to review. Name who gets the exceptions and who can delete the scratch org.
Six checks to pin a coding agent: person creates the org, alias only, one org listed, two toolsets, non-GA off, short expiry
Six checks before a coding agent gets near an org.

Our first agent in production path puts a human gate on the write after the agent has run in shadow mode, and the same rule applies to a coding agent. See also how we think about stopping an agent.

Before a coding agent gets near your org, get three answers in writing: which orgs are authorized on its machine, which of them is a Dev Hub, and which tools are switched on.

Filed under

Frameworks and protocolssalesforce scratch orgscratch org salesforceai coding agent salesforce
Useful to someone on your team?

FAQ

Questions teams ask next

What is the Salesforce DX MCP Server?
It is an npm package, @salesforce/mcp, that lets an AI coding tool such as Claude Code, Cursor or VS Code with Copilot deploy metadata, run tests, query data and manage orgs through the Model Context Protocol. Salesforce says it includes more than 60 tools. Some Salesforce documentation pages label it Beta.
Can the DX MCP Server create a scratch org?
Yes, through the create_scratch_org tool, but Salesforce marks that tool NON-GA. By default the server uses only generally available tools, so it stays off until you add the --allow-non-ga-tools flag. Creating one also needs an authorized Dev Hub org.
How many scratch orgs can an agent create in a day?
The Dev Hub edition decides it. Developer Edition allows 3 active and 6 a day, Enterprise 40 active and 80 a day, Unlimited and Performance 100 active and 200 a day. The daily limit is a rolling 24 hours and is shared by everyone who uses that Dev Hub.
Is a scratch org a safe place for an agent to test?
It is a safer place than a shared sandbox, because it is disposable and expires, 7 days by default and 30 at most. It is also empty by default, so a pass there does not prove the change works in your org. Use an org shape or a snapshot, and keep personal data out.

Sources

  1. 01Salesforce DX Developer Guide: Install and Configure the Salesforce DX MCP ServerAccessed 01 Oct 2026
  2. 02Salesforce DX Developer Guide: Salesforce DX MCP Server and ToolsAccessed 01 Oct 2026
  3. 03Salesforce DX Developer Guide: Use the Core Salesforce DX MCP ToolsAccessed 01 Oct 2026
  4. 04GitHub: salesforcecli/mcp READMEAccessed 01 Oct 2026
  5. 05Salesforce DX Developer Guide: Supported Scratch Org Editions and AllocationsAccessed 01 Oct 2026
  6. 06Salesforce DX Developer Guide: Scratch OrgsAccessed 01 Oct 2026
  7. 07Salesforce DX Developer Guide: Scratch Org SnapshotsAccessed 01 Oct 2026
  8. 08AICPA: 2017 Trust Services Criteria (With Revised Points of Focus, 2022)Accessed 01 Oct 2026
Shivanath Devinarayanan, founder of Mindcat

Written by

Shivanath Devinarayanan

Founder, Mindcat Consulting · Salesforce MVP Hall of Fame

Runs 200+ agents in production. Reads every brief that comes in and signs the work that goes out.

About Shivanath

First Agent in Production · the written assessment

We work in real estate and right now, the AI pilot never left the sandbox.

Industry
Problem

Brief: Real estate. Leads from portals and WhatsApp. Follow-up has no owner. Stalled AI or Salesforce pilot. Need a finish, cut, or rebuild call. From: /blog/salesforce-dx-mcp-server-scratch-org.