exa-mcp-server crashes with "SyntaxError: Invalid or unexpected token" — how to fix?
Running
bunx exa-mcp-server@lateston Node v22.16.0 immediately fails withSyntaxError: Invalid or unexpected tokenatnode_modules/exa-mcp-server/.smithery/index.cjs:2. The reporter suspected the shebang wasn't on the first line in the published tarball. What configs work until the package is fixed?Originally asked on GitHub: https://github.com/exa-labs/exa-mcp-server/issues/62
5 answers
Status: Fixed — an Exa collaborator announced on 2025-10-02 that the NPM package was updated, and using the latest package resolves the crash. The thread never confirmed the root cause; the shebang issue was only the reporter's suspicion.
Until you update, two workarounds were confirmed:
- Pin an older version as a temporary hotfix (a commenter suggested 2.0.9, and another confirmed the pin works):
json"exa": { "command": "npx", "args": ["exa-mcp-server@2.0.9"] }- Use the hosted remote MCP endpoint instead of the local server. One commenter said this resolved the error after updating the config:
json"mcpServers": { "exa": { "command": "npx", "args": ["-y", "mcp-remote", "https://mcp.exa.ai/mcp"] } }For Claude Code, a contributor suggested removing the old entry first, then adding the remote with the API key from your shell environment:
claude mcp remove exa claude mcp add exa -e EXA_API_KEY=$EXA_API_KEY -- npx -y mcp-remote https://mcp.exa.ai/mcpwith
export EXA_API_KEY=your_keyset beforehand. A commenter confirmed this worked after removing the old configuration.General advice: pass the API key through an environment variable rather than writing the literal value in your MCP config, so the key doesn't end up in shared config files.
Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Ran
bunx exa-mcp-server@latestand gotSyntaxError: Invalid or unexpected tokenatnode_modules/exa-mcp-server/.smithery/index.cjs:2on Node v22.16.0. The reporter suspected the shebang must be on the first line in the published tarball.Source: https://github.com/exa-labs/exa-mcp-server/issues/62 (opens external site)
Did this work for you?What @sharon-lsvp tried on GitHub (Worked)
Replaced the local server config with the hosted remote endpoint (
npx -y mcp-remote https://mcp.exa.ai/mcp). The commenter said the error resolved after updating the config.Source: https://github.com/exa-labs/exa-mcp-server/issues/62#issuecomment-3336443038 (opens external site)
Did this work for you?What @6DammK9 tried on GitHub (Worked)
Pinned the package version as a temporary hotfix:
npx exa-mcp-server@2.0.9. A later commenter confirmed the pin works.Source: https://github.com/exa-labs/exa-mcp-server/issues/62#issuecomment-3336597409 (opens external site)
Did this work for you?What @JakubHojsan tried on GitHub (Worked)
For Claude Code, a contributor suggested
claude mcp remove exa, thenclaude mcp add exa -e EXA_API_KEY=$EXA_API_KEY -- npx -y mcp-remote https://mcp.exa.ai/mcpwith the key exported in the shell. A commenter confirmed it worked after removing the old configuration.Source: https://github.com/exa-labs/exa-mcp-server/issues/62#issuecomment-3340736505 (opens external site)
Did this work for you?
Related questions
- exa-mcp-server stdio fails with SyntaxError: Invalid or unexpected token on shebang line
- exa-mcp-server ignores --tools option after update: how to select enabled tools?
- Exa MCP server returns HTTP 400 on remote setup (Smithery / mcp-remote)
- Exa MCP hosted SSE endpoint (mcp.exa.ai/mcp) down?
- Exa MCP server unable to connect in KiloCode: remote URL vs npx config