Skip to content

Better support for authentication schemes besides basic HTTP auth #51

@alexi190

Description

@alexi190

It seems there is still an issue connecting to the Elasticsearch server at http://192.168.1.10:9200. The connection is being closed unexpectedly. This could be due to:

Incorrect server configuration or the server not running.
Network issues or firewall restrictions.
Invalid API key or authentication issues.

{
    "servers": {
        "elasticsearch-mcp-server": {
            "command": "npx",
            "args": [
                "-y",
                "@elastic/mcp-server-elasticsearch"
            ],
            "env": {
                "ES_URL": "http://192.168.1.10:9200",
                "ES_API_KEY": "eHliTjVJOEItZ1FNUUMdwewewvUHI6cV9uZlRxxxxxxxxxxxxxxxxxxxxxx==",
            }
        }
    }
}

i can connect to the server using java api with same api_key also i tried user name and password but same error however i can connect using kibanna

@Configuration
public class ElasticSearchConnectionConfig extends ElasticsearchConfiguration {
    String apiKey = "eHliTjVJOEItZ1FNUUMdwewewvUHI6cV9uZlRxxxxxxxxxxxxxxxxxxxxxx==";

    @Value("${spring.profiles.active}")
    private String activeProfile;


    @Override
    @NonNull
    public ClientConfiguration clientConfiguration() {
        String fingerprint = "A4:96:8E:93:1D:83:35:32:55:48:4E:A5:62:84:1A:15:4B:AA:38:A0:C7:7B:E5:5F:01:F4:87:22:06:01:E2:55";
        SSLContext sslContext = TransportUtils
                .sslContextFromCaFingerprint(fingerprint);
        HttpHeaders headers = new HttpHeaders();
        headers.add("Authorization", "ApiKey " + apiKey);
        System.out.println("PROFILE IS " + activeProfile);
        return ClientConfiguration.builder()
                .connectedTo(Objects.equals(activeProfile, "dev") ? "192.168.1.10:9200" : "es01:9200")
                .usingSsl(sslContext)
                .withDefaultHeaders(headers)
                .build();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    configurationRequests to expose more configuration options.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions