
Thinking About How to Add a Local MCP Server Bundled with a Plugin to Claude Code's MCP Allowlist
This page has been translated by machine translation. View original
Hello! I'm Yoshida from the Cloud Business Division.
For the Claude Code Team plan, we decided to put an MCP allowlist (allowManagedMcpServersOnly and allowedMcpServers) and marketplace restrictions (strictKnownMarketplaces) into the server-managed settings. The plugin we distribute internally bundles a local MCP server. I tried to write this MCP server into the allowlist, but I couldn't write it smoothly by either name or path.
After some experimentation, the following way of installing let me write it into the allowlist.
- Place the plugin in a fixed folder for each user and install it as a directory marketplace
- Write the
serverCommandofallowedMcpServersas a path starting with${HOME} - Narrow down where the plugin is placed with the
pathPatternofstrictKnownMarketplaces
How to distribute plugins depends on each organization's circumstances, so please read this not as the correct answer but as one example of an install method that worked for writing the entry. It should be useful for administrators who are trying to restrict Claude Code's MCP servers with server-managed settings and who distribute plugins that have bundled MCP servers.
I tested with Claude Code 2.1.333 and macOS (Apple silicon). I have not verified Windows.
The MCP server that causes the problem
The problem when writing the MCP allowlist is a local MCP server that launches a file inside the plugin's folder. Even within the same plugin, remote MCP servers and local MCP servers launched by a command on the PATH should be writable as they are.
MCP servers in a plugin are written in the plugin's .mcp.json. Besides local (stdio) servers, you can also write remote servers referenced by an https:// URL.
To reach claude.ai users as well, reference a remote server with an
https://URL, as shown in Bundle an MCP connector with its skill.
In the allowlist, remote servers are matched by serverUrl (the URL), and local servers are matched by serverCommand (the command to launch and its arguments). URLs and commands on the PATH don't change with how the plugin is installed, but the path of a file inside the plugin's folder does. Sorting by the form of the MCP server and whether it's inside or outside a plugin gives the following.
| Form of MCP server | Outside a plugin (claude mcp add) |
Inside a plugin |
|---|---|---|
| Remote (URL) | Can be written with serverUrl |
Can be written with serverUrl (the URL doesn't change with the install method) |
Local, launched by a command on the PATH (such as npx @playwright/mcp@latest) |
Can be written with serverCommand |
Can be written with serverCommand |
| Local, launching a file in a fixed location | Can be written if you decide on a location and tell users | The location changes depending on how the plugin is installed |
Of the "Inside a plugin" column in the table, I haven't tested the remote and PATH command rows. They are conclusions drawn from how matching works in the documentation.
The location of the plugin's folder is decided not by the user but by Claude Code, depending on how it was installed. This article only covers local MCP servers that launch files inside the plugin's folder.
Prerequisites to keep in mind
A plugin is a unit for distributing skills, hooks, MCP servers, and more together. A marketplace is a place that holds a list of plugins (marketplace.json). The differences between skills, plugins, and marketplaces are explained in the "Terminology" section of the following article.
ビジネスユーザに利用してもらうために、コンテナで実行されるSkillを作成して、Claude Code PluginをMarketplaceで配布する | DevelopersIO
The following article is a helpful reference for the steps to turn a local folder into a marketplace. The "directory marketplace" used in the latter half takes this form.
Claude CodeのLSPを公式マーケットプレイスなしで利用する | DevelopersIO
Here I'll cover only the two points needed for the path discussion in the latter half.
Where plugins are placed for each install method
Where the plugin's files are placed depends on how it was installed.
| Install method | Location of the plugin's files | Part of the path that varies |
|---|---|---|
| Marketplace such as GitHub | Copied to ~/.claude/plugins/cache/<marketplace name>/<plugin name>/<version>/ |
Version |
| claude.ai Organization library (sync) | Under ~/.claude/plugins/synced/<organization UUID>_<account UUID>/ |
Account (per person) |
| Directory marketplace (local folder) | Not copied; stays in the folder where you placed it | Only the home folder |
Plugins in a marketplace added from a local folder are loaded from the folder where you placed them, without being copied to the cache.
Relative-path plugins in a marketplace added from a local path: The plugin is loaded in place from its path inside the marketplace folder. (omitted) The plugin's hook processes and MCP and LSP servers receive
CLAUDE_PLUGIN_ROOTpointing at the source directory.
Plugins synced from claude.ai are downloaded by Claude Code from each user's account rather than from a marketplace, so they are outside the scope of the strictKnownMarketplaces restriction (Manage Claude Code plugins for your organization).
${CLAUDE_PLUGIN_ROOT} and the names of a plugin's MCP servers
In a plugin's .mcp.json, you can write the plugin's folder as ${CLAUDE_PLUGIN_ROOT}. ${CLAUDE_PLUGIN_ROOT} expands to the "Location of the plugin's files" in the table above. The .mcp.json of this plugin is as follows.
{
"mcpServers": {
"example-mcp": {
"command": "${CLAUDE_PLUGIN_ROOT}/runtime/node/bin/node",
"args": ["${CLAUDE_PLUGIN_ROOT}/scripts/server.mjs"]
}
}
}
A plugin's MCP server is registered under the name plugin:<plugin name>:<server name>.
The server itself is registered under a scoped name,
plugin:<plugin-name>:<server-name>, such asplugin:my-plugin:database-tools.
Connect Claude Code to tools via MCP
Where I got stuck writing the allowlist
I loaded a JSON containing only the allowlist with claude --settings <file> and searched for the right way to write it while comparing the output of claude mcp list. I got stuck on the following three points.
A plugin's MCP doesn't pass with serverName
At first I intended to allow it by name.
echo '{"allowedMcpServers":[{"serverName":"example-mcp"},{"serverName":"playwright"},{"serverName":"plugin_example-tools_example-mcp"}]}' > allow-mix.json
claude --settings allow-mix.json mcp list
playwright: /usr/local/bin/npx @playwright/mcp@latest - ✔ Connected
The plugin's MCP doesn't appear. Writing plugin:example-tools:example-mcp to match the registered name gave the same result. This is because serverName in allowedMcpServers can't contain a colon.
In
allowedMcpServers,serverNameis limited to letters, digits, hyphens, and underscores.
Control organization MCP server access
The documentation also says that serverName is a label chosen by the user and is not a security control. And once you include even one serverCommand entry, stdio servers are no longer allowed by serverName.
| stdio | Matches a
serverCommandentry. Matching onserverNameis valid only when the allowlist has noserverCommandentries |
Control organization MCP server access
Since other local MCP servers also have to be written with serverCommand, I decided to allow the plugin's MCP by command as well.
serverCommand is matched against the expanded absolute path
Next, I wrote serverCommand using ${CLAUDE_PLUGIN_ROOT}, as in .mcp.json.
{"allowedMcpServers":[{"serverCommand":["${CLAUDE_PLUGIN_ROOT}/runtime/node/bin/node","${CLAUDE_PLUGIN_ROOT}/scripts/server.mjs"]}]}
This didn't match. Looking at the command shown by claude mcp list, ${CLAUDE_PLUGIN_ROOT} has been expanded to an absolute path. Writing the expanded absolute path matched.
plugin:example-tools:example-mcp: /Users/example/example-plugin/example-tools/runtime/node/bin/node /Users/example/example-plugin/example-tools/scripts/server.mjs - ✔ Connected
${VAR} is also expanded on the allowlist side, but what gets expanded is the environment variables at Claude Code's startup. ${CLAUDE_PLUGIN_ROOT} is a value passed to the plugin's MCP server, not an environment variable at Claude Code's startup.
The values of
serverCommandandserverUrlare expanded before matching. Both the policy entry and the value configured on the server go through${VAR}and${VAR:-default}expansion, so an entry written as["${HOME}/bin/server"]matches both a server config that uses the same reference and a server config that uses the expanded path.
Control organization MCP server access
An absolute path can be written, but as the earlier table shows, the path changes depending on how the plugin is installed. If installed from a marketplace such as GitHub, the path includes the version, so you'd have to fix the allowlist with every release. If synced from the Organization library, the account UUID is included, so the path differs from person to person. Either way, the path can't be written as a single allowlist entry.
Specifying cwd didn't connect
I also tried whether I could write it with a relative path and cwd without using ${CLAUDE_PLUGIN_ROOT}.
{"mcpServers":{"example-mcp":{"command":"node","args":["scripts/server.mjs"],"cwd":"."}}}
If you write ["node", "scripts/server.mjs"] in the allowlist, matching passes, but it fails to connect with Failed to connect. The debug log showed the following error.
[ERROR] MCP server "plugin:example-tools:example-mcp" Server stderr: ... Error: Cannot find module '/Users/example/work/scripts/server.mjs'
It was looking for the script not in the plugin's folder but in the folder where Claude Code was launched (/Users/example/work). Even when I set cwd to ${CLAUDE_PLUGIN_ROOT} or an absolute path, it didn't connect. I couldn't find anywhere in the documentation that describes how cwd is handled for plugin MCP servers, so I don't know whether cwd can't be used or whether I wrote it incorrectly. This time I didn't use cwd and instead wrote command and args as paths starting with ${CLAUDE_PLUGIN_ROOT}.
An install method where the path doesn't change
So far I learned that to write it into the allowlist, I need an install method in which the plugin folder's path doesn't change by person or version. So I decided to install it as a directory marketplace.
Where the plugin is placed
Each user extracts the plugin to ~/example-plugin/example-tools and adds ~/example-plugin as a directory marketplace (example-local).
mkdir -p ~/example-plugin/.claude-plugin
unzip -q example-tools.zip -d ~/example-plugin/example-tools
cat > ~/example-plugin/.claude-plugin/marketplace.json <<'EOF'
{
"name": "example-local",
"owner": { "name": "example-org" },
"plugins": [
{ "name": "example-tools", "source": "./example-tools" }
]
}
EOF
claude plugin marketplace add ~/example-plugin
claude plugin install example-tools@example-local
The plugin is loaded from the folder where it was placed, so ${CLAUDE_PLUGIN_ROOT} expands to ~/example-plugin/example-tools. The only part that differs by person is the home folder.
Server-managed settings
The MCP and marketplace portions of the server-managed settings JSON are as follows. In the claude.ai admin console, paste the JSON into Claude Code's server-managed settings and save it.
{
"allowManagedMcpServersOnly": true,
"allowedMcpServers": [
{
"serverCommand": [
"${HOME}/example-plugin/example-tools/runtime/node/bin/node",
"${HOME}/example-plugin/example-tools/scripts/server.mjs"
]
},
{
"serverCommand": [
"${USERPROFILE}\\example-plugin\\example-tools/runtime/node/node.exe",
"${USERPROFILE}\\example-plugin\\example-tools/scripts/server.mjs"
]
},
{ "serverCommand": ["npx", "@playwright/mcp@latest"] },
{ "serverCommand": ["uvx", "awslabs.aws-documentation-mcp-server@latest"] },
{ "serverUrl": "https://knowledge-mcp.global.api.aws" }
],
"strictKnownMarketplaces": [
{ "source": "github", "repo": "anthropics/claude-plugins-official" },
{ "source": "github", "repo": "anthropics/skills" },
{ "source": "github", "repo": "example-org/example-plugins" },
{ "source": "hostPattern", "hostPattern": "^claude\\.ai$" },
{ "source": "pathPattern", "pathPattern": "[/\\\\]example-plugin$" }
]
}
In allowedMcpServers, I wrote the plugin's MCP server as a path starting with ${HOME}. The documentation says to use ${USERPROFILE} instead of ${HOME} on Windows. I haven't verified the Windows entry.
The pathPattern in strictKnownMarketplaces is a regular expression applied to the path of a directory marketplace.
pathPattern:{ "source": "pathPattern", "pathPattern": "^/opt/approved/" }, matched against thepathoffileanddirectorysources. The pattern matches anywhere in the path, so start it with^to pin a directory prefix.
Manage Claude Code plugins for your organization
Ideally I'd want to pin it under the home folder. However, I couldn't find any description saying ${HOME} is expanded in pathPattern. So I narrowed it down by requiring that the end of the path be a folder named example-plugin. [/\\] is [/\] written inside JSON, so that it matches both / on macOS and \ on Windows.
Results of verification
I put the JSON above into the server-managed settings of a test organization and checked with Claude Code. To see them get blocked, I also registered MCP servers that aren't in the allowlist.
claude mcp add playwright -s user -- npx @playwright/mcp@latest
claude mcp add playwright-abs -s user -- "$(which npx)" @playwright/mcp@latest
claude mcp add unlisted-local -s user -- npx -y @modelcontextprotocol/server-everything
claude mcp add --transport http unlisted-remote -s user https://mcp.example.com/mcp
The claude mcp list output after applying the managed settings is as follows.
$ claude mcp list
(claude.ai のコネクタの行は省略。許可リストにURLがあるコネクタだけが出ていた)
plugin:example-tools:example-mcp: /Users/example/example-plugin/example-tools/runtime/node/bin/node
/Users/example/example-plugin/example-tools/scripts/server.mjs - ✔ Connected
aws-mcp-server: uvx awslabs.aws-documentation-mcp-server@latest - ✔ Connected
aws-knowledge: https://knowledge-mcp.global.api.aws (HTTP) - ✔ Connected
playwright: npx @playwright/mcp@latest - ✔ Connected
Compared with before applying the managed settings, the results were as follows.
| Server | Without managed settings | With managed settings |
|---|---|---|
plugin:example-tools:example-mcp |
Connected | Connected |
playwright (npx @playwright/mcp@latest) |
Connected | Connected |
playwright-abs (absolute path /usr/local/bin/npx …) |
Connected | Not shown |
unlisted-local |
Connected | Not shown |
unlisted-remote |
Shown (connection fails) | Not shown |
| Connectors whose URL is not in the allowlist | Shown | Not shown |
I could also call the plugin's MCP tools. playwright-abs is the same Playwright MCP, but since the command was registered with an absolute path, it doesn't match ["npx", "@playwright/mcp@latest"]. This also confirmed that serverCommand is matched by exact match. Even when I added allowedMcpServers to the user's settings, unlisted-local stayed hidden because allowManagedMcpServersOnly is true.
I also verified the marketplace restriction. ~/example-plugin can be added again, and a folder with a different name is blocked.
$ claude plugin marketplace add ~/example-plugin
Adding marketplace…
✔ Added marketplace: example-local (declared in user settings)
$ cp -R ~/example-plugin ~/other-plugin-lab
$ claude plugin marketplace add ~/other-plugin-lab
Adding marketplace…
✘ Failed to add marketplace: Marketplace source 'dir:/Users/example/other-plugin-lab' is blocked by enterprise policy. Allowed sources: github:anthropics/claude-plugins-official, github:anthropics/skills, github:example-org/example-plugins, hostPattern:^claude\.ai$, pathPattern:[/\\]example-plugin$
The scope that this form allows
This form is meant to let the plugin's MCP pass for users who install as instructed; it does not completely fix the placement location. The following three points remain regarding the scope that is allowed.
pathPatternonly looks at the name at the end of the path, so a folder namedexample-plugincan be added as a marketplace wherever it is placed. If someone places a different plugin there, its skills and hooks will be loaded. Its MCP servers should be blocked because they won't matchallowedMcpServers, but I haven't tested this- A
serverCommandentry written with an environment variable can point to a different location if the user changesHOMEbefore launching Claude Code. The documentation also cautions that entries used for enforcement should be written as literals - I haven't verified Windows. I haven't tested whether a path mixing
\and/separators matches, or whether it matches the\side ofpathPattern
Policy entries still depend on the values from the launching shell for the variables they reference, so use literal URLs and commands for entries you rely on for enforcement.
Control organization MCP server access
In closing
A local MCP server that launches a file bundled with a plugin can't be allowed by name in the MCP allowlist, and it's matched against the expanded absolute path. This time, I installed it as a directory marketplace where the path doesn't change, allowed it with a path starting with ${HOME}, and narrowed the placement location with pathPattern.
How to allow remote MCP servers and connectors, and how to write the allowlist for cloud sessions, are summarized in the following article.
Claude CodeのMCP許可リストは、ローカルとクラウドセッションで書き方が違います | DevelopersIO
I hope this helps someone.
That was Yoshida from the Cloud Business Division!
References
- Control organization MCP server access
- Connect Claude Code to tools via MCP
- Add components to a plugin
- Plugin loading reference
- Manage Claude Code plugins for your organization
- Create a marketplace
- ビジネスユーザに利用してもらうために、コンテナで実行されるSkillを作成して、Claude Code PluginをMarketplaceで配布する | DevelopersIO
- Claude CodeのLSPを公式マーケットプレイスなしで利用する | DevelopersIO
- Claude CodeのMCP許可リストは、ローカルとクラウドセッションで書き方が違います | DevelopersIO
