apply-native-policy-to-instance
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseApply 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 ), not MCP → skill apply-policy-to-api-instance
urn:api:* - 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 )而非 MCP 进行操作 → skill apply-policy-to-api-instance
urn:api:* - 用户需要先创建实例 → skill secure-api
- 用户希望移除或禁用策略——告知用户后停止
Prerequisites
前置条件
Connected to . Probe with
or . If the tools are
missing, stop. On 403 / gate-closed (), say they are not
entitled and stop — never silently switch provider.
urn:mcp:mulesoft-platformview_api_instance_policiesprepare_policy_creationenabled: false确保已连接到 。使用 或 进行探测。如果工具缺失,则停止。遇到 403 或 gate 已关闭()时,说明用户未获相应使用权限并停止——绝不悄悄切换 provider。
urn:mcp:mulesoft-platformview_api_instance_policiesprepare_policy_creationenabled: falseReference files
参考文件
- — provider routing,
references/native-apply.mdjoin, edit merge, Apigee rename rule, and how to wait for completion. Read it before the first write.find_assets
- ——provider 路由、
references/native-apply.md结果关联、编辑合并、Apigee 重命名规则以及如何等待操作完成。首次写入前必须阅读。find_assets
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.
| Path | When | Go to |
|---|---|---|
| Audit | "What protection / what's applied" with no change yet | Step A |
| Edit | Change an already-applied native policy ("add 1.1.1.1") | Step E |
| Apply | Add a native plugin that is not already on this instance | Steps 1–5 |
阅读用户最新一轮消息并选择一条路径。对于 Audit 或 Edit 请求,不要执行 Apply 步骤。
| 路径 | 使用场景 | 前往 |
|---|---|---|
| Audit | 询问“有哪些保护/已应用什么”,且尚未提出更改 | 步骤 A |
| Edit | 修改已应用的原生策略(“添加 1.1.1.1”) | 步骤 E |
| Apply | 添加当前实例尚未应用的原生 plugin | 步骤 1–5 |
Rules that always apply
始终适用的规则
- Native catalog, not Universal. Never send a Kong plugin name (or an
Apigee template id) to .
apply_universal_policy - Confirm before acting. Show the mapping (native policy name → API instances), then wait for an explicit yes before apply or edit.
- Do not guess property names. Build from
configuration_data(get_policy_template_form). Apigee uses nested objects andtemplate.configuration-prefixed attributes — copy those names.@ - 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.
- Wait for completion. External writes often return with
status: "success"202 /httpStatus. That is acceptance, not done. PolloperationStatus=accepted. MuleSoft writes are typically synchronous (2xx withoutlist_instance_policy_operations).operationStatus
- 使用原生目录,而非 Universal。 绝不要将 Kong plugin 名称或 Apigee template id 传给 。
apply_universal_policy - 执行前必须确认。 显示映射关系(原生策略名称 → API 实例),然后等待用户明确同意后再执行 apply 或 edit。
- 不要猜测属性名称。 根据 (
get_policy_template_form)构建template.configuration。Apigee 使用嵌套对象和带configuration_data前缀的属性——应准确复制这些名称。@ - 一次性收集配置。 显示 schema 表(当展开后的行数超过约 12 行时,仅显示必填字段,同时披露隐藏的可选字段并提供展开选项)。在一次回复中收集所有可见字段。不要虚构可选字段。执行 edit 时,仅询问合并后仍为空的必填字段——当变更内容完整时,不要重新询问整个 schema。
- 等待完成。 外部写入操作经常返回 ,同时带有
status: "success"202 或httpStatus。这只表示操作已被接受,并不表示已经完成。需要轮询operationStatus=accepted。MuleSoft 写入操作通常是同步的(返回 2xx 且没有list_instance_policy_operations)。operationStatus
Step A: Audit — what is already applied
步骤 A:Audit——查询已应用的内容
Skip Apply. Do not pass . Do not offer to apply
a Universal policy unless they ask.
policy_name_filterThis is the "what protection do I have for my Apigee APIs?" path: they may
name a provider slice (several APIs), not a single instance.
- Call with
find_assets,include_applied_policies=true,asset_type=apiverbatim. Put a named provider inuser_query, then filter client-side (query).references/native-apply.md - 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.
- 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。不要传入 。除非用户主动要求,否则不要提议应用 Universal 策略。
policy_name_filter这是“我的 Apigee API 有哪些保护?”路径:用户可能指定的是某个提供商范围(多个 API),而不是单个实例。
- 调用 ,设置
find_assets、include_applied_policies=true,并将asset_type=api原样传入。如果用户指定了 provider,则将其放入user_query,然后在客户端进行筛选(参见query)。references/native-apply.md - 显示已应用策略列表,先按 API、再按实例分组,并列出每个 API 实例对应的策略名称。如果用户指定了 provider,仅显示该 provider 的实例。
- 询问用户是否希望修改其中某个策略。如果希望修改,则前往步骤 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 each.
edit_applied_policy- Identify +
api_instance_id+ Exchangepolicy_id+asset.{group_id,asset_id,asset_version}(andprovideron MuleSoft) fromenvironment_id(do not guess). Skipview_api_instance_policies— say so and stop for those.readOnly: true - Load the schema with using those coordinates.
get_policy_template_form - Read current . Merge the requested delta into that full object (
configurationDatareplaces wholesale — omitted keys are dropped). Prompt only for required fields the merge left empty.configuration_data - Apigee: never change / display name on an existing policy. Edit configuration values only. A rename makes the async
@namefail (UPDATE) even though the tool reportedBAD_REQUESTon the 202.success - Show the native-policy → API + instance mapping of every instance you will loop. [GATE] Wait for okay.
- Call per instance. Then wait (
edit_applied_policy). Confirm per API instance.references/native-apply.md
除非仍需从步骤 A 获取实例列表,否则跳过 Apply。
没有批量编辑工具:每个实例仅循环处理一次。即使多个 Apigee API 使用同一个原生策略,也必须为每个实例分别执行一次 。
edit_applied_policy- 从 中获取
view_api_instance_policies、api_instance_id、Exchangepolicy_id和asset.{group_id,asset_id,asset_version}(对于 MuleSoft 还需获取provider),不要猜测。对于environment_id的实例,说明情况并停止处理这些实例。readOnly: true - 使用这些坐标调用 加载 schema。
get_policy_template_form - 读取当前的 。将用户请求的变更内容合并到完整对象中(
configurationData会整体替换——遗漏的键会被丢弃)。仅询问合并后仍为空的必填字段。configuration_data - Apigee:绝不要修改已有策略的 或显示名称。 只能编辑配置值。重命名会导致异步
@name失败并返回UPDATE,即使工具在 202 响应中报告了BAD_REQUEST。success - 显示每个待循环实例的原生策略 → API + 实例映射。[GATE] 等待用户确认。
- 对每个实例调用 。随后等待操作完成(参见
edit_applied_policy)。逐一确认每个 API 实例。references/native-apply.md
Step 1: Identify the instance (Apply)
步骤 1:确定实例(Apply)
If the user already named an instance, use that (and
for MuleSoft). Otherwise (,
verbatim) and pick one. If several remain, list them
(API name · instance · environment · provider) and wait.
api_instance_idenvironment_idfind_assetsasset_type=apiuser_queryResolve : / / for external; omit (or
) for Anypoint. Do not guess.
providerkongapigeeazuremulesoftDo 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).
如果用户已经指定实例,则使用其 (对于 MuleSoft 还需使用 )。否则调用 (、 原样传入)并选择一个实例。如果仍有多个候选,则列出它们(API 名称 · 实例 · 环境 · provider)并等待用户选择。
api_instance_idenvironment_idfind_assetsasset_type=apiuser_query确定 :对于外部提供商,使用 、 或 ;对于 Anypoint,则省略该字段或使用 。不要猜测。
providerkongapigeeazuremulesoft不要在未确认的情况下将一个新的原生 plugin 应用到一组实例。这种批量展开操作应使用 skill apply-universal-policy(canonical),或走已经确认的 Edit 循环(策略已应用)。
Step 2: List native policies that are not yet applied
步骤 2:列出尚未应用的原生策略
Call with , ,
(external), and when they named a policy.
MuleSoft also needs .
prepare_policy_creationorganization_idapi_instance_idproviderpolicy_name_hintenvironment_idEach entry carries Exchange coordinates ( / /
) plus and
( = the same template may be applied more than once). Applied
policies are filtered out ( is always false here).
groupIdassetIdassetVersioncapabilities.injectionPointsapplicationLimitMULTIPLEalreadyAppliedIf more than one template matches the hint, list s and ask. If none
match, say so and stop.
name调用 ,传入 、、(外部提供商),如果用户指定了策略名称,还需传入 。MuleSoft 还需要 。
prepare_policy_creationorganization_idapi_instance_idproviderpolicy_name_hintenvironment_id每个条目都包含 Exchange 坐标( / / ),以及 和 ( 表示同一 template 可以应用多次)。已应用的策略会被过滤掉(这里的 始终为 false)。
groupIdassetIdassetVersioncapabilities.injectionPointsapplicationLimitMULTIPLEalreadyApplied如果多个 template 与提示匹配,请列出其 并询问用户。如果没有匹配项,说明情况并停止。
nameStep 3: Load the schema and collect configuration
步骤 3:加载 schema 并收集配置
Call with the selected template's Exchange
coordinates (, , — required on the
external path) plus / as in Step 2.
get_policy_template_formgroup_idasset_idasset_versionproviderenvironment_idPresent the schema table. [GATE] Wait for the whole config in one
reply, then for okay to apply.
使用所选 template 的 Exchange 坐标(、、——外部提供商路径必填)调用 ,并按照步骤 2 传入 或 。
group_idasset_idasset_versionget_policy_template_formproviderenvironment_id显示 schema 表。[GATE] 等待用户在一次回复中提供完整配置,然后等待用户确认是否执行 apply。
Step 4: Apply once
步骤 4:执行一次 Apply
Call once with:
apply_policy_to_instanceapi_instance_id- — the collected object (schema property names, not guessed ones)
configuration_data - from Step 2 (required external)
asset.{group_id,asset_id,asset_version} - for Kong / Apigee / Azure
provider - for MuleSoft
environment_id - only if the template requires it and the user set it; otherwise omit and let APIM default it
injection_point
Do not loop this tool. Do not call .
apply_universal_policy调用一次 ,传入:
apply_policy_to_instanceapi_instance_id- ——收集到的对象(使用 schema 中的属性名称,不要猜测)
configuration_data - 步骤 2 中获取的 (外部提供商路径必填)
asset.{group_id,asset_id,asset_version} - Kong、Apigee 或 Azure 对应的
provider - MuleSoft 对应的
environment_id - 仅当 template 要求且用户已设置 时才传入该参数;否则省略,让 APIM 使用默认值
injection_point
不要循环调用此工具。不要调用 。
apply_universal_policyStep 5: Wait until it is actually done
步骤 5:等待操作真正完成
See . Report the native policy name → API
instances (environment / provider). On , say whether
is present. Optionally re-read
so the user sees the live and
config.
references/native-apply.mdFAILEDerror.retryableview_api_instance_policiespolicyId参见 。报告原生策略名称 → API 实例(环境/provider)的映射关系。如果状态为 ,说明是否存在 。可以选择重新读取 ,让用户查看最新的 和配置。
references/native-apply.mdFAILEDerror.retryableview_api_instance_policiespolicyIdBest Practices
最佳实践
- Route first. ✅ Audit stays on Step A; Edit on Step E; a new plugin
on one instance is Steps 1–5. ❌ running / apply because the file is numbered 1–5. ❌ sending a Kong plugin to
prepare_policy_creation.apply_universal_policy - Confirm the mapping, then wait. ✅ native policy name → API
instances, then an explicit yes. ❌ writing on the schema reply. ❌
treating + HTTP 202 as done — poll
status: "success".list_instance_policy_operations - Don't guess coordinates or property names. ✅ /
policy_idfromasset; config keys fromview_api_instance_policies. ❌ inventing Apigeeget_policy_template_form-prefixed fields or changing@on edit.@name
- 优先路由。 ✅ Audit 停留在步骤 A;Edit 使用步骤 E;向单个实例添加新 plugin 时使用步骤 1–5。❌ 因为 Apply 步骤编号为 1–5,就对 Audit 或 Edit 请求运行 /apply。❌ 将 Kong plugin 传给
prepare_policy_creation。apply_universal_policy - 先确认映射关系,然后等待。 ✅ 显示原生策略名称 → API 实例的映射,然后等待明确同意。❌ 在 schema 回复后立即执行写入。❌ 将 和 HTTP 202 视为已完成——应轮询
status: "success"。list_instance_policy_operations - 不要猜测坐标或属性名称。 ✅ 从 获取
view_api_instance_policies/policy_id,从asset获取配置键。❌ 虚构 Apigee 带get_policy_template_form前缀的字段或在编辑时修改@。@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.
httpStatusconfiguration_dataget_policy_template_formApigee edit failed after a 202 : you likely changed
(or the equivalent display name). Keep
identical to the applied value; delete-and-recreate is not on this surface.
successAccessControl.@name@nameUser 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 返回 422: 与 provider schema 不匹配。重新读取 ,并使用其准确的属性名称。
httpStatusconfiguration_dataget_policy_template_formApigee 在 202 后编辑失败: 很可能是修改了 (或等效的显示名称)。保持 与已应用的值完全一致;当前操作界面不提供删除后重建的流程。
successAccessControl.@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
(), not MCP.
urn:api:* - skill secure-api: create/deploy the instance first.
- skill apply-universal-policy:在多个实例或提供商上应用同一个 canonical 策略()。
apply_universal_policy - skill apply-policy-to-api-instance:通过 Anypoint REST()而非 MCP 执行相同任务。
urn:api:* - skill secure-api:首先创建或部署实例。