mongodb-js/mongodb-mcp-server

[Bug]: Unable to connect using connection string

Closed this issue · 11 comments

Version

1.2.0

App

  • Cursor
  • Windsurf
  • VSCode
  • VSCode Insiders
  • Claude Desktop
  • Other

Affected Models (if applicable)

  • Claude 3.5 Sonnet
  • Claude 3.7 Sonnet
  • GPT-4a
  • o4-mini
  • Other

Bug Description

I am unable to connect to the mcp server using the connection string, it gives an error related to docker even though I am not using docker to connect

Image

Thanks for opening this issue. The ticket MCP-274 was created for internal tracking.

Hi thanks for opening this issue.

Could you confirm the following for me: after you see the error message in the console, does the process exit? (Or does the process keep running?)

Could you also share:

  • which tool you're using to interact with our MCP server
  • tell us how you are running MongoDB locally

Thanks!

Hi thanks for opening this issue.

Could you confirm the following for me: after you see the error message in the console, does the process exit? (Or does the process keep running?)

Could you also share:

  • which tool you're using to interact with our MCP server
  • tell us how you are running MongoDB locally

Thanks!

Hey, it keeps running.
I am just running it in the terminal. When I use cursor to interact with the mcp server, it does work but not like this in the terminal, so I don't think its an issue with my MongoDb setup
I haven't setup our MongoDB, I actually just ssh into it to connect to locally.

Hi @Ateeb626

can you clarify what you mean with this statement?

When I use cursor to interact with the mcp server, it does work but not like this in the terminal, so I don't think its an issue with my MongoDb setup

What do you mean that it works? To clarify, the MCP Server is not meant to be used from the terminal. You start the server and connect with Cursor/Copilot/Windsurf, and if you are able to query your MongoDB cluster in your IDE, it means it works fine.

If your Cursor is in your machine, and the MCP Server is in another machine, and Cursor can't connect to the MCP Server, you will need to ensure that:

  1. The MCP Server allows remote connections (in the README.md and our docs we documented best practices for this)
  2. There is no firewall blocking the connection between the MCP Server and Cursor.

You can use a ssh tunnel for this (ssh -L), but this is something that we have not documented as it's specific to your setup.

If the issue is that you can connect to the MCP Server with Cursor, but you can't query the MongoDB Server, you will need to ensure that you have access to the server, credentials are well configured in the client, etc. You can validate this by using mongosh and the very same connection string you use in the MCP Server.

Hi @Ateeb626

can you clarify what you mean with this statement?

When I use cursor to interact with the mcp server, it does work but not like this in the terminal, so I don't think its an issue with my MongoDb setup

What do you mean that it works? To clarify, the MCP Server is not meant to be used from the terminal. You start the server and connect with Cursor/Copilot/Windsurf, and if you are able to query your MongoDB cluster in your IDE, it means it works fine.

If your Cursor is in your machine, and the MCP Server is in another machine, and Cursor can't connect to the MCP Server, you will need to ensure that:

  1. The MCP Server allows remote connections (in the README.md and our docs we documented best practices for this)
  2. There is no firewall blocking the connection between the MCP Server and Cursor.

You can use a ssh tunnel for this (ssh -L), but this is something that we have not documented as it's specific to your setup.

If the issue is that you can connect to the MCP Server with Cursor, but you can't query the MongoDB Server, you will need to ensure that you have access to the server, credentials are well configured in the client, etc. You can validate this by using mongosh and the very same connection string you use in the MCP Server.

I was using it as a remote MCP server to host it in my own infrastructure. So, now the mcp server isn't starting basically from the command line. Previously, this used to work for me with --connectionString parameter but that is deprecated now. However, when i add it as a mcp server directly in Cursor with the UI where I use the same connection string, it works within cursor which is why I thought the issue is in doing it from the command line

If you can't connect to your remote MCP Server in another host, it's likely a connectivity issue between Cursor and your MCP Server. We specify how to configure the MCP Server to host it remotely in the README.md:

https://github.com/mongodb-js/mongodb-mcp-server/?tab=readme-ov-file#option-5-running-as-an-http-server

If your MCP Server is going to be accessible to the internet, please make sure to follow the security best practices specified in the documentation.

If you can't connect to your remote MCP Server in another host, it's likely a connectivity issue between Cursor and your MCP Server. We specify how to configure the MCP Server to host it remotely in the README.md:

https://github.com/mongodb-js/mongodb-mcp-server/?tab=readme-ov-file#option-5-running-as-an-http-server

If your MCP Server is going to be accessible to the internet, please make sure to follow the security best practices specified in the documentation.

Yeah this is what I am doing but when I run the command to start the server over http, I get the error that I shared in the screenshot

We are aware that the error message is a bit misleading, and we have a PR to improve it.

#708

But the error doesn't block or break the server, you should still be able to use the server and connect to it.

Please try it and if you see any error, please share both Cursor and the MCP Server logs.

Yeah, the error message was misleading me, have been able to connect with it even with the error, thank you

No worries, and thanks for opening a ticket!

The corresponding JIRA ticket has been automatically closed.