apply-native-policy-to-instance

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Apply Native Policy to an Instance

将原生策略应用到实例

List what is already applied, change it, or apply one native plugin to one instance — then wait until the write has actually finished.
列出已应用的内容、进行修改,或将一个原生 plugin 应用到一个实例——然后等待写入操作真正完成。

When to Use This Skill

何时使用此 skill

Use this skill when the user asks to:
  • "What protection do I have for my Apigee APIs?"
  • "Improve the IP filtering to include 1.1.1.1"
  • "Add ip-restriction to this Kong instance"
  • "Apply quota to that Apigee proxy"
  • List, edit, or apply a native plugin/template (not a Universal/canonical template)
Trigger keywords: what protection · what's applied · change this policy · IP filtering · this instance · Kong plugin · Apigee · Azure · native policy.
Do NOT use this skill when:
  • They want the same canonical policy on many instances / providers → skill apply-universal-policy (
    apply_universal_policy
    )
  • They are driving Anypoint REST (OpenAPI
    urn:api:*
    ), not MCP → skill apply-policy-to-api-instance
  • They need to create the instance first → skill secure-api
  • They want to remove / disable a policy — say so and stop
当用户提出以下要求时,使用此 skill:
  • “我的 Apigee API 有哪些保护?”
  • “改进 IP 过滤,将 1.1.1.1 纳入其中”
  • “为此 Kong 实例添加 ip-restriction”
  • “为该 Apigee proxy 应用 quota”
  • 列出、编辑或应用一个原生 plugin/template(而不是 Universal/canonical template)
触发关键词: 有哪些保护 · 已应用了什么 · 修改此策略 · IP 过滤 · 此实例 · Kong plugin · Apigee · Azure · 原生策略。
以下情况不要使用此 skill:
  • 用户希望在许多实例或提供商上使用同一个 canonical 策略 → skill apply-universal-policy(
    apply_universal_policy
    )
  • 用户正在通过 Anypoint REST(OpenAPI
    urn:api:*
    )而非 MCP 进行操作 → skill apply-policy-to-api-instance
  • 用户需要先创建实例 → skill secure-api
  • 用户希望移除或禁用策略——告知用户后停止

Prerequisites

前置条件

Connected to
urn:mcp:mulesoft-platform
. Probe with
view_api_instance_policies
or
prepare_policy_creation
. If the tools are missing, stop. On 403 / gate-closed (
enabled: false
), say they are not entitled and stop — never silently switch provider.
确保已连接到
urn:mcp:mulesoft-platform
。使用
view_api_instance_policies
或
prepare_policy_creation
进行探测。如果工具缺失,则停止。遇到 403 或 gate 已关闭(
enabled: false
)时,说明用户未获相应使用权限并停止——绝不悄悄切换 provider。

Reference files

参考文件

  • references/native-apply.md
    — provider routing,
    find_assets
    join, edit merge, Apigee rename rule, and how to wait for completion. Read it before the first write.
  • references/native-apply.md
    ——provider 路由、
    find_assets
    结果关联、编辑合并、Apigee 重命名规则以及如何等待操作完成。首次写入前必须阅读。

Workflow

工作流

Pick the path first

先选择路径

Read the latest user turn and choose one path. Do not run Apply steps for an Audit or Edit request.
PathWhenGo to
Audit"What protection / what's applied" with no change yetStep A
EditChange an already-applied native policy ("add 1.1.1.1")Step E
ApplyAdd a native plugin that is not already on this instanceSteps 1–5
阅读用户最新一轮消息并选择一条路径。对于 Audit 或 Edit 请求,不要执行 Apply 步骤。
路径使用场景前往
Audit询问“有哪些保护/已应用什么”,且尚未提出更改步骤 A
Edit修改已应用的原生策略(“添加 1.1.1.1”)步骤 E
Apply添加当前实例尚未应用的原生 plugin步骤 1–5

Rules that always apply

