When running the MCP Server in a Docker container, the container cannot reach services running on the host machine using localhost in the base URL. Each container runs in an isolated network, so localhost always resolves to the container itself, not the host machine.

This becomes an issue only if the MCP Server profile was originally created using a base URL that contains localhost. For example, during development, an OpenEdge Data Service might be running directly on the host and used to generate the MCP server profile:
./mcpgen openapi-gen http://localhost:8810/Sports/web/pdo/SportsService  
./mcpgen up --spec ./openapi_SportsService.yml  

Although localhost works at profile creation time, once the MCP Server starts inside a container, MCP tools running in that container can no longer reach the Data Service using localhost.

If the MCP Server profile was originally created using a host name or an IP address, no additional configuration is required.

To support development scenarios where localhost has been used, MCP provides a convenience mechanism using a mapped host name (data.service) using the extra_hosts configuration.

Recommended approach: Use a host name or IP address

To access the Data Service from the MCP Server container, update the base URL to use a host name or IP address that points to the host machine.

Example
./mcpgen update --base-url http://192.168.10.100:8810/Sports/web/pdo/SportsService openedge-mcp-server

If the MCP Server profile was created using a host name or IP address from the beginning, no additional configuration is required.

Development-only approach for localhost base URLs

During development, as an alternative to changing the base URL to a host name or IP address, you can use the special host name data.service. This name is mapped to the host machine using the extra_hosts setting in the Docker Compose file.

Perform the following steps:
  1. Edit the docker-compose.mcp.yml Docker Compose file for the profile located at:
    generated/<profile>/docker-compose.mcp.yml
  2. Uncomment the extra_hosts block and update the data.service IP address to either the Docker host gateway IP (for example, 172.18.0.1) or the IP address of the host:
    extra_hosts:
     - "data.service:172.18.0.1"
  3. Update the base URL to use data.service:
    ./mcpgen update --base-url <URL> <profile>

    For example,

    ./mcpgen update --base-url http://data.service:8810/Sports/web/pdo/SportsService openedge-mcp-server
  4. Restart the OpenEdge MCP Server container:
    ./mcpgen restart –no-smoke <container-name>

    For example,

    ./mcpgen restart -no-smoke openedge-mcp-server
  5. After the server restarts, use the MCP client to call a tool and confirm that the data service is accessible:
    . /mcpgen client --tool <tool-name> --json <profile>
    For example,
    ./mcpgen client --tool getCustomer --json openedge-mcp-server

Production behavior

The extra_hosts configuration is intended for development only. When exporting a profile for production, the extra_hosts block is removed automatically. No manual cleanup is required.