> ## Documentation Index
> Fetch the complete documentation index at: https://test-8ad8522e-feat-ai-sre.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 更新 MCP 服务器

> 更新 MCP 服务器配置；省略字段表示不变。

## 限制说明

| 项目   | 说明                                     |
| ---- | -------------------------------------- |
| 速率限制 | 每个 `app_key` **1,000 次/分钟**；**50 次/秒** |
| 权限要求 | **MCP 管理**（`ai-sre`）                   |

## 使用说明

* `env`/`headers` 中的脱敏密钥会被保留——回传脱敏值不会覆盖已存储的真实密钥。
* `environments` 是三态部分更新字段：省略（null）表示保持不变；传入列表即整体设置——空列表表示清除限制、恢复为所有环境。
* 变更 `team_id` 需要对目标团队具有重新分配权限；若 `environments` 未随之修改，则当前环境列表在新团队下仍须对调用者可选，否则更新会被拒绝。
* 每次调用都会记录到账户审计日志。


## OpenAPI

````yaml /api-reference/safari.openapi.zh.json post /safari/mcp/server/update
openapi: 3.1.0
info:
  title: Flashduty 开放 API
  description: >-
    Flashduty AI SRE 平台的公开 HTTP API —— 技能、MCP 服务器（连接器）、A2A 智能体与会话。所有接口均使用
    Flashduty 控制台签发的 `app_key` 查询参数进行认证。
  version: 1.0.0
servers:
  - url: https://api.flashcat.cloud
    description: Flashduty Open API
security:
  - AppKeyAuth: []
tags:
  - name: AI SRE/技能
    description: AI SRE 智能体技能管理。
  - name: AI SRE/MCP 服务器
    description: MCP（Model Context Protocol）服务器管理。
  - name: AI SRE/A2A 智能体
    description: A2A（智能体到智能体）远程智能体管理。
  - name: AI SRE/会话
    description: AI SRE 智能体会话历史 —— 查询、查看与导出会话记录。
  - name: AI SRE/自动化
  - name: AI SRE/知识
  - name: AI SRE/产物
    description: AI SRE 产物库 —— 发布、浏览并公开分享智能体生成的文件。