始终适用的规则

  1. Native catalog, not Universal. Never send a Kong plugin name (or an Apigee template id) to
    apply_universal_policy
    .
  2. Confirm before acting. Show the mapping (native policy name → API instances), then wait for an explicit yes before apply or edit.
  3. Do not guess property names. Build
    configuration_data
    from
    get_policy_template_form
    (
    template.configuration
    ). Apigee uses nested objects and
    @
    -prefixed attributes — copy those names.
  4. One-shot config. Show the schema table (required-only when it is longer than about 12 flattened rows, disclosing hidden optionals and offering to expand). Collect the visible fields in one reply. Do not invent optionals. On edit, prompt only for fields the merge left empty — do not re-ask the whole schema when the delta is complete.
  5. Wait for completion. External writes often return
    status: "success"
    with
    httpStatus
    202 /
    operationStatus=accepted
    . That is acceptance, not done. Poll
    list_instance_policy_operations
    . MuleSoft writes are typically synchronous (2xx without
    operationStatus
    ).
  1. 使用原生目录,而非 Universal。 绝不要将 Kong plugin 名称或 Apigee template id 传给
    apply_universal_policy
    。
  2. 执行前必须确认。 显示映射关系(原生策略名称 → API 实例),然后等待用户明确同意后再执行 apply 或 edit。
  3. 不要猜测属性名称。 根据
    get_policy_template_form
    (
    template.configuration
    )构建
    configuration_data
    。Apigee 使用嵌套对象和带
    @
    前缀的属性——应准确复制这些名称。
  4. 一次性收集配置。 显示 schema 表(当展开后的行数超过约 12 行时,仅显示必填字段,同时披露隐藏的可选字段并提供展开选项)。在一次回复中收集所有可见字段。不要虚构可选字段。执行 edit 时,仅询问合并后仍为空的必填字段——当变更内容完整时,不要重新询问整个 schema。
  5. 等待完成。 外部写入操作经常返回
    status: "success"
    ,同时带有
    httpStatus
    202 或
    operationStatus=accepted
    。这只表示操作已被接受,并不表示已经完成。需要轮询
    list_instance_policy_operations
    。MuleSoft 写入操作通常是同步的(返回 2xx 且没有
    operationStatus
    )。

Step A: Audit — what is already applied

步骤 A:Audit——查询已应用的内容

Skip Apply. Do not pass
policy_name_filter
. Do not offer to apply a Universal policy unless they ask.
This is the "what protection do I have for my Apigee APIs?" path: they may name a provider slice (several APIs), not a single instance.
  1. Call
    find_assets
    with
    include_applied_policies=true
    ,
    asset_type=api
    ,
    user_query
    verbatim. Put a named provider in
    query
    , then filter client-side (
    references/native-apply.md
    ).
  2. Present the applied-policy list grouped by API, then instance — policy names with each API instance. When they named a provider, show only that provider's instances.
  3. Ask whether they want to change any. If they do, go to Step E.
Example shape:
Payments API
  prod (Production · apigee)
    - Access control (inbound, enabled)
  sandbox (Sandbox · apigee)
    - (none)
跳过 Apply。不要传入
policy_name_filter
。除非用户主动要求,否则不要提议应用 Universal 策略。
这是“我的 Apigee API 有哪些保护?”路径:用户可能指定的是某个提供商范围(多个 API),而不是单个实例。
  1. 调用
    find_assets
    ,设置
    include_applied_policies=true
    、
    asset_type=api
    ,并将
    user_query
    原样传入。如果用户指定了 provider,则将其放入
    query
    ,然后在客户端进行筛选(参见
    references/native-apply.md
    )。
  2. 显示已应用策略列表,先按 API、再按实例分组,并列出每个 API 实例对应的策略名称。如果用户指定了 provider,仅显示该 provider 的实例。
  3. 询问用户是否希望修改其中某个策略。如果希望修改,则前往步骤 E。
