Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error connecting to Docker Postgres #71

Closed
Fgabz opened this issue Nov 26, 2024 · 3 comments
Closed

Error connecting to Docker Postgres #71

Fgabz opened this issue Nov 26, 2024 · 3 comments

Comments

@Fgabz
Copy link

Fgabz commented Nov 26, 2024

I've tried to add MCP Postgres server, however got issue while trying with Claude

Error


2024-11-26T23:31:11.185Z [error] Could not start MCP server postgres: Error: spawn npx ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn npx',
  path: 'npx',
  spawnargs: [Array]
}

Config


{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://postgres:postgres@localhost:5432/bounce_persistence_dev"
      ]
    }
  }
}
➜  ~ which npx

/Users/fanilo/.asdf/shims/npx

Check


and I confirm that db was running with

psql postgresql://postgres:postgres@localhost:5432/mydb
@Fgabz
Copy link
Author

Fgabz commented Nov 27, 2024

Ok fixed.

I'll let the issue open for others

Solution (MacOs)

sudo mkdir -p /usr/local/bin
➜  ~ sudo ln -s /Users/YOUR_USER/.asdf/shims/npx /usr/local/bin/npx

@rockywangxiaolei
Copy link

i also got similar problem using MCP server to connect a docker postgresql.
my env is windows 11.
i can see the config has been loaded to Claude desktop (under top menu:file->settings->developer).
there is also logs showing db connected as below:
2024-11-27T08:26:15.225Z [info] Attempting to connect to MCP server postgres...
2024-11-27T08:26:15.250Z [info] Connected to MCP server postgres!
2024-11-27T08:40:21.735Z [info] Attempting to connect to MCP server postgres...
2024-11-27T08:40:21.769Z [info] Connected to MCP server postgres!
however , on the chat interface it keep showing "Could not attach to MCP server postgres"

tried the solution you shared using command under windows but doesnt work.

@jspahrsummers
Copy link
Member

Per #40 (comment), issues with npx on Windows should now be resolved. Please comment on that issue if the fix doesn't work for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants