Skip to content

Configuration

João Miguel Tabosa Vaz Marques Silva edited this page Nov 17, 2025 · 2 revisions

This page describes how to configure the TP-Link Omada MCP server via environment variables.

The MCP server reads configuration from environment variables (or a .env file) into an EnvironmentConfig object defined in src/config.ts, validated with Zod, and then passed to:

  • OmadaClient (for Omada API access)
  • server setup (stdio or HTTP)

Omada Client Configuration

These variables control how the MCP server talks to your Omada controller.

Variable Required Default Description
OMADA_BASE_URL Yes - Base URL of the Omada controller (e.g. https://omada-controller.local).
OMADA_CLIENT_ID Yes - OAuth client ID generated under Omada Platform Integration.
OMADA_CLIENT_SECRET Yes - OAuth client secret associated with the client ID.
OMADA_OMADAC_ID Yes - Omada controller ID (omadacId) to target.
OMADA_SITE_ID No - Optional default site ID; otherwise tools must pass siteId explicitly.
OMADA_STRICT_SSL No true Enforce strict SSL certificate validation (set to false for self-signed).
OMADA_TIMEOUT No 30000 HTTP request timeout in milliseconds.

How these map into the code

In src/omadaClient/index.ts:

  • OMADA_BASE_URL → Axios baseURL
  • OMADA_STRICT_SSL → https.Agent({ rejectUnauthorized: options.strictSsl })
  • OMADA_CLIENT_ID, OMADA_CLIENT_SECRET, OMADA_OMADAC_ID → AuthManager for OAuth client credentials
  • OMADA_SITE_ID → default site in SiteOperations
  • OMADA_TIMEOUT → axiosOptions.timeout

The OmadaClient then builds Omada API paths with:

private buildOmadaPath(relativePath: string): string {
  const normalized = relativePath.startsWith('/') ? relativePath : `/${relativePath}`;
  return `/openapi/v1/${encodeURIComponent(this.omadacId)}${normalized}`;
}

So a call with relativePath = "/sites" becomes:

/openapi/v1/{omadacId}/sites

MCP Generic Server Configuration

These variables control the generic MCP server behavior (logging, transport, statefulness).

Variable Required Default Description
MCP_SERVER_LOG_LEVEL No info Logging verbosity: debug, info, warn, error.
MCP_SERVER_LOG_FORMAT No plain Log format: plain, json, or gcp-json.
MCP_SERVER_USE_HTTP No false Start HTTP server instead of stdio when set to true.
MCP_SERVER_STATEFUL No false Maintain stateful sessions per client when true.

Internally, these values are consumed by:

  • src/server/common.ts (logging, server creation)
  • src/server/http.ts (HTTP server setup and session management)

MCP HTTP Server Configuration

If MCP_SERVER_USE_HTTP=true, the following are used to configure the HTTP transport.

Variable Required Default Description
MCP_HTTP_PORT No 3000 Port for the HTTP server.
MCP_HTTP_TRANSPORT No stream stream (Streamable HTTP) or sse (legacy HTTP+SSE).
MCP_HTTP_BIND_ADDR No 127.0.0.1 Bind address (IPv4/IPv6). Use 0.0.0.0 to expose to the network (careful).
MCP_HTTP_PATH No /mcp or /sse Base path for MCP endpoints (depends on transport if not set).
MCP_HTTP_ENABLE_HEALTHCHECK No true Enable healthcheck endpoint.
MCP_HTTP_HEALTHCHECK_PATH No /healthz Path for the healthcheck endpoint.
MCP_HTTP_ALLOW_CORS No true Enable CORS for the HTTP server.
MCP_HTTP_ALLOWED_ORIGINS No 127.0.0.1, localhost Comma-separated list of allowed origins. Use * only for dev.
MCP_HTTP_NGROK_ENABLED No false Automatically expose the HTTP server via ngrok when true.
MCP_HTTP_NGROK_AUTH_TOKEN No - Ngrok auth token (required if ngrok is enabled).

These are used to configure:

  • HTTP listener and binding (MCP_HTTP_PORT, MCP_HTTP_BIND_ADDR)
  • Transport implementation (MCP_HTTP_TRANSPORT)
  • CORS and origin validation (MCP_HTTP_ALLOWED_ORIGINS, MCP_HTTP_ALLOW_CORS)
  • Healthcheck endpoints
  • Optional automatic ngrok tunneling

See HTTP Transport for concrete usage examples.


Example .env

OMADA_BASE_URL=https://omada-controller.local
OMADA_CLIENT_ID=example-client-id
OMADA_CLIENT_SECRET=example-client-secret
OMADA_OMADAC_ID=example-omadac-id
OMADA_SITE_ID=site-01
OMADA_STRICT_SSL=false
OMADA_TIMEOUT=30000

MCP_SERVER_LOG_LEVEL=info
MCP_SERVER_LOG_FORMAT=plain
MCP_SERVER_USE_HTTP=true
MCP_SERVER_STATEFUL=false

MCP_HTTP_PORT=3000
MCP_HTTP_TRANSPORT=stream
MCP_HTTP_BIND_ADDR=127.0.0.1
MCP_HTTP_PATH=/mcp
MCP_HTTP_ENABLE_HEALTHCHECK=true
MCP_HTTP_HEALTHCHECK_PATH=/healthz
MCP_HTTP_ALLOW_CORS=true
MCP_HTTP_ALLOWED_ORIGINS=127.0.0.1, localhost

For more details on transports, see HTTP Transport. For tool usage, see Tools.

Clone this wiki locally