示例格式:
Payments API
  prod (Production · apigee)
    - 访问控制(入站,已启用)
  sandbox (Sandbox · apigee)
    - (无)

Step E: Edit an already-applied native policy

步骤 E:编辑已应用的原生策略

Skip Apply unless you still need the instance list from Step A.
There is no bulk-edit tool: loop once per instance. Several Apigee APIs with the same native policy is still one
edit_applied_policy
each.
  1. Identify
    api_instance_id
    +
    policy_id
    + Exchange
    asset.{group_id,asset_id,asset_version}
    +
    provider
    (and
    environment_id
    on MuleSoft) from
    view_api_instance_policies
    (do not guess). Skip
    readOnly: true
    — say so and stop for those.
  2. Load the schema with
    get_policy_template_form
    using those coordinates.
  3. Read current
    configurationData
    . Merge the requested delta into that full object (
    configuration_data
    replaces wholesale — omitted keys are dropped). Prompt only for required fields the merge left empty.
  4. Apigee: never change
    @name
    / display name
    on an existing policy. Edit configuration values only. A rename makes the async
    UPDATE
    fail (
    BAD_REQUEST
    ) even though the tool reported
    success
    on the 202.
  5. Show the native-policy → API + instance mapping of every instance you will loop. [GATE] Wait for okay.
  6. Call
    edit_applied_policy
    per instance. Then wait (
    references/native-apply.md
    ). Confirm per API instance.
除非仍需从步骤 A 获取实例列表,否则跳过 Apply。
没有批量编辑工具:每个实例仅循环处理一次。即使多个 Apigee API 使用同一个原生策略,也必须为每个实例分别执行一次
edit_applied_policy
。
  1. 从
    view_api_instance_policies
    中获取
    api_instance_id
    、
    policy_id
    、Exchange
    asset.{group_id,asset_id,asset_version}
    和
    provider
    (对于 MuleSoft 还需获取
    environment_id
    ),不要猜测。对于
    readOnly: true
    的实例,说明情况并停止处理这些实例。
  2. 使用这些坐标调用
    get_policy_template_form
    加载 schema。
  3. 读取当前的
    configurationData
    。将用户请求的变更内容合并到完整对象中(
    configuration_data
    会整体替换——遗漏的键会被丢弃)。仅询问合并后仍为空的必填字段。
  4. Apigee:绝不要修改已有策略的
    @name
    或显示名称。
    只能编辑配置值。重命名会导致异步
    UPDATE
    失败并返回
    BAD_REQUEST
    ,即使工具在 202 响应中报告了
    success
    。
  5. 显示每个待循环实例的原生策略 → API + 实例映射。[GATE] 等待用户确认。
  6. 对每个实例调用
    edit_applied_policy
    。随后等待操作完成(参见
    references/native-apply.md
    )。逐一确认每个 API 实例。

Step 1: Identify the instance (Apply)

步骤 1:确定实例(Apply)

If the user already named an instance, use that
api_instance_id
(and
environment_id
for MuleSoft). Otherwise
find_assets
(
asset_type=api
,
user_query
verbatim) and pick one. If several remain, list them (API name · instance · environment · provider) and wait.
Resolve
provider
:
kong
/
apigee
/
azure
for external; omit (or
mulesoft
) for Anypoint. Do not guess.
Do not silently apply a new native plugin to a set — that fan-out is skill apply-universal-policy (canonical) or a confirmed Edit loop (already applied).
如果用户已经指定实例,则使用其
api_instance_id
(对于 MuleSoft 还需使用
environment_id
)。否则调用
find_assets
(
asset_type=api
、
user_query
原样传入)并选择一个实例。如果仍有多个候选,则列出它们(API 名称 · 实例 · 环境 · provider)并等待用户选择。
确定
provider
:对于外部提供商,使用
kong
、
apigee
或
azure
;对于 Anypoint,则省略该字段或使用
mulesoft
。不要猜测。
不要在未确认的情况下将一个新的原生 plugin 应用到一组实例。这种批量展开操作应使用 skill apply-universal-policy(canonical),或走已经确认的 Edit 循环(策略已应用)。

