Skip to content

[Bug] MCP Server Fails Due to Internal API Mismatch Between ibis-server and `java-engine #1259

@mknaepen-mycsn

Description

@mknaepen-mycsn

Describe the bug
When using the Wren MCP Server with a standalone Trino database, any attempt to run a SQL query from an MCP client fails with a generic connection error ('ConnectError' object has no attribute 'text').

The root cause is an internal API incompatibility between the ibis-server and java-engine containers. The ibis-server receives the request but then calls an API endpoint on the java-engine that does not exist, resulting in an HTTP 404 Not Found error within the backend, which breaks the query process. This is not a user configuration or networking issue, as all container networking has been verified to be working correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Set up a standalone Trino container using docker-compose.
  2. Set up the Wren Engine services (ibis-server, java-engine) using the default docker-compose.yml from the repository.
  3. Create a shared external Docker network and attach all three containers to it to ensure they can communicate.
  4. Configure the wren-engine/mcp-server with the correct .env, mdl.json, and trino_connection.json files, pointing to the Trino container via its service name (trino_parquet_server).
  5. Launch the MCP server via uv run app/wren.py.
  6. Connect an AI agent (e.g., Cline, Claude Desktop) and attempt to run a SQL query (e.g., "how many channels are there").
  7. Observe that the query fails with a connection error.

Expected behavior
The query should be successfully proxied from the ibis-server to the java-engine, executed on the Trino database, and the results returned to the MCP client. The health_check tool should report that the Wren Engine is healthy.

Screenshots
The user-facing error in the MCP client:
image

The error from the java-engine logs, which shows the true root cause:

2025-07-16T13:37:58.279Z  WARN  http-worker-22  io.wren.main.web.WrenExceptionMapper    Exception, type: class jakarta.ws.rs.NotFoundException, message: HTTP 404 Not Found
jakarta.ws.rs.NotFoundException: HTTP 404 Not Found
        at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:271)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
        ... (stack trace continues)

Desktop:

  • OS: Linux Ubuntu 24 LTS (Docker Desktop)

Wren AI Information

  • Version: latest tags as of July 16, 2025, for ghcr.io/canner/wren-engine-ibis and ghcr.io/canner/wren-engine.

Additional context
An exhaustive troubleshooting process was performed to isolate this bug. Here is the key evidence that proves all networking and configuration is correct:

  1. Host-to-Ibis-Server Connection Works: A curl http://localhost:8000/v1/health from the host machine successfully reaches the ibis-server and receives a {"detail":"Not Found"} response, proving the port mapping is correct.

  2. Ibis-Server-to-Trino Connection Works: A curl from inside the ibis-server container to the Trino container's service name and port (http://trino_parquet_server:8080) connects successfully and receives a valid HTTP 303 See Other response. This proves the Docker network bridge and DNS are working.

  3. Ibis-Server-to-Java-Engine Connection Works: A curl from inside the ibis-server to the java-engine (http://java-engine:8080/v1/health) connects successfully and receives the HTTP 500 / 404 Not Found error shown in the screenshot above.

This combination of evidence definitively proves that all network links are functional. The failure occurs because the ibis-server makes a request to a URL path on the java-engine that does not exist, causing the java-engine to throw the NotFoundException and break the chain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions