Skip to content

Conversation

@bryangwj
Copy link
Contributor

Currently, the only configuration option for the Elasticsearch instance URL is ES_URL. However, this means you cannot directly connect to Elasticsearch instances behind a reverse proxy or ingress controller that exposes Elasticsearch at a non-root path. This is because the current @elastic/elasticsearch JavaScript client internally uses the undici HTTP library for Node.js, which enforces strict URL validation for connections. Specifically, undici does not allow paths other than / in the base URL you provide to the node property. If you try to connect to a URL like https://example.test.net/test-es/elastic, the client throws an InvalidArgumentError: invalid url because the path is not /. The changes in this pull request addresses this issue by allowing users to include a path prefix (e.g. /test-es/elastic) with the ES_PATH_PREFIX configuration option, while ES_URL remains as before (e.g. https://example.test.net).

@bryangwj bryangwj requested a review from a team as a code owner May 30, 2025 08:26
@cla-checker-service
Copy link

cla-checker-service bot commented May 30, 2025

💚 CLA has been signed

@bryangwj
Copy link
Contributor Author

I've just read and signed the contributor agreement. Do I need to make a new pull request?

@flobernd
Copy link
Member

@bryangwj Thanks for signing the CLA. Opening a new PR is not required.

Copy link
Member

@JoshMock JoshMock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks great to me. Thanks for the contribution @bryangwj!

@JoshMock
Copy link
Member

JoshMock commented Jun 2, 2025

Closing and reopening to try to get the Buildkite CI job going.

@JoshMock JoshMock closed this Jun 2, 2025
@JoshMock JoshMock reopened this Jun 2, 2025
@JoshMock JoshMock enabled auto-merge (squash) June 2, 2025 18:00
@JoshMock
Copy link
Member

JoshMock commented Jun 2, 2025

buildkite test this

@JoshMock JoshMock merged commit c196911 into elastic:main Jun 2, 2025
2 checks passed
technige pushed a commit to technige/mcp-server-elasticsearch that referenced this pull request Jun 6, 2025
* Update index.ts to accept path prefix in Elasticsearch URL

* Update README.md to include information about path prefix

---------

Co-authored-by: Josh Mock <[email protected]>
technige added a commit that referenced this pull request Jun 6, 2025
* Includes specific user-agent for MCP

* Simplified product name for user agent

* chore(deps): update node.js to v22.16.0 (#58)

Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>

* Add new configuration option for Elasticsearch path prefix (#72)

* Update index.ts to accept path prefix in Elasticsearch URL

* Update README.md to include information about path prefix

---------

Co-authored-by: Josh Mock <[email protected]>

* fix(deps): update dependency @elastic/elasticsearch to v9.0.2 (#74)

Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>

* chore(deps): update buildkite plugin monorepo-diff to v1.4.0 (#75)

Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>

* fix(deps): update dependency @modelcontextprotocol/sdk to v1.12.1 (#76)

Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>

---------

Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com>
Co-authored-by: Ang Wei Jun Bryan <[email protected]>
Co-authored-by: Josh Mock <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants