Serving multiple databases v7

One endpoint process can serve several databases, for both MCP and the OTLP server. List them in edb.endpoints_database and the URL path picks the database. To give MCP a different list, set edb.endpoints_mcp_database. The OTLP server has no list of its own and always uses edb.endpoints_database. Without a list, the endpoint serves one database, postgres by default.

edb.endpoints_database = 'sales, support'

The value is an identifier list, written like search_path. Each database you list must exist for calls to succeed, and each needs AIDB installed to offer more than execute_sql. Run SELECT pg_reload_conf(); to apply a change.

Writing database names

The endpoint matches names exactly and case-sensitively, against the names as Postgres folds them, for MCP and OTLP alike. Quote a name the same way you would in SQL:

In the listServed at
Sales/mcp/sales and /otlp/sales
"Sales"/mcp/Sales and /otlp/Sales
  • Unquoted names fold to lowercase. The supervisor logs a warning when a name folds.
  • Double-quote a name to keep its case, or to include a space, a comma, or a non-ASCII letter. An unquoted non-ASCII name is refused, because the supervisor has no database encoding to fold it with.
  • A list that doesn't parse, is empty, or repeats a name idles the supervisor with a warning until the next pg_reload_conf().

If you launch edb-endpoints yourself, you pass database names with command-line flags instead. See Launching edb-endpoints yourself.

How clients pick a database

For MCP:

URLDatabase
/mcp and /mcp/The first database in the list, the default
/mcp/<name> and /mcp/<name>/The named database. The endpoint percent-decodes <name>.
Any other name404 with the body unknown database, whatever the method

For example, with the list above, http://<mcp-host>:8765/mcp/support serves support, and http://<mcp-host>:8765/mcp serves sales.

Each database has its own MCP sessions. A session opened on one path is unknown on another. The exception is the default database: /mcp, /mcp/, and the first entry's own path share one set of sessions.

When a request reaches bare /mcp, the initialize response names the default database in its instructions, so a client knows which one it's talking to.

For the OTLP server, the database is always part of the URL, as /otlp/<name>/v1/<signal>. There is no default database, so telemetry is never written to a database the sender didn't name. A name that isn't in edb.endpoints_database gets 404 with the body unknown database. See Sending telemetry.

Unavailable databases

  • A listed database without the AIDB extension still serves execute_sql. tools/list offers only that tool, and calling a catalog tool passes Postgres's missing-schema error through.
  • A listed database that doesn't exist, or that is dropped or renamed while the endpoint runs, is still served. initialize succeeds, and each call fails with database "<name>" does not exist. When the database exists again, the next call works without a reload.

Controlling access to each database

Being on the list only makes a database reachable. Who may use it stays with Postgres: the CONNECT privilege and pg_hba.conf. To keep a database away from MCP clients and telemetry senders entirely, leave it off the list. Because MCP and OTLP share edb.endpoints_database, a database is reachable by senders only if it's in that list, even if you set a different edb.endpoints_mcp_database for MCP. A name that isn't listed can never be reached.

To restrict who can use a listed database, revoke CONNECT from PUBLIC first, then grant it to the roles that need it:

REVOKE CONNECT ON DATABASE support FROM PUBLIC;
GRANT CONNECT ON DATABASE support TO agent_alice;

The endpoint connects over the server's Unix socket, so local lines in pg_hba.conf apply. When unix_socket_directories is empty, it falls back to TCP on 127.0.0.1, and host lines for that address apply instead. Whichever lines apply must check a password. See Passwords are always checked.

Whether a database is listed is visible before authentication. An unlisted name returns the 404, and a listed one gets an MCP response. The bare /mcp initialize response also names the default database without credentials.

For the OTLP server, a role that sends telemetry also needs to be a member of aidb_otel_writer. Role membership is cluster-wide, so one GRANT aidb_otel_writer applies in every database where the extension is installed. To limit a sender to some databases, revoke CONNECT on the others.

Upgrading from 7.8.0

Earlier releases served one database through the edb.endpoints_mcp_* settings. Before you upgrade, check these changes:

  • Passwords are now required. The endpoint refuses a connection that pg_hba.conf admitted without checking a password, such as by trust or peer. Change the matching lines to scram-sha-256 before you upgrade, or every tool call fails. See Passwords are always checked.

  • PostgreSQL 14 and 15 are no longer supported for the endpoint.

  • The database setting is now an identifier list. Earlier releases passed edb.endpoints_mcp_database to the endpoint as written. Now:

    • An unquoted name with uppercase letters folds to lowercase, so Sales now means the database sales. Write '"Sales"' to keep the old meaning.
    • A name with a space or a non-ASCII letter no longer parses and idles the supervisor until you double-quote it.
    • A name with a comma now splits into two names. Double-quote it.
    • Whitespace around a name is dropped.

    A lowercase ASCII name, such as the default postgres, means the same as before.

  • The supervisor has a new name. aidb endpoints supervisor replaces aidb mcp endpoint supervisor as its backend_type in pg_stat_activity and as its log prefix. Update monitoring queries and log filters that match the old name. See Logging.

  • Three edb.endpoints_mcp_* settings are deprecated. Replace edb.endpoints_mcp_command_path, edb.endpoints_mcp_restart_max, and edb.endpoints_mcp_restart_window_secs with edb.endpoints_command_path, edb.endpoints_restart_max, and edb.endpoints_restart_window_secs. A value that's still set takes precedence, and the supervisor logs a warning. See Deprecated settings.

  • The MCP host and database settings now default to empty. edb.endpoints_mcp_host and edb.endpoints_mcp_database fall back to edb.endpoints_host and edb.endpoints_database when empty. A value you already set keeps working, so nothing changes unless you set the general settings. See MCP settings.

  • edb.endpoints_mcp_enabled now takes effect on reload. The supervisor still starts only if a server switch is on when Postgres starts, so turning the endpoint on from fully off needs a restart. The new master switch, edb.endpoints_enabled, is on by default. Setting it to off disables every server. See Configuring the endpoint.

  • A launch command you run yourself needs a change. The binary now serves the OTLP server by default. See Launching edb-endpoints yourself.