Skip to content

Allow overriding the MCP server name via environment variable #64

Description

@Hope-IT-Works

Problem

The server registers itself with a hardcoded FastMCP server name (MariaDB_Server), which is returned as serverInfo.name during the MCP initialize handshake.

This becomes a problem when running multiple instances of the server against different databases (e.g. separate dev/staging/prod MariaDB instances, each exposed as its own MCP server in a client's configuration). MCP clients such as VS Code group and display tools/approvals by the server's reported name. Since every instance reports the same MariaDB_Server name, they are visually indistinguishable in the client UI (e.g. in VS Code's "Manage Tool Approval" picker), even though each instance is configured under a distinct key in the client's mcp.json and points at a different DB_HOST/DB_NAME.

Example setup

services:
  db1-mcp:
    image: ghcr.io/mariadb/mcp:latest
    environment:
      DB_HOST: db1
      ...
  db2-mcp:
    image: ghcr.io/mariadb/mcp:latest
    environment:
      DB_HOST: db2
      ...

Both db1-mcp and db2-mcp show up as MariaDB_Server in the client, with no way to tell them apart other than inspecting tool call parameters at runtime.

Suggested solution

Add an optional environment variable, e.g. MCP_SERVER_NAME, that overrides the default MariaDB_Server name passed to FastMCP(...). If unset, keep the current default for backward compatibility.

mcp = FastMCP(os.getenv("MCP_SERVER_NAME", "MariaDB_Server"))

This would let operators running multiple instances of the server give each one a distinct, human-readable name (e.g. MariaDB_Production, MariaDB_Staging), making them distinguishable in MCP client UIs without requiring a custom-built image.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions