Add an MCP server to the Grok CLI so it works in every folder

Why a per-project Grok server says "folder untrusted" and the agent gets no tools, and the user-scope line that fixes it, with the keyed form per shell.

Updated 4 min readmcpgroksetuptroubleshooting

Tested 28 October 2026 with Grok CLI 1.0.70 on Linux, Node 22On this page: 1 live demo, 1 real output

The short answer

  1. Add the server for your user, so it starts in every folder: grok mcp add --scope user everything -- npx -y @modelcontextprotocol/server-everything.
  2. For a keyed remote server, add --transport http <url> --header "Authorization: Bearer $NAME", written the way your shell expects ($env:NAME in PowerShell).
  3. Check it: grok mcp doctor everything should end with handshake OK and a tool count.
  4. If you keep a server per project instead, trust the folder once: grok --trust mcp doctor everything.

The Grok CLI reads MCP servers from two places: ~/.grok/config.toml (user scope) and .grok/config.toml in a project (project scope). The second only starts in a folder you have trusted, and a headless run (grok -p "…") never stops to ask. That is the whole story behind most "Grok can't see the tools" reports.

Live demoBuild your grok mcp add line

The live demo loads here when scripts run. The text below says what it shows.

Type your server's name and the command that starts it (or its URL and the name of the variable that holds its key), pick user or project scope, your computer, and copy the result. It applies exactly the rules on this page and runs in your browser: nothing is sent or saved. With scripts off, the examples below are the same shapes.

Add it for your user

grok mcp add --scope user everything -- npx -y @modelcontextprotocol/server-everything

Then ask the doctor. This is the whole session as it ran on 28 Oct 2026 (Grok CLI 1.0.70, Linux, an empty home folder):

Real outputgrok mcp add --scope user everything …, then grok mcp list and grok mcp doctor everything
$ grok mcp add --scope user everything -- npx -y @modelcontextprotocol/server-everything
Added stdio MCP server 'everything' with command: npx -y @modelcontextprotocol/server-everything to user config
File modified: ~/.grok/config.toml
$ grok mcp list
  everything: npx -y @modelcontextprotocol/server-everything
$ grok mcp doctor everything

MCP Doctor

  Config sources
    ~/.grok/config.toml                      1 server
    ~/.claude.json                           not found
    .mcp.json                                not found

  everything (stdio: npx -y @modelcontextprotocol/server-everything)
    ✓ command found (/usr/bin/npx)
    ✓ server started (0.0s)
    ✓ handshake OK (protocol 2025-11-25)
    ✓ 13 tools discovered

Found 1 healthy, 0 failing.

Notice the config sources: the doctor also looks for Claude Code's ~/.claude.json and a project's .mcp.json, so a server you already added to Claude Code can show up here too.

@modelcontextprotocol/server-everything is the MCP project's own test server: free, on npm, no key, with an echo tool. Start with it to prove the setup, then swap in the command your server's README gives.

A remote server with a key

The example is Clinamen's hosted server, which needs a Clinamen Signature key (sales open at launch); any server that takes a bearer key works the same way.

grok mcp add --scope user --transport http clinamen https://mcp.clinamen.dev/mcp --header "Authorization: Bearer $CLINAMEN_LICENCE_KEY"
grok mcp add --scope user --transport http clinamen https://mcp.clinamen.dev/mcp --header "Authorization: Bearer $env:CLINAMEN_LICENCE_KEY"
grok mcp add --scope user --transport http clinamen https://mcp.clinamen.dev/mcp --header "Authorization: Bearer %CLINAMEN_LICENCE_KEY%"

Your shell fills the key in, so ~/.grok/config.toml holds the value. That file lives in your user folder, never in a repo. On a shared Mac or Linux machine, make it private: chmod 600 ~/.grok/config.toml (Grok wrote it readable by other users on our test machine).

Per project: trust the folder

A project-scoped server is fine when you want it committed with the repo. Without trust, doctor says exactly what happens:

    ✗ folder untrusted (repo-local (project-scoped) server not started for an untrusted folder)
    → re-run with --trust to allow repo-local servers

--trust is a flag on grok itself, before the subcommand. It saves the grant for that folder for good:

grok --trust mcp doctor everything

(grok mcp doctor --trust is refused.) Opening grok in the folder and accepting its trust prompt does the same.

A committed project file must not hold a key. Add the line with the variable's name in single quotes, so your shell leaves it alone and Grok fills it in each time it starts:

grok mcp add --scope project --transport http clinamen https://mcp.clinamen.dev/mcp --header 'Authorization: Bearer ${CLINAMEN_LICENCE_KEY}'

"Healthy" is not "key accepted"

grok mcp doctor checks that the server starts and answers. In our test, a remote server added with an empty key still reported handshake OK, 14 tools, because the server answers every call with "key not received" and how to fix it. So after doctor, ask Grok to call one of the server's tools. A server that explains refusals tells you the reason there; Clinamen's says missing (no key arrived), unexpanded (the variable's name arrived instead of its value) or unknown (a key arrived but is not one it issued).

grok.com and the Grok apps

The chat apps are a different path: at grok.com/connectors, New Connector → Custom takes a public MCP server URL and runs whatever sign-in the server asks for. A server on your own machine needs a tunnel. Clinamen's hosted server signs in with a key in a header today, not OAuth; we have not tested it as a grok.com connector yet.

Something here did not work?

Every command on this page was run before it was published, on the systems named in "How we tested this". If a step fails for you, write to [email protected] with what you ran and what you saw, and we will fix the page.