paths:
  /safari/mcp/server/update:
    post:
      tags:
        - AI SRE/MCP 服务器
      summary: 更新 MCP 服务器
      description: 更新 MCP 服务器配置；省略字段表示不变。
      operationId: mcp-write-server-update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MCPServerUpdateRequest'
            example:
              server_id: mcp_4kP9wQ2nLceRtY7uVb3xA1
              description: Query Prometheus metrics, alerts, and rules.
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/MCPServerItem'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  server_id: mcp_4kP9wQ2nLceRtY7uVb3xA1
                  account_id: 10023
                  team_id: 0
                  can_edit: true
                  environments: []
                  server_name: prometheus
                  description: Query Prometheus metrics, alerts, and rules.
                  transport: streamable-http
                  url: https://mcp.example.com/prometheus
                  status: enabled
                  connect_timeout: 10
                  call_timeout: 60
                  auth_mode: shared
                  created_by: 80011
                  created_at: 1716960000000
                  updated_at: 1717046400000
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - AppKeyAuth: []
components:
  schemas:
    MCPServerUpdateRequest:
      type: object
      description: MCP 服务器的部分更新；省略字段表示不变。
      properties:
        server_id:
          type: string
          description: 目标 MCP 服务器 ID，取自 `POST /safari/mcp/server/list` 返回的列表。
        server_name:
          type: string
          description: 新名称；省略或留空则不修改。
          minLength: 1
          maxLength: 255
        description:
          type: string
          description: 新描述；省略或留空则不修改。
          minLength: 1
          maxLength: 1024
        transport:
          type: string
          description: >-
            传输协议；切换时应一并提供对应字段（`stdio` 用 `command`/`args`/`env`，`sse` /
            `streamable-http` 用 `url`/`headers`）；省略或留空则不修改。
          enum:
            - stdio
            - sse
            - streamable-http
        command:
          type: string
          description: 可执行命令（stdio 传输）。
        args:
          type: array
          items:
            type: string
          description: 命令参数（`stdio` 传输）；整体替换：传 `[]` 可清空，省略则不修改。
        env:
          type: object
          additionalProperties:
            type: string
          description: 环境变量（`stdio` 传输）；整体替换，但敏感键回传掩码值或空字符串时保留服务端存储的原值；省略则不修改。
        url:
          type: string
          description: 服务器 URL（sse / streamable-http 传输）。
        headers:
          type: object
          additionalProperties:
            type: string
          description: HTTP 头（`sse` / `streamable-http` 传输）；整体替换，掩码/空值保留规则同 `env`；省略则不修改。
        connect_timeout:
          type: integer
          description: 连接超时，单位秒。0 表示默认（10 秒）。
        call_timeout:
          type: integer
          description: 工具调用超时，单位秒。0 表示默认（60 秒）。
        auth_mode:
          type: string
          description: 认证模式：shared（默认）、per_user_secret 或 per_user_oauth。
        secret_schema:
          type: string
          description: JSON 密钥 schema；auth_mode=per_user_secret 时必填。
        oauth_metadata:
          type: string
          description: JSON OAuth 元数据；为 per_user_oauth 预留。
        team_id:
          type:
            - integer
            - 'null'
          description: 重新分配团队范围：0 表示账户级；>0 表示团队。省略则不变。
          format: int64
        environments:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            该服务器可运行的执行环境：`cloud` 和/或 BYOC Runner 的环境 ID
            列表。省略（null）表示保持不变；传入列表即整体设置——空列表表示清除限制、恢复为所有环境。
        allow_insecure_oauth_http:
          type:
            - boolean
            - 'null'
          description: 是否允许 OAuth 令牌交换使用明文 HTTP。省略表示不变。
        allow_insecure_tls_skip_verify:
          type:
            - boolean
            - 'null'
          description: 是否跳过 TLS 证书校验。省略表示不变。
      required:
        - server_id
    ResponseEnvelope:
      type: object
      description: >-
        Standard response envelope used by every Flashduty public API. On
        success `data` contains the endpoint-specific payload and `error` is
        absent. On failure `error` is present and `data` is absent. `request_id`
        is always present and is also mirrored in the `Flashcat-Request-Id`
        response header.
      properties:
        request_id:
          type: string
          description: 本次请求的唯一 ID，与 Flashcat-Request-Id 响应头一致。反馈问题时请携带该 ID。
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        error:
          $ref: '#/components/schemas/DutyError'
        data:
          description: 端点专属数据负载，具体结构见各操作 200 响应中的 schema。
      required:
        - request_id
    MCPServerItem:
      type: object
      description: 账户下注册的 MCP 服务器（连接器）。
      properties:
        server_id:
          type: string
          description: MCP 服务器唯一 ID（前缀 `mcp_`）。
        account_id:
          type: integer
          description: 所属账户 ID。
          format: int64
        team_id:
          type: integer
          description: 团队范围：0 表示账户级；>0 表示所属团队。
          format: int64
        can_edit:
          type: boolean
          description: 调用者是否可编辑该服务器。
        environments:
          type: array
          items:
            type: string
          description: >-
            该服务器可运行的执行环境（`cloud` 和/或 BYOC Runner 的环境 ID）。始终返回；`[]`
            表示所有环境（该字段引入前的历史数据也是空数组）。
        server_name:
          type: string
          description: MCP 服务器名称，在其作用域（账户范围或单个团队）内唯一，大小写不敏感。
        description:
          type: string
          description: 服务器描述。
        ai_description:
          type: string
          description: LLM 生成的描述，存在时优先于 `description`；尚未生成时省略。
        transport:
          type: string
          description: >-
            传输协议。可选值：`stdio`（标准输入输出，本地子进程方式）、`sse`（独立 SSE，旧版 MCP
            传输协议）、`streamable-http`（较新的 HTTP 流式传输协议）。
          enum:
            - stdio
            - sse
            - streamable-http
        command:
          type: string
          description: 可执行命令（仅 stdio 传输）。
        args:
          type: array
          items:
            type: string
          description: 命令参数（stdio 传输）。
        env:
          type: object
          additionalProperties:
            type: string
          description: 环境变量（stdio 传输）；密钥值已脱敏。
        url:
          type: string
          description: 服务器 URL（sse / streamable-http 传输）。
        headers:
          type: object
          additionalProperties:
            type: string
          description: HTTP 头（sse / streamable-http）；密钥值已脱敏。
        proxy_url:
          type: string
          description: 访问服务器使用的出站代理 URL。
        status:
          type: string
          description: 服务器状态。
          enum:
            - enabled
            - disabled
        connect_timeout:
          type: integer
          description: 连接超时，单位秒（0 表示默认 10 秒）。
        call_timeout:
          type: integer
          description: 工具调用超时，单位秒（0 表示默认 60 秒）。
        allow_insecure_oauth_http:
          type: boolean
          description: 允许该服务器的 OAuth token 交换走明文 HTTP；仅供测试使用。为 false 时省略。
        allow_insecure_tls_skip_verify:
          type: boolean
          description: 连接该服务器时跳过 TLS 证书校验；仅供测试使用。为 false 时省略。
        auth_mode:
          type: string
          description: >-
            认证模式。可选值：`shared`（共享凭据：配置资源时保存一份静态凭据，账户内所有调用方共用；缺省及空字符串等同于此值）、`per_user_secret`（按人密钥：每位使用者按
            `secret_schema` 各自保存密钥，运行时按人注入）、`per_user_oauth`（按人 OAuth：每位使用者各自完成
            OAuth 授权，首次调用时按需完成发现与注册）。
          enum:
            - shared
            - per_user_secret
            - per_user_oauth
        secret_schema:
          type: string
          description: JSON 编码的密钥 schema（per_user_secret 模式）。
        oauth_metadata:
          type: string
          description: JSON 编码的 OAuth 元数据（per_user_oauth 模式）。
        source_template_name:
          type: string
          description: 该连接器安装来源的市场模板名称；自建为空。
        created_by:
          type: integer
          description: 创建该服务器的成员 ID。
          format: int64
        created_at:
          type: integer
          format: int64
          description: 创建时间，Unix 毫秒时间戳。
        updated_at:
          type: integer
          format: int64
          description: 最近更新时间，Unix 毫秒时间戳。
      required:
        - server_id
        - account_id
        - team_id
        - can_edit
        - server_name
        - description
        - transport
        - status
        - connect_timeout
        - call_timeout
        - created_by
        - created_at
        - updated_at
        - environments
    DutyError:
      type: object
      description: 响应结构中的错误 payload，仅在非 2xx 响应时出现。
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: 用户可读的错误描述，语言会跟随调用方的 Accept-Language。可能包含字段名、ID 等请求上下文。
          example: The specified parameter template_id is not valid.
      required:
        - code
        - message
    ErrorResponse:
      type: object
      description: 错误响应结构。`error` 必填，`data` 不存在。
      properties:
        request_id:
          type: string
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
          description: 本次请求的唯一追踪 ID（trace ID），反馈问题时请提供该值以便检索日志。
        error:
          $ref: '#/components/schemas/DutyError'
      required:
        - request_id
        - error
    ErrorCode:
      type: string
      description: >-
        Flashduty 错误码枚举。每个失败响应的 `error.code` 都是下列稳定值之一，HTTP 状态码仅作参考。


        | 错误码 | HTTP | 含义 |

        |---|---|---|

        | `OK` | 200 | 保留值，正常错误响应不会返回。 |

        | `InvalidParameter` | 400 | 必填参数缺失或未通过校验。 |

        | `BadRequest` | 400 | 通用的 400 错误，通常是请求本身不合法。 |

        | `InvalidContentType` | 400 | 请求头 `Content-Type` 不是 `application/json`。
        |

        | `ResourceNotFound` | 400 | 目标资源不存在。注意 HTTP 状态码是 400 而非 404（历史设计）。 |

        | `NoLicense` | 400 | 功能需要有效授权，但未找到可用的 license。 |

        | `ReferenceExist` | 400 | 该资源仍被其他实体引用，无法删除。 |

        | `Unauthorized` | 401 | `app_key` 缺失、无效或已过期。 |

        | `BalanceNotEnough` | 402 | 账户余额不足，无法执行需要计费的操作。 |

        | `AccessDenied` | 403 | 身份认证通过，但 RBAC 权限不足以执行该操作。 |

        | `RouteNotFound` | 404 | 请求的 URL 路径不是已知路由。 |

        | `MethodNotAllowed` | 405 | 当前路径不接受所使用的 HTTP 方法。 |

        | `UndonedOrderExist` | 409 | 账户存在未完成的订单，请稍后重试。 |

        | `RequestLocked` | 423 | 因连续失败被临时锁定。 |

        | `EntityTooLarge` | 413 | 请求体超过允许的最大长度。 |

        | `RequestTooFrequently` | 429 | 命中限流（全局、账户级或集成级）。 |

        | `RequestVerifyRequired` | 428 | 操作需要二次验证码，但未提供。 |

        | `DangerousOperation` | 428 | 危险操作，需要进行 MFA 验证。 |

        | `InternalError` | 500 | 服务端未预期错误。反馈问题请附上 `request_id`。 |

        | `ServiceUnavailable` | 503 | 后端依赖不可用，请稍后重试。 |
      enum:
        - OK
        - InvalidParameter
        - BadRequest
        - InvalidContentType
        - ResourceNotFound
        - NoLicense
        - ReferenceExist
        - Unauthorized
        - BalanceNotEnough
        - AccessDenied
        - RouteNotFound
        - MethodNotAllowed
        - UndonedOrderExist
        - RequestLocked
        - EntityTooLarge
        - RequestTooFrequently
        - RequestVerifyRequired
        - DangerousOperation
        - InternalError
        - ServiceUnavailable
      x-enumDescriptions:
        OK: 保留值，正常错误响应不会返回。
        InvalidParameter: 必填参数缺失或未通过校验。
        BadRequest: 通用的 400 错误，通常是请求本身不合法。
        InvalidContentType: 请求头 `Content-Type` 不是 `application/json`。
        ResourceNotFound: 目标资源不存在。注意 HTTP 状态码是 400 而非 404（历史设计）。
        NoLicense: 功能需要有效授权，但未找到可用的 license。
        ReferenceExist: 该资源仍被其他实体引用，无法删除。
        Unauthorized: '`app_key` 缺失、无效或已过期。'
        BalanceNotEnough: 账户余额不足，无法执行需要计费的操作。
        AccessDenied: 身份认证通过，但 RBAC 权限不足以执行该操作。
        RouteNotFound: 请求的 URL 路径不是已知路由。
        MethodNotAllowed: 当前路径不接受所使用的 HTTP 方法。
        UndonedOrderExist: 账户存在未完成的订单，请稍后重试。
        RequestLocked: 因连续失败被临时锁定。
        EntityTooLarge: 请求体超过允许的最大长度。
        RequestTooFrequently: 命中限流（全局、账户级或集成级）。
        RequestVerifyRequired: 操作需要二次验证码，但未提供。
        DangerousOperation: 危险操作，需要进行 MFA 验证。
        InternalError: 服务端未预期错误。反馈问题请附上 `request_id`。
        ServiceUnavailable: 后端依赖不可用，请稍后重试。
      example: InvalidParameter
  responses:
    BadRequest:
      description: Invalid request — usually a missing or malformed parameter.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingParameter:
              summary: Missing required parameter
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InvalidParameter
                  message: The specified parameter skill_id is not valid.
    Unauthorized:
      description: Missing or invalid app_key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingAppKey:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: Unauthorized
                  message: You are unauthorized.
    Forbidden:
      description: The app_key is valid but lacks permission for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            accessDenied:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: AccessDenied
                  message: Access Denied.
    TooManyRequests:
      description: Rate limit hit. Either the global API limit or a per-account limit.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
    ServerError:
      description: Unexpected server-side error. Include the request_id when reporting.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            internal:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InternalError
                  message: >-
                    We encountered an internal error, and it has been reported.
                    Please try again later.
  securitySchemes:
    AppKeyAuth:
      type: apiKey
      in: query
      name: app_key
      description: >-
        App key issued from the Flashduty console. Required on every public API
        call. Keep it secret — it grants the same access as the owning account.

````