> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unla.amoylab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP 閘道設定

> mcp-gateway.yaml 設定檔詳細解釋

設定檔支援以 `${VAR:default}` 語法從環境變數讀取。若環境變數未設置則採用預設值。

常見做法是利用不同 `.env` 檔案注入參數，也可直接修改設定檔內容（硬編碼）。

## 基本設定

```yaml theme={null}
port: ${MCP_GATEWAY_PORT:5235}                      # 服務監聽埠
pid: "${MCP_GATEWAY_PID:/var/run/mcp-gateway.pid}"  # PID 檔案路徑
```

<Note>
  此處 PID 需與下方提及一致，主要用於服務管理及熱重載功能。
</Note>

## 儲存設定

儲存設定模組主要用於保存閘道代理相關設定。當前支援兩種儲存方式：

<CardGroup cols={2}>
  <Card title="DB 儲存" icon="database">
    存放於資料庫中，單一記錄一份設定，支援 SQLite3、PostgreSQL、MySQL
  </Card>

  <Card title="API 儲存" icon="api">
    透過 API 端點儲存設定，便於外部組態管理系統集成
  </Card>
</CardGroup>

### 設定範例

```yaml theme={null}
storage:
  type: "${GATEWAY_STORAGE_TYPE:db}"                    # 儲存方式：db, api

  # 資料庫配置（僅 type 為 db 時用）
```