Step 2: List native policies that are not yet applied

步骤 2:列出尚未应用的原生策略

Call
prepare_policy_creation
with
organization_id
,
api_instance_id
,
provider
(external), and
policy_name_hint
when they named a policy. MuleSoft also needs
environment_id
.
Each entry carries Exchange coordinates (
groupId
/
assetId
/
assetVersion
) plus
capabilities.injectionPoints
and
applicationLimit
(
MULTIPLE
= the same template may be applied more than once). Applied policies are filtered out (
alreadyApplied
is always false here).
If more than one template matches the hint, list
name
s and ask. If none match, say so and stop.
调用
prepare_policy_creation
,传入
organization_id
、
api_instance_id
、
provider
(外部提供商),如果用户指定了策略名称,还需传入
policy_name_hint
。MuleSoft 还需要
environment_id
。
每个条目都包含 Exchange 坐标(
groupId
/
assetId
/
assetVersion
),以及
capabilities.injectionPoints
和
applicationLimit
(
MULTIPLE
表示同一 template 可以应用多次)。已应用的策略会被过滤掉(这里的
alreadyApplied
始终为 false)。
如果多个 template 与提示匹配,请列出其
name
并询问用户。如果没有匹配项,说明情况并停止。

Step 3: Load the schema and collect configuration

步骤 3:加载 schema 并收集配置

Call
get_policy_template_form
with the selected template's Exchange coordinates (
group_id
,
asset_id
,
asset_version
— required on the external path) plus
provider
/
environment_id
as in Step 2.
Present the schema table. [GATE] Wait for the whole config in one reply, then for okay to apply.
使用所选 template 的 Exchange 坐标(
group_id
、
asset_id
、
asset_version
——外部提供商路径必填)调用
get_policy_template_form
,并按照步骤 2 传入
provider
或
environment_id
。
显示 schema 表。[GATE] 等待用户在一次回复中提供完整配置,然后等待用户确认是否执行 apply。

Step 4: Apply once

步骤 4:执行一次 Apply

Call
apply_policy_to_instance
once with:
  • api_instance_id
  • configuration_data
    — the collected object (schema property names, not guessed ones)
  • asset.{group_id,asset_id,asset_version}
    from Step 2 (required external)
  • provider
    for Kong / Apigee / Azure
  • environment_id
    for MuleSoft
  • injection_point
    only if the template requires it and the user set it; otherwise omit and let APIM default it
Do not loop this tool. Do not call
apply_universal_policy
.
调用一次
apply_policy_to_instance
,传入:
  • api_instance_id
  • configuration_data
    ——收集到的对象(使用 schema 中的属性名称,不要猜测)
  • 步骤 2 中获取的
    asset.{group_id,asset_id,asset_version}
    (外部提供商路径必填)
  • Kong、Apigee 或 Azure 对应的
    provider
  • MuleSoft 对应的
    environment_id
  • 仅当 template 要求且用户已设置
    injection_point
    时才传入该参数;否则省略,让 APIM 使用默认值
不要循环调用此工具。不要调用
apply_universal_policy
。

Step 5: Wait until it is actually done

步骤 5:等待操作真正完成

See
references/native-apply.md
. Report the native policy name → API instances (environment / provider). On
FAILED
, say whether
error.retryable
is present. Optionally re-read
view_api_instance_policies
so the user sees the live
policyId
and config.
参见
references/native-apply.md
。报告原生策略名称 → API 实例(环境/provider)的映射关系。如果状态为
FAILED
,说明是否存在
error.retryable
。可以选择重新读取
view_api_instance_policies
,让用户查看最新的
policyId
和配置。

Best Practices

