Reroute MCP calls with the CLI
A step-by-step guide to letting veefore integrate move a project's existing MCP calls onto Veefore, with a diff, backups and automatic rollback.
If your code already calls an MCP server with the official MCP SDK —
client.callTool(…) — veefore integrate can move those calls onto Veefore
for you. It shows you the change first, backs up every file, type-checks your
project afterwards, and puts everything back if the check newly fails.
The result is the same code the SDK guide has you write:
mcpServer('<server>').callTool(…).
You will need: Node.js 20.10 or newer, a TypeScript or JavaScript project that calls an MCP server over HTTP, and a Veefore account.
#Step by step
Set up the project
bashnpm install -g veefore
cd your-agent-project
veefore
Sign in when the browser opens and answer y. The CLI creates an agent for
this project in the Development environment and writes .env.local and
veefore.config.json. See the Quickstart for what each step
shows.
Connect the same server in the console
The CLI only rewrites a call when it is sure which server it goes to, so the server must be registered with exactly the URL your code uses.
- Find the URL in your code — the one passed to
new StreamableHTTPClientTransport(new URL('…')). - In the console, set the Environment switcher to Development.
- Open MCP → Connect server, paste that URL, tick I know who runs this server and trust it, and click Connect.
- Tick your project's agent and the tools your code calls, then click Authorize N tools.
Install the SDK
bashnpm install @veefore/sdk@1.8.0
Install it first: the rewrite uses mcpServer(), which needs 1.8.0 or later.
With an older SDK installed, the calls are listed with this command instead of
changed, so the project keeps compiling.
Preview the change
bashveefore integrate --dry-run
This shows the diff without writing anything. Each rerouted call looks like this:
diff+import { mcpServer } from '@veefore/sdk';
...
- const result = await client.callTool({ name: 'read_wiki_structure', arguments });
+ const result = await mcpServer('deepwiki').callTool({ name: 'read_wiki_structure', arguments });
Anything the CLI is not sure about is listed instead of changed, with the file, the line and the code to write (see What it will not change).
Apply it
bashveefore integrate
integrate shows the same diff and asks before writing. It backs up each file,
then runs your TypeScript compiler (--noEmit) or node --check. If a check
newly fails, every file is restored automatically.
To undo it later:
bashveefore undo
A file you edited after the change is left alone and listed, unless you add
--force.
Run it, and check it worked
Run your agent as usual, with veefore dev in another terminal to watch the
decisions. Open Actions in the console: each MCP call is listed with your
agent and a tool named mcp_<server>_<tool>.
Then confirm nothing still goes around Veefore:
bashveefore doctor
doctor fails a project that still calls an MCP server directly, with the file
and line of each call.
Turn on protection
bashveefore policies test
veefore deploy --mode ENFORCE --reason "MCP calls rerouted and reviewed"
Until then the environment is in Observe: calls run and are recorded, and nothing is blocked.
#What it will not change
The CLI rewrites a call only when it can be certain. It lists the rest, with the line to write, when:
- The URL is not in the file, or does not match exactly one server registered in the agent's environment. Register the server with the exact URL, or make the change by hand.
- The project defers approvals (
VEEFORE_APPROVAL_MODE=defer) and the code reads the result. The result can now be "awaiting approval", so the code around it needs anisAwaitingApproval(…)check. See the SDK guide. - The code is Python. Python MCP sessions are always listed. Use
guard_client().mcp_call(…)as shown in the SDK guide.
Running veefore integrate again changes nothing that is already rerouted.