anjor
July 4, 2025, 10:48pm
1
I am trying to set up MCP with claude code and got this error:
[
{
"debug": "Connection failed: McpError: MCP error -32000: Connection closed",
"timestamp": "2025-07-04T22:46:20.069Z",
"sessionId": "d5321f96-71e1-4116-8b07-43ca9de89b2f",
"cwd": "/Users/anjor/repos/anjor/pltr-mcp-experiments"
},
{
"debug": "Error message: MCP error -32000: Connection closed",
"timestamp": "2025-07-04T22:46:20.069Z",
"sessionId": "d5321f96-71e1-4116-8b07-43ca9de89b2f",
"cwd": "/Users/anjor/repos/anjor/pltr-mcp-experiments"
},
{
"debug": "Error stack: McpError: MCP error -32000: Connection closed\n at an1._onclose (file:///Users/anjor/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1338:14912)\n at _transport.onclose (file:///Users/anjor/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1338:14231)\n at ChildProcess.<anonymous> (file:///Users/anjor/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1340:1444)\n at ChildProcess.emit (node:events:518:28)\n at ChildProcess.emit (node:domain:489:12)\n at maybeClose (node:internal/child_process:1101:16)\n at ChildProcess._handle.onexit (node:internal/child_process:304:5)",
"timestamp": "2025-07-04T22:46:20.069Z",
"sessionId": "d5321f96-71e1-4116-8b07-43ca9de89b2f",
"cwd": "/Users/anjor/repos/anjor/pltr-mcp-experiments"
},
{
"error": "Connection failed: MCP error -32000: Connection closed",
"timestamp": "2025-07-04T22:46:20.070Z",
"sessionId": "d5321f96-71e1-4116-8b07-43ca9de89b2f",
"cwd": "/Users/anjor/repos/anjor/pltr-mcp-experiments"
}
]
Hi @anjor
I managed to reproduce a similar error from Claude. It seems like this failure is caused by a miss-configured npmrc.
Could you double check if step 1. succeeded?
Please re-run the below command:
npm config set '//<enrollment>.palantirfoundry.com/artifacts/api/repositories/ri.artifacts.repository.discovered.foundry-mcp/contents/release/npm/:_authToken=${FOUNDRY_TOKEN}' --location user
If the command succeeded it should update the ~/.npmrc file with a new line
//yourenrollment.palantirfoundry.com/artifacts/api/repositories/ri.artifacts.repository.discovered.foundry-mcp/contents/release/npm/:_authToken=${FOUNDRY_TOKEN}
anjor
July 7, 2025, 12:26pm
3
Hey @Andrius ,
Yeah i see the entry in ~/.npmrc but still getting this in MCP logs:
{
"debug": "Error stack: McpError: MCP error -32000: Connection closed\n at an1._onclose (file:///Users/anjor/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1338:14912)\n at _transport.onclose (file:///Users/anjor/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1338:14231)\n at ChildProcess.<anonymous> (file:///Users/anjor/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1340:1444)\n at ChildProcess.emit (node:events:518:28)\n at ChildProcess.emit (node:domain:489:12)\n at maybeClose (node:internal/child_process:1101:16)\n at ChildProcess._handle.onexit (node:internal/child_process:304:5)",
"timestamp": "2025-07-07T12:24:14.607Z",
"sessionId": "821b9c60-43b1-4ab1-9859-3c859d300274",
"cwd": "/Users/anjor/repos/anjor/pltr-mcp-experiments"
},
{
"error": "Connection failed: MCP error -32000: Connection closed",
"timestamp": "2025-07-07T12:24:14.607Z",
"sessionId": "821b9c60-43b1-4ab1-9859-3c859d300274",
"cwd": "/Users/anjor/repos/anjor/pltr-mcp-experiments"
}
Here’s what i have in the ~/.npmrc:
//<<yourenrollment>>.palantirfoundry.com//artifacts/api/repositories/ri.artifacts.repository.discovered.foundry- mcp/contents/release/npm/:_authToken=<redacted>
anjor:
foundry- mcp
There seems to be an issue with our docs! If you inspect the ~/.npmrc file there is a space in the middle of the line. Will fix the docs ASAP.
anjor
July 10, 2025, 10:30pm
5
That didn’t do it either. But I worked with Claude Code to get it fixed. It wrote these two potentially useful scripts for me:
test_mcp.sh
#!/bin/bash
# Load environment variables
source .env
# Create a temporary .npmrc file with proper authentication
cat > /tmp/.npmrc << EOF
registry=https://<stack>/artifacts/api/repositories/ri.artifacts.repository.discovered.foundry-mcp/contents/release/npm/
//<stack>/artifacts/api/repositories/ri.artifacts.repository.discovered.foundry-mcp/contents/release/npm/:_authToken=${FOUNDRY_TOKEN}
EOF
# Test the Palantir MCP command with the npm config and foundry token
NPM_CONFIG_USERCONFIG=/tmp/.npmrc npx -y "@palantir/mcp@latest" start \
--foundry-api-url "https://<stack>" \
--foundry-token "$FOUNDRY_TOKEN" \
# Clean up
rm -f /tmp/.npmrc
add_mcp.sh
#!/bin/bash
# Load environment variables
source .env
# Remove the existing server first
claude mcp remove palantir-mcp 2>/dev/null
# Add the MCP server with corrected environment variables
claude mcp add palantir-mcp \
-e FOUNDRY_TOKEN="$FOUNDRY_TOKEN" \
-e NPM_CONFIG_REGISTRY="https://<stack>/artifacts/api/repositories/ri.artifacts.repository.discovered.foundry-mcp/contents/release/npm/" \
-e "NPM_CONFIG_//<stack>/artifacts/api/repositories/ri.artifacts.repository.discovered.foundry-mcp/contents/release/npm/:_authToken=$FOUNDRY_TOKEN" \
-- npx "-y" "@palantir/mcp@latest" "start" "--foundry-api-url" "https://<stack>" "--foundry-token" "$FOUNDRY_TOKEN"
1 Like