最佳实践

  • Route first. ✅ Audit stays on Step A; Edit on Step E; a new plugin on one instance is Steps 1–5. ❌ running
    prepare_policy_creation
    / apply because the file is numbered 1–5. ❌ sending a Kong plugin to
    apply_universal_policy
    .
  • Confirm the mapping, then wait. ✅ native policy name → API instances, then an explicit yes. ❌ writing on the schema reply. ❌ treating
    status: "success"
    + HTTP 202 as done — poll
    list_instance_policy_operations
    .
  • Don't guess coordinates or property names. ✅
    policy_id
    /
    asset
    from
    view_api_instance_policies
    ; config keys from
    get_policy_template_form
    . ❌ inventing Apigee
    @
    -prefixed fields or changing
    @name
    on edit.
  • 优先路由。 ✅ Audit 停留在步骤 A;Edit 使用步骤 E;向单个实例添加新 plugin 时使用步骤 1–5。❌ 因为 Apply 步骤编号为 1–5,就对 Audit 或 Edit 请求运行
    prepare_policy_creation
    /apply。❌ 将 Kong plugin 传给
    apply_universal_policy
    。
  • 先确认映射关系,然后等待。 ✅ 显示原生策略名称 → API 实例的映射,然后等待明确同意。❌ 在 schema 回复后立即执行写入。❌ 将
    status: "success"
    和 HTTP 202 视为已完成——应轮询
    list_instance_policy_operations
    。
  • 不要猜测坐标或属性名称。 ✅ 从
    view_api_instance_policies
    获取
    policy_id
    /
    asset
    ,从
    get_policy_template_form
    获取配置键。❌ 虚构 Apigee 带
    @
    前缀的字段或在编辑时修改
    @name
    。

Troubleshooting

故障排查

Tools missing: the Platform MCP catalog on this host is stale. Stop. Do not fall back to Anypoint REST unless the user is on skill apply-policy-to-api-instance.
Gate closed / 403: say they are not entitled for that provider. Stop.
Apply of a new plugin to more than one instance: ask which one, or switch to skill apply-universal-policy if they meant a canonical template.
httpStatus
422 on apply/edit:
configuration_data
does not match the provider schema. Re-read
get_policy_template_form
and use its exact property names.
Apigee edit failed after a 202
success
:
you likely changed
AccessControl.@name
(or the equivalent display name). Keep
@name
identical to the applied value; delete-and-recreate is not on this surface.
User named a Universal/canonical template for many APIs: switch to skill apply-universal-policy.
工具缺失: 当前主机上的 Platform MCP 工具目录已过期。停止操作。除非用户使用的是 skill apply-policy-to-api-instance,否则不要回退到 Anypoint REST。
Gate 已关闭或返回 403: 告知用户未获该 provider 的使用授权。停止操作。
将新 plugin 应用到多个实例: 询问用户要应用于哪个实例;如果用户实际需要的是 canonical template,则切换到 skill apply-universal-policy。
Apply/Edit 返回
httpStatus
422:
configuration_data
与 provider schema 不匹配。重新读取
get_policy_template_form
,并使用其准确的属性名称。
Apigee 在 202
success
后编辑失败:
很可能是修改了
AccessControl.@name
(或等效的显示名称)。保持
@name
与已应用的值完全一致;当前操作界面不提供删除后重建的流程。
用户为多个 API 指定了 Universal/canonical template: 切换到 skill apply-universal-policy。

Related Skills

相关 Skills

  • skill apply-universal-policy: one canonical policy across many instances or providers (
    apply_universal_policy
    ).
  • skill apply-policy-to-api-instance: same job over Anypoint REST (
    urn:api:*
    ), not MCP.
  • skill secure-api: create/deploy the instance first.
  • skill apply-universal-policy:在多个实例或提供商上应用同一个 canonical 策略(
    apply_universal_policy
    )。
  • skill apply-policy-to-api-instance:通过 Anypoint REST(
    urn:api:*
    )而非 MCP 执行相同任务。
  • skill secure-api:首先创建或部署实例。