service-discoverability

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Service Discoverability

服务可发现性

What This Is

这是什么

When an AI agent is handed only your app's URL (e.g.
https://yourapp.com
), it should be able to work out the rest on its own: which canisters the app comprises, what each one does, how to call them, how to query their data, and how to act as the signed-in user. No human supplying canister IDs, no bespoke integration.
This skill covers what a canister app publishes to make that possible, across five layers. Layer 1 is gated: it is what an app publishes to participate in ICP MCP, and publishing it accepts an agreement on the operator's behalf — read Before Layer 1 before writing that file. Layers 2-5 are ungated and independently adoptable; each is useful on its own, and together they make an app agent-ready.
LayerQuestion it answersMechanism
1. CompositionWhich canisters make up this app, and what is each for?
/.well-known/ic-architecture
JSON manifest
2. InterfaceWhat methods and types does a canister expose?
candid:service
metadata
3. BehaviorHow does it actually behave (units, lifecycle, gotchas)?
getApiDoc
query method
4. DataHow do I query its data without a method per question?OQL
schema
+
execute
query methods
5. IdentityHow do I act as the signed-in user, under the right principal?
/.well-known/ii-derivation-origin
file
The load-bearing move for Layers 1 and 5 is generating the well-known files at deploy time, because the canister IDs (and the mainnet origin) differ per network. This skill uses the
@dfinity/static-site
recipe's
presync
hook to do that — the same pattern demonstrated by the community example
raymondk/demo-ic-architecture
.
当 AI Agent 只拿到应用的 URL(例如
https://yourapp.com
)时,它应该能够自行弄清楚其余信息:应用由哪些 canister 组成、每个 canister 的用途、如何调用它们、如何查询数据,以及如何以已登录用户的身份操作。无需人工提供 canister ID,也无需定制集成。
本 skill 介绍 canister 应用为实现上述目标而需要发布的内容,共分为五个层级。第 1 层设有准入门槛:应用需要发布相关内容才能参与 ICP MCP,而发布这些内容即代表运营方接受协议——编写第 1 层文件前请先阅读 第 1 层之前。第 2 至第 5 层没有准入门槛,可以独立采用;每一层单独使用都有价值,组合使用则能让应用具备 Agent 就绪能力。
层级回答的问题机制
1. 组成此应用由哪些 canister 构成,每个 canister 的用途是什么?
/.well-known/ic-architecture
JSON 清单
2. 接口canister 公开了哪些方法和类型?
candid:service
元数据
3. 行为它实际上如何工作(单位、生命周期、注意事项)?
getApiDoc
查询方法
4. 数据如何无需为每个问题编写单独方法就能查询数据?OQL
schema
+
execute
查询方法
5. 身份如何在正确的 principal 下以已登录用户的身份操作?
/.well-known/ii-derivation-origin
文件
第 1 层和第 5 层的关键举措是在部署时生成 well-known 文件,因为 canister ID 和主网 origin 会因网络而异。本 skill 使用
@dfinity/static-site
recipe 的
presync
钩子完成此操作——这与社区示例
raymondk/demo-ic-architecture
演示的模式相同。

Before Layer 1: The Operator Must Accept the ICP MCP App Operator Terms

第 1 层之前:运营方必须接受 ICP MCP App Operator Terms

Stop here before you create, generate, or deploy
/.well-known/ic-architecture
.
That file is not only configuration. Availability through ICP MCP is governed by the ICP MCP App Operator Terms — version 1.1, effective 2026-09-02, the version current when this skill was written — an agreement between DFINITY Stiftung (the "DFINITY Foundation") and the app's operator — and publishing a valid manifest is, on its own, the act that accepts them and opts the app in. No signature step, no checkbox, nothing further. An agent that adds the manifest to a build on its own initiative has entered its user into a contract without asking.
Name that version to the user: it is what they are accepting. Check the top of the terms page before you do — the terms are versioned independently of this skill (section 14), so if the page shows a version later than the one above, the page is right and this skill is stale. Tell the user the version the page shows, and say the skill's copy is out of date so it gets fixed.
Do not publish until the user has confirmed both points below. Put them in your own words, link the terms, and let the user read before they answer.
1. They are the operator, or authorized to bind it. The operator is the person or entity legally authorized to operate the app and declare its canisters. Building the app is not the same as operating it — section 1: "If you develop an application but do not operate it, these Terms are for its operator to accept, not you." A contractor, agency, or employee on someone else's app routes the decision to the operator rather than publishing and moving on.
2. They accept what publishing permits. Under section 2, participation lets the ICP MCP server, acting for users who have authorized their AI assistant through Internet Identity:
  • read the manifest, the
    candid:service
    metadata of the canisters the manifest declares, and what
    getApiDoc
    /
    get_api_doc
    returns;
  • index and cache that metadata, and describe the app and its API to assistants and their users, including in any public listing of participating apps;
  • submit query calls and, for users who authorized actions, state-changing (update) calls to those declared canisters, signed with the per-application Internet Identity identities of those users; and
  • fetch the app's published files from its origin to keep the above current.
Participation is free in both directions: DFINITY charges nothing for it and owes nothing for it.
在创建、生成或部署
/.well-known/ic-architecture
之前,请先停在这里。
该文件不只是配置。通过 ICP MCP 提供的服务受 ICP MCP App Operator Terms 约束——版本 1.1,生效日期为 2026-09-02,这是编写本 skill 时的当前版本。该协议由 DFINITY Stiftung(“DFINITY Foundation”)与应用运营方签订,并且仅发布有效清单这一行为本身就会接受协议并使应用加入其中。没有签名步骤、没有复选框,也不需要其他操作。AI Agent 如果擅自将清单加入构建,就等于未经询问便让用户订约。
必须向用户说明该版本,因为这是用户将要接受的内容。操作前请查看条款页面顶部——条款独立于此 skill 进行版本管理(见第 14 条),因此,如果页面显示的版本晚于上述版本,应以页面为准,并说明本 skill 中的版本已过期,需要予以修正。请告知用户页面实际显示的版本,并说明本 skill 的内容已过时,以便进行修正。
在用户确认以下两点之前,请勿发布。 请用自己的话说明这两点,附上条款链接,并让用户阅读后再作答复。
1. 用户是运营方,或有权代表运营方作出约束性决定。 运营方是依法有权运营应用并声明其 canister 的个人或实体。开发应用并不等于运营应用——第 1 条规定:“如果你开发某个应用但不负责运营它,则应由其运营方而非你接受这些条款。”如果承包商、代理机构或员工处理的是他人的应用,应将决定交由运营方作出,而不是自行发布后继续推进。
2. 用户接受发布清单所允许的行为。 根据第 2 条,参与后,ICP MCP 服务器可以代表已通过 Internet Identity 授权其 AI 助手的用户执行以下操作:
  • 读取清单、清单所声明 canister 的
    candid:service
    元数据
    ,以及
    getApiDoc
    /
    get_api_doc
    返回的内容;
  • 索引并缓存这些元数据,并向助手及其用户描述该应用及其 API,包括在参与应用的任何公开列表中展示;
  • 向已声明的 canister 提交查询调用;对于已授权执行操作的用户,还可提交改变状态的(update)调用,并使用这些用户的按应用划分的 Internet Identity 身份进行签名;
  • 从应用的源站获取已发布文件,以保持上述内容保持最新。
参与在两个方向上均免费:DFINITY 不收取费用,也不承担费用。

The manifest is the switch, and it is the whole scope

清单既是开关,也决定了完整的参与范围

  • Only declared canisters are in scope. ICP MCP retrieves canister metadata and submits query or update calls only to canisters listed in a valid manifest. Never list a canister the operator does not run or is not entitled to expose — section 5 is a standing representation, repeated every time the file is served, that every declared canister is operated by the operator or under their authority.
  • Without a valid manifest, none of that happens. ICP MCP may still fetch and describe the app's public website, but metadata retrieval and canister calls are refused.
  • Removing the manifest is the off switch — registered or not. Once ICP MCP observes the removal, new metadata reads and query/update calls stop; this is also the fastest mitigation if the origin or a declared canister is compromised (section 7). It does not stop ICP MCP fetching the public website or describing public information; for that, ask DFINITY to suspend participation at
    mcp@dfinity.org
    .
  • Deactivating is not terminating. Removing the manifest ends participation; ending the agreement is a separate act — notice to
    mcp@dfinity.org
    (section 11). Neither undoes calls already executed on the Internet Computer, and sections 8, 12, 13 and 15 (personal data, warranties, liability, governing law) survive termination. Tell an operator asking how to get out both halves, not just the file deletion.
  • Keeping the manifest published is continuing acceptance, including of an updated version of the terms. An operator who does not accept a new version ends participation before it takes effect.
  • 只有已声明的 canister 属于参与范围。 ICP MCP 仅会向有效清单中列出的 canister 获取 canister 元数据并提交查询或 update 调用。绝不列出运营方不运营或无权公开的 canister——第 5 条是一项持续性陈述,每次提供该文件时都会再次确认:每个已声明的 canister 均由运营方运营或处于其授权之下。
  • 没有有效清单,就不会发生上述任何行为。 ICP MCP 仍可能获取并描述应用的公开网站,但元数据检索和 canister 调用会被拒绝。
  • 移除清单就是关闭开关——无论应用此前是否注册。一旦 ICP MCP 发现清单被移除,新的元数据读取及查询/update 调用便会停止;如果源站或某个已声明的 canister 遭到入侵,这也是最快的缓解措施(第 7 条)。但这不会阻止 ICP MCP 获取公开网站或描述公开信息;若需停止这些行为,请联系
    mcp@dfinity.org
    申请暂停参与。
  • 停用不等于终止。 移除清单会结束参与;终止协议则是另一项独立操作——需向
    mcp@dfinity.org
    发出通知(第 11 条)。两者都不会撤销此前已在 Internet Computer 上执行的调用;第 8、12、13 和 15 条(个人数据、保证、责任和适用法律)在终止后仍然有效。如果运营方询问如何退出,应告知其需要同时处理这两部分,而不能只删除文件。
  • 持续发布清单即表示持续接受协议,其中也包括接受更新后的条款版本。如果运营方不接受新版本,应在新版本生效前结束参与。

Registration is optional

注册是可选的

Registration is not a condition of participation and is not what opts the app in — the manifest already did that. It exists so DFINITY knows who the operator is: to reach them with the notices the terms provide for (sections 10, 11, 14), and to have a record of who accepted and of which version, which publication alone does not show.
To register, the operator emails
mcp@dfinity.org
with: the operator's legal name and country; the name, role, and email of the accepting representative; the app's origin domain(s); the canister IDs the manifest declares; the URL of the app's own privacy policy, so ICP MCP can present it to users considering the app; and the version of the terms being accepted — read from the top of the terms page at that moment, which is where section 3 says it is shown. The version named in Before Layer 1 is the one current when this skill was written; if the page disagrees, the page wins and its value is what goes in the email. Keep the registration current as any of those change.
注册不是参与的前提条件,也不是应用加入其中的方式——发布清单已经完成加入。注册的作用是让 DFINITY 知道运营方是谁,以便向其发送条款规定的通知(第 10、11、14 条),并记录由谁接受了哪个版本;仅凭发布行为无法看出这些信息。
如需注册,运营方应向
mcp@dfinity.org
发送电子邮件,内容包括:运营方的法定名称和所在国家;接受条款代表的姓名、职务和电子邮箱;应用的源站域名;清单中声明的 canister ID;应用自身隐私策略的 URL,以便 ICP MCP 向正在考虑使用该应用的用户展示;以及所接受条款的版本——该版本应读取自当时条款页面顶部,第 3 条正是要求在此显示版本。第 1 层之前章节所列版本是编写本 skill 时的当前版本;如果页面不一致,应以页面为准,并在邮件中填写页面显示的版本。任何相关信息发生变化时,都应保持注册信息同步更新。

Obligations that outlive the deploy

部署后仍持续存在的义务

These bind for as long as the manifest is published, so raise them with the user while the app is being made discoverable, not after:
  • Accuracy (section 6). The manifest, the Candid interface, and the
    getApiDoc
    text must identify the app correctly, describe what each method actually does, and stay in sync as the app changes. Never present a state-changing method as read-only or harmless, and never conceal a fee or transfer it performs.
  • No assistant manipulation (section 6). Published metadata and API docs describe the API and nothing more — no instructions telling the assistant to ignore its user, change its safety behavior, exfiltrate data, or avoid or disparage other apps. A hard constraint on
    getApiDoc
    content.
  • Security (section 7). The operator is responsible for control of the origin, the canisters' security and upgrade paths, and the integrity of the discoverability files.
  • Personal data (section 8). Requests reaching the app carry personal data — call arguments, per-application identities, and whatever the canisters return. Each party is an independent controller; the operator handles that data lawfully and keeps an accurate privacy policy available to the app's users. The ICP MCP Privacy Policy covers what ICP MCP discloses to the app, not what the app then does with it.
只要清单持续发布,这些义务就一直有效,因此应在使应用具备可发现性的过程中告知用户,而不能等到部署完成后再处理:
  • 准确性(第 6 条)。 清单、Candid 接口和
    getApiDoc
    文本必须正确标识应用,描述每个方法的实际行为,并随应用变化保持同步。绝不把改变状态的方法描述为只读或无害,也绝不隐瞒其收取的费用或执行的转账。
  • 不得操纵助手(第 6 条)。 已发布的元数据和 API 文档只能描述 API,不得包含要求助手忽略用户、改变安全行为、外泄数据或回避、贬低其他应用的指令。这是对
    getApiDoc
    内容的硬性约束。
  • 安全(第 7 条)。 运营方负责控制源站、canister 的安全及升级路径,以及可发现性文件的完整性。
  • 个人数据(第 8 条)。 到达应用的请求会携带个人数据——调用参数、按应用划分的身份,以及 canister 返回的任何内容。各方均为独立的数据控制者;运营方须依法处理这些数据,并确保向应用用户提供准确的隐私策略。ICP MCP Privacy Policy 涵盖 ICP MCP 会向应用披露哪些内容,但不包括应用随后如何处理这些数据。

Prerequisites

前置条件

  • icp-cli
    and
    ic-wasm
    , installed together:
    npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
    . See the
    icp-cli
    skill.
  • The frontend deployed with the
    @dfinity/static-site
    recipe (the recommended way to host a frontend on the IC — see the
    static-site
    skill). This is what auto-serves
    /.well-known/
    files and runs the
    presync
    hook with deployed canister IDs available.
  • envsubst
    (from GNU gettext) for templating the manifest. Any other templating mechanism works too (a small Node/
    jq
    script);
    envsubst
    is just the simplest.
  • icp-cli
    和
    ic-wasm
    需一起安装:
    npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
    。参见
    icp-cli
    skill。
  • 前端使用
    @dfinity/static-site
    recipe 部署(在 IC 上托管前端的推荐方式;参见
    static-site
    skill)。该 recipe 会自动提供
    /.well-known/
    文件,并在已部署 canister ID 可用时运行
    presync
    钩子。
  • envsubst
    (GNU gettext 提供)用于为清单模板化。其他模板机制也可以使用,例如一个小型 Node/
    jq
    脚本;
    envsubst
    只是最简单的选择。

Layer 1: Composition — the
ic-architecture
manifest

第 1 层:组成——
ic-architecture
清单

Gated. Publishing this file opts the app into ICP MCP and accepts the ICP MCP App Operator Terms on the operator's behalf. Confirm with the operator first — see Before Layer 1 above.
Publish a JSON document at the origin's
/.well-known/ic-architecture
that lists every canister and its role:
json
{
  "version": "1.0.0",
  "canisters": [
    {
      "id": "hcv4s-uaaaa-aaabq-qaaba-cai",
      "name": "frontend",
      "role": "the frontend"
    },
    {
      "id": "hmxr2-pqaaa-aaabq-qaaaa-cai",
      "name": "backend",
      "role": "the backend",
      "description": "orders + inventory API; call getApiDoc() first"
    }
  ]
}
Field rules:
  • version
    — the manifest schema version.
  • id
    — required, a canister principal.
  • name
    ,
    role
    — human-readable labels;
    description
    is optional. These fields are untrusted, so a consumer sanitizes them before use.
  • Unknown fields must be ignored, so the format can grow (e.g. per-canister network hints, or an api-doc pointer) without breaking older readers.
设有准入门槛。 发布此文件会使应用加入 ICP MCP,并代表运营方接受 ICP MCP App Operator Terms。请先与运营方确认——参见上文 第 1 层之前。
在源站的
/.well-known/ic-architecture
发布一份 JSON 文档,列出每个 canister 及其角色:
json
{
  "version": "1.0.0",
  "canisters": [
    {
      "id": "hcv4s-uaaaa-aaabq-qaaba-cai",
      "name": "frontend",
      "role": "the frontend"
    },
    {
      "id": "hmxr2-pqaaa-aaabq-qaaaa-cai",
      "name": "backend",
      "role": "the backend",
      "description": "orders + inventory API; call getApiDoc() first"
    }
  ]
}
字段规则:
  • version
    ——清单 schema 版本。
  • id
    ——必填,canister principal。
  • name
    、
    role
    ——供人阅读的标签;
    description
    为可选字段。这些字段不受信任,因此消费者在使用前必须对其进行清理。
  • 必须忽略未知字段,以便格式未来可以扩展(例如增加按 canister 划分的网络提示或 API 文档指针),而不会破坏旧版读取器。

Generate it at deploy time (the
presync
pattern)

在部署时生成它(
presync
模式)

Canister IDs differ per network (local, staging, mainnet), so never commit hard-coded IDs. Produce the file in the deploy pipeline, which already knows the IDs. With the
@dfinity/static-site
recipe this is the
presync
hook: it runs at sync time, after the canisters exist, so their IDs are resolvable.
frontend/canister.yaml
(the per-canister config referenced from your top-level
icp.yaml
; see the
static-site
skill for the project layout):
yaml
name: frontend
recipe:
  type: "@dfinity/static-site@v0.4.3"
  configuration:
    build:
      # Runs BEFORE the canister exists — no canister IDs available here.
      - npm ci
      - npm run build
    presync:
      # Runs AFTER canisters exist, with each canister's ID exported as ICP_CLI_CID_<NAME>.
      - mkdir -p dist/.well-known
      - envsubst < ic-architecture/tmpl."$ICP_CLI_ENVIRONMENT".json > dist/.well-known/ic-architecture
    dir: dist
  • The static-site recipe exports each project canister's ID into
    presync
    as
    ICP_CLI_CID_<NAME>
    (name upper-cased, non-alphanumerics →
    _
    ; e.g.
    backend
    →
    ICP_CLI_CID_BACKEND
    ). Other vars:
    ICP_CLI_CID
    (this canister),
    ICP_CLI_NETWORK
    .
  • $ICP_CLI_ENVIRONMENT
    is the environment being deployed (e.g.
    local
    ,
    ic
    ), exported into the
    presync
    shell. It selects the matching template, so the same hook serves every network.
  • presync
    runs with the canister directory as its working directory.
    The relative
    ic-architecture/...
    path therefore resolves inside the frontend canister directory — put the templates at
    frontend/ic-architecture/
    , alongside
    canister.yaml
    (as the example project does). A path resolved from the repo root instead would make
    envsubst
    read nothing and silently write an empty manifest (Pitfall 7).
  • Pin the recipe to the current release (
    @dfinity/static-site@v0.4.3
    here); check the static-site recipe releases and the
    static-site
    skill for the latest.
Keep one template per environment under
frontend/ic-architecture/
, with
envsubst
placeholders for the IDs.
frontend/ic-architecture/tmpl.local.json
:
json
{
  "version": "1.0.0",
  "canisters": [
    { "id": "${ICP_CLI_CID_FRONTEND}", "name": "frontend", "role": "the frontend" },
    { "id": "${ICP_CLI_CID_BACKEND}", "name": "backend", "role": "the backend", "description": "orders + inventory API; call getApiDoc() first" }
  ]
}
frontend/ic-architecture/tmpl.ic.json
(mainnet) is the same shape; only fixed fields like a static external dependency would differ.
Alternative — the reference demo's form.
raymondk/demo-ic-architecture
resolves the IDs explicitly with
icp canister status
rather than the exported vars — useful if you need an ID the recipe does not export. Its
presync
is:
yaml
    presync:
      - mkdir -p dist/.well-known
      - >-
        FRONTEND_ID=$(icp canister status frontend --id-only -e "$ICP_CLI_ENVIRONMENT")
        BACKEND_ID=$(icp canister status backend --id-only -e "$ICP_CLI_ENVIRONMENT")
        envsubst < ic-architecture/tmpl."$ICP_CLI_ENVIRONMENT".json > dist/.well-known/ic-architecture
with the template using
${FRONTEND_ID}
/
${BACKEND_ID}
instead.
icp canister status <name> --id-only -e <env>
prints just the canister ID (there is no
icp canister id
command).
canister ID 会因网络而异(本地、预发布、主网),因此绝不提交硬编码 ID。应在已经掌握这些 ID 的部署流水线中生成文件。使用
@dfinity/static-site
recipe 时,对应的机制就是
presync
钩子:它在同步时运行,即在 canister 已经创建之后,因此可以解析它们的 ID。
frontend/canister.yaml
(顶层
icp.yaml
引用的按 canister 配置文件;项目结构参见
static-site
skill):
yaml
name: frontend
recipe:
  type: "@dfinity/static-site@v0.4.3"
  configuration:
    build:
      # Runs BEFORE the canister exists — no canister IDs available here.
      - npm ci
      - npm run build
    presync:
      # Runs AFTER canisters exist, with each canister's ID exported as ICP_CLI_CID_<NAME>.
      - mkdir -p dist/.well-known
      - envsubst < ic-architecture/tmpl."$ICP_CLI_ENVIRONMENT".json > dist/.well-known/ic-architecture
    dir: dist
  • static-site recipe 会将每个项目 canister 的 ID 导出到
    presync
    中,变量名为
    ICP_CLI_CID_<NAME>
    (名称转为大写,非字母数字字符替换为
    _
    ;例如
    backend
    →
    ICP_CLI_CID_BACKEND
    )。其他变量包括:
    ICP_CLI_CID
    (当前 canister)和
    ICP_CLI_NETWORK
    。
  • $ICP_CLI_ENVIRONMENT
    表示正在部署的环境(例如
    local
    、
    ic
    ),并被导出到
    presync
    shell。它用于选择匹配的模板,因此同一钩子可以服务所有网络。
  • presync
    以 canister 目录作为工作目录运行。
    因此,relative
    ic-architecture/...
    路径会在 frontend canister 目录内解析——应将模板放在
    frontend/ic-architecture/
    中,与
    canister.yaml
    放在一起(参考示例项目)。如果从仓库根目录解析路径,
    envsubst
    将读不到任何内容,并静默写入空清单(参见陷阱 7)。
  • 将 recipe 固定到当前发行版(此处为
    @dfinity/static-site@v0.4.3
    );请检查 static-site recipe 的发行版以及
    static-site
    skill,以获取最新版本。
在
frontend/ic-architecture/
下为每个环境保留一个模板,并使用
envsubst
占位符表示 ID。
frontend/ic-architecture/tmpl.local.json
:
json
{
  "version": "1.0.0",
  "canisters": [
    { "id": "${ICP_CLI_CID_FRONTEND}", "name": "frontend", "role": "the frontend" },
    { "id": "${ICP_CLI_CID_BACKEND}", "name": "backend", "role": "the backend", "description": "orders + inventory API; call getApiDoc() first" }
  ]
}
frontend/ic-architecture/tmpl.ic.json
(主网)采用相同结构;通常只有静态外部依赖等固定字段会有所不同。
替代方案——参考 demo 的形式。
raymondk/demo-ic-architecture
使用
icp canister status
显式解析 ID,而不是使用导出的变量——如果需要某个 recipe 未导出的 ID,这种方式会很有用。其
presync
如下:
yaml
    presync:
      - mkdir -p dist/.well-known
      - >-
        FRONTEND_ID=$(icp canister status frontend --id-only -e "$ICP_CLI_ENVIRONMENT")
        BACKEND_ID=$(icp canister status backend --id-only -e "$ICP_CLI_ENVIRONMENT")
        envsubst < ic-architecture/tmpl."$ICP_CLI_ENVIRONMENT".json > dist/.well-known/ic-architecture
相应模板使用
${FRONTEND_ID}
/
${BACKEND_ID}
。
icp canister status <name> --id-only -e <env>
只输出 canister ID(不存在
icp canister id
命令)。

Serve it correctly

正确提供文件

  • .well-known/
    is uploaded automatically
    by the static-site recipe (it traverses
    .well-known/
    even though it skips other dotfiles). A file at
    dist/.well-known/ic-architecture
    is served at
    /.well-known/ic-architecture
    with no extra config — no
    .ic-assets.json5
    , no SPA-exemption rule.
  • A real file beats the SPA fallback. With the static-site
    /*  /index.html  200
    rewrite, the manifest is a real file, so it is served directly; the rewrite only catches paths with no matching file. (The legacy
    @dfinity/asset-canister
    resolves the same way — its
    index.html
    fallback likewise fires only when no file matches — but there the manifest has to be uploaded in the first place:
    .ic-assets.json5
    needs
    { "match": ".well-known", "ignore": false }
    , or the hidden directory never ships. On a non-IC host, check that host's own routing precedence; where rewrites shadow real files, exempt
    /.well-known/*
    .)
  • Set the content type. Extensionless files do not get
    application/json
    automatically. Add a
    _headers
    file (at the root of
    dir
    , e.g. via
    public/_headers
    ) so the manifest is served as JSON:
text
/.well-known/ic-architecture
  Content-Type: application/json
See the
static-site
skill for
_headers
/
_redirects
details.
  • .well-known/
    会由 static-site recipe 自动上传
    (它会遍历
    .well-known/
    ,即使会跳过其他点文件)。位于
    dist/.well-known/ic-architecture
    的文件会通过
    /.well-known/ic-architecture
    提供,无需额外配置——不需要
    .ic-assets.json5
    ,也不需要 SPA 豁免规则。
  • 真实文件优先于 SPA 回退。 使用 static-site 的
    /*  /index.html  200
    重写规则时,清单是真实文件,因此会直接提供;该重写只会处理没有匹配文件的路径。(旧版
    @dfinity/asset-canister
    的解析方式相同——其
    index.html
    回退同样仅在没有文件匹配时触发——但必须先上传清单:
    .ic-assets.json5
    需要包含
    { "match": ".well-known", "ignore": false }
    ,否则隐藏目录不会随应用发布。在非 IC 主机上,应检查该主机自身的路由优先级;如果重写规则会遮蔽真实文件,则需豁免
    /.well-known/*
    。)
  • 设置 content type。 无扩展名文件不会自动获得
    application/json
    。请在
    dir
    根目录添加
    _headers
    文件(例如通过
    public/_headers
    ),使清单以 JSON 形式提供:
text
/.well-known/ic-architecture
  Content-Type: application/json
有关
_headers
/
_redirects
的详细信息,请参见
static-site
skill。

Layer 2: Interface —
candid:service

第 2 层:接口——
candid:service

Expose your Candid interface as the canister's public
candid:service
metadata — the standard IC mechanism, embedded by default by the
@dfinity/motoko
and
@dfinity/rust
recipes. It lets an agent fetch exact method signatures and types and encode/decode calls correctly. Do not strip it from the build.
An agent (or you, to verify) fetches it with:
bash
undefined
将 Candid 接口公开为 canister 的
candid:service
公共元数据——这是标准的 IC 机制,
@dfinity/motoko
和
@dfinity/rust
recipe 默认会嵌入该元数据。它允许 Agent 获取精确的方法签名和类型,并正确编码和解码调用。不要在构建过程中将其移除。
Agent(或你本人进行验证)可以使用以下命令获取:
bash
undefined

By raw canister ID against mainnet (the agent's case: no project context) — target the network.

By raw canister ID against mainnet (the agent's case: no project context) — target the network.

icp canister metadata <BACKEND_ID> candid:service --network ic
icp canister metadata <BACKEND_ID> candid:service --network ic

By canister name from inside a project — use the project environment instead.

By canister name from inside a project — use the project environment instead.

icp canister metadata backend candid:service -e ic
undefined
icp canister metadata backend candid:service -e ic
undefined

Layer 3: Behavior —
getApiDoc

第 3 层:行为——
getApiDoc

Candid types describe shape, not behavior. Expose a query method returning a prose (markdown) guide to what an agent cannot infer from types. Name it so it appears in
candid:service
— an agent then finds it with zero out-of-band knowledge (no bootstrap hint or side channel).
Motoko:
motoko
persistent actor {
  public query func getApiDoc() : async Text {
    "## Orders API\n\n" #
    "- **Units:** amounts are integers scaled by 10^8 (1 unit = 1e-8).\n" #
    "- **Auth:** `placeOrder` requires a signed principal; anonymous callers can only read.\n" #
    "- **Lifecycle:** `placeOrder` returns before settlement; poll `orderStatus` until `#done`.\n" #
    "- **Irreversible:** `cancelOrder` cannot be undone; `closeAccount` is a dead-man switch.\n"
  };
};
Rust (
ic-cdk
):
rust
#[ic_cdk::query]
fn get_api_doc() -> String {
    // Same content; the snake_case name get_api_doc is equally discoverable.
    "## Orders API\n\n- Units: amounts are integers scaled by 10^8 ...".to_string()
}
Cover the non-obvious semantics: units and encoding (integer money scaled by
10^8
, fractions vs tenth-bps, timestamp units), which calls need a signed principal and how anonymous access differs, staged or asynchronous operations that return before completing and must be polled, what is irreversible and any dead-man switches, and the gotchas that routinely trip up new integrators.
Once the app participates in ICP MCP, section 6 of the App Operator Terms constrains this text: it must not present a state-changing method as read-only or harmless or conceal a fee it charges, and it must describe the API only — never instructing the calling assistant to ignore its user, change its safety behavior, exfiltrate data, or disparage other apps. An agent acts on what
getApiDoc
returns, so prompt-injection-shaped content there is a breach, not a feature.
Candid 类型只能描述结构,不能描述行为。应公开一个 query 方法,返回一份 prose(markdown)指南,用于说明 Agent 无法从类型中推断的信息。该方法名称必须出现在
candid:service
中,这样 Agent 无需任何带外知识即可找到它(既不需要 bootstrap 提示,也不需要旁路渠道)。
Motoko:
motoko
persistent actor {
  public query func getApiDoc() : async Text {
    "## Orders API\n\n" #
    "- **Units:** amounts are integers scaled by 10^8 (1 unit = 1e-8).\n" #
    "- **Auth:** `placeOrder` requires a signed principal; anonymous callers can only read.\n" #
    "- **Lifecycle:** `placeOrder` returns before settlement; poll `orderStatus` until `#done`.\n" #
    "- **Irreversible:** `cancelOrder` cannot be undone; `closeAccount` is a dead-man switch.\n"
  };
};
Rust(
ic-cdk
):
rust
#[ic_cdk::query]
fn get_api_doc() -> String {
    // Same content; the snake_case name get_api_doc is equally discoverable.
    "## Orders API\n\n- Units: amounts are integers scaled by 10^8 ...".to_string()
}
应涵盖不直观的语义:单位及编码方式(按
10^8
缩放的整数金额、分数与十分之一基点、时间戳单位)、哪些调用需要已签名的 principal 以及匿名访问有何差异、分阶段或异步操作会在完成前返回且必须轮询、哪些操作不可撤销、是否存在 dead-man switch,以及经常使新集成方陷入困惑的各种注意事项。
应用参与 ICP MCP 后,App Operator Terms 第 6 条会约束此文本:不得把改变状态的方法描述为只读或无害,不得隐瞒其收取的费用,并且只能描述 API——绝不能指示调用方助手忽略用户、改变安全行为、外泄数据或贬低其他应用。Agent 会按照
getApiDoc
返回的内容采取行动,因此在那里植入类似 prompt injection 的内容属于违规,而不是功能特性。

Layer 4: Data — OQL (optional, for data-rich apps)

第 4 层:数据——OQL(可选,适合数据丰富的应用)

For apps with a lot of queryable data, expose a self-describing query surface so an agent can answer open-ended questions without you writing a method per question. OQL is one such convention — two query methods that speak JSON-in-text:
candid
schema  : ()     -> (text)   query;  // JSON catalogue: entities, fields, edges
execute : (text) -> (Result) query;  // one JSON query object -> paged rows
schema
returns a JSON catalogue of entities, their fields (with types and roles), and the edges between them; an agent fetches it once.
execute
runs one JSON query object (filters, aggregation, ordering, projection, paging) and returns a paged
Result
:
candid
type Cell   = record {
  name  : text;
  value : variant { text : text; int : int; float : float64; bool : bool };  // representative scalar arms; a given canister may tag others
};
type Result = record { hasMore : bool; rows : vec vec Cell };  // each row is a list of named cells
Agents read cells by name, never by position, and page while
hasMore
is true. Prefer server-side filtering and aggregation so only the needed data crosses into the agent's context. Any Candid interface works; OQL just makes open-ended questions more economical.
对于包含大量可查询数据的应用,应公开一个可自我描述的查询接口,使 Agent 无需针对每个问题编写单独方法,就能回答开放式问题。OQL 是一种约定——两个以文本形式承载 JSON 的查询方法:
candid
schema  : ()     -> (text)   query;  // JSON catalogue: entities, fields, edges
execute : (text) -> (Result) query;  // one JSON query object -> paged rows
schema
返回实体、字段(包含类型和角色)以及实体之间关系的 JSON 目录;Agent 只需获取一次。
execute
执行一个 JSON 查询对象(过滤、聚合、排序、投影、分页),并返回分页的
Result
:
candid
type Cell   = record {
  name  : text;
  value : variant { text : text; int : int; float : float64; bool : bool };  // representative scalar arms; a given canister may tag others
};
type Result = record { hasMore : bool; rows : vec vec Cell };  // each row is a list of named cells
Agent 应按名称读取 cell,绝不能按位置读取,并在
hasMore
为 true 时继续分页。优先在服务端执行过滤和聚合,这样只有必要的数据才会进入 Agent 的上下文。任何 Candid 接口都可以使用;OQL 只是让开放式问题处理起来更经济。

Layer 5: Identity —
ii-derivation-origin

第 5 层:身份——
ii-derivation-origin

To let an agent act with the user's own principal and permissions, publish the Internet Identity derivation origin your frontends pin. An agent that already holds the user's II authorization derives a short-lived, per-app delegation for that origin, yielding the same principal the user has in a browser — so your existing access control applies unchanged. (The agent/CLI side that consumes this is the
agent-web-identity
skill:
icp identity link web --app <domain>
.)
The principal a user gets is a function of three inputs:
  1. The user's Internet Identity.
  2. The account within that Internet Identity.
  3. Your app's derivation origin.
Only the third is under your app's control, which is why the app must declare it. The derivation origin defaults to the visible origin: the origin the user's agent was asked to act on (agentic flows) or the origin in the browser address bar (classical flows). Publishing the file matters when an app is reachable from more than one origin (e.g. a rebrand or a secondary frontend): the visible origin may then differ from the origin identities are derived for, and the file tells the agent which origin to request derivations for.
Publish, at each supported frontend origin,
/.well-known/ii-derivation-origin
whose body is the canonical
https://host
origin on a single line:
text
https://hcv4s-uaaaa-aaabq-qaaba-cai.icp.net
  • If the derivation origin is just the app's own visible origin, you may omit the file; its absence means "derive for the visible / requested origin itself."
  • Generate it at deploy time with the same
    presync
    pattern when the origin is a per-network canister URL; for a custom domain it is a one-line static file (e.g.
    public/.well-known/ii-derivation-origin
    ).
  • Do not confuse it with
    ii-alternative-origins
    .
    A custom origin is enabled by two coupled files: the app pins
    derivationOrigin
    in its II configuration, and the derivation origin itself publishes
    /.well-known/ii-alternative-origins
    listing the origins allowed to derive against it. That list is the inverse relation — "who may point here," not "where does this app point" (Pitfall 8). On the default
    *.icp0.io
    /
    ic0.app
    canister origins, do not set a custom
    derivationOrigin
    at all (see "Your app's identity is its primary origin" in the
    user-sign-in
    skill); a custom one goes hand in hand with a custom domain — see the
    custom-domains
    skill.
为了让 Agent 以用户自己的 principal 和权限采取行动,应发布前端所固定的 Internet Identity derivation origin。已经持有用户 II 授权的 Agent 会为该 origin 派生一个短期、按应用划分的 delegation,从而得到与用户在浏览器中相同的 principal——因此现有访问控制无需任何更改。(消费此信息的 Agent/CLI 端对应
agent-web-identity
skill:
icp identity link web --app <domain>
。)
用户获得的 principal 是以下三个输入共同决定的函数:
  1. 用户的 Internet Identity。
  2. 该 Internet Identity 中的账户。
  3. 应用的 derivation origin。
只有第三项由应用控制,因此应用必须声明它。derivation origin 默认是可见的 origin:即 Agent 被要求代为操作的 origin(Agent 流程),或浏览器地址栏中显示的 origin(传统流程)。当应用可通过多个 origin 访问时(例如品牌重塑或第二个前端),发布该文件就很重要:此时可见 origin 可能不同于实际用于派生身份的 origin,而该文件会告诉 Agent 应为哪个 origin 申请派生。
在每个受支持的前端 origin 发布
/.well-known/ii-derivation-origin
,其正文为单行的规范化
https://host
origin:
text
https://hcv4s-uaaaa-aaabq-qaaba-cai.icp.net
  • 如果 derivation origin 就是应用自身的可见 origin,可以省略该文件;文件不存在意味着“针对可见或请求的 origin 本身进行派生”。
  • 如果 origin 是按网络变化的 canister URL,请使用相同的
    presync
    模式在部署时生成;对于自定义域名,则使用单行静态文件(例如
    public/.well-known/ii-derivation-origin
    )。
  • 不要将其与
    ii-alternative-origins
    混淆。
    启用自定义 origin 需要两个相互关联的文件:应用在 II 配置中固定
    derivationOrigin
    ,同时 derivation origin 自身发布
    /.well-known/ii-alternative-origins
    ,列出允许针对该 origin 进行派生的 origins。该列表表示的是反向关系——“哪些 origin 可以指向这里”,而不是“此应用指向哪里”(参见陷阱 8)。在默认的
    *.icp0.io
    /
    ic0.app
    canister origin 上,不要设置自定义
    derivationOrigin
    (参见
    user-sign-in
    skill 中的“Your app's identity is its primary origin”);自定义 derivation origin 应与自定义域名搭配使用——参见
    custom-domains
    skill。

How an Agent Traverses This

Agent 的遍历方式

Published independently, the layers are consumed in one order — each step exists to let the agent skip work at the next:
  1. GET /.well-known/ic-architecture
    → every canister ID, and which one to call, from whichever labels identify it (
    name
    ,
    role
    ,
    description
    ).
  2. candid:service
    on that canister → exact signatures and types, plus the names
    getApiDoc
    /
    schema
    /
    execute
    , which is why those must live in the interface and not a side channel.
  3. getApiDoc()
    → the semantics the types cannot carry, including which calls need a signed principal.
  4. /.well-known/ii-derivation-origin
    , or the visible origin when absent → derive the user's delegation and act as the signed-in user, so existing access control applies unchanged.
  5. schema()
    once, then
    execute(...)
    per question, filtered and aggregated server-side.
The identity step is numbered 5 as a layer but happens before the first protected call: step 3 is where the agent learns which methods require a signed principal, so anything gated — a protected
execute
, or any update call — has to wait for the delegation. Only unauthenticated reads can run ahead of it.
Steps 1-3 take an agent from a bare URL to a correctly-encoded, correctly-understood call in three round trips. Each layer left unpublished replaces one of them with guessing — an unlabeled manifest alone costs a
candid:service
fetch per canister (Pitfall 10).
即使各层独立发布,Agent 仍会按固定顺序消费它们——每一步的存在,都是为了让 Agent 跳过下一步中的部分工作:
  1. GET /.well-known/ic-architecture
    → 获取所有 canister ID,以及根据
    name
    、
    role
    、
    description
    等标签判断应调用哪个 canister。
  2. 在该 canister 上获取
    candid:service
    → 获取精确签名和类型,以及
    getApiDoc
    /
    schema
    /
    execute
    这些名称;这正是它们必须存在于接口中、而不能放在旁路渠道中的原因。
  3. getApiDoc()
    → 获取类型无法承载的语义,包括哪些调用需要已签名的 principal。
  4. /.well-known/ii-derivation-origin
    ,或在文件不存在时使用可见 origin → 派生用户 delegation 并以已登录用户的身份操作,从而无需更改现有访问控制。
  5. 先调用一次
    schema()
    ,随后针对每个问题调用
    execute(...)
    ,并在服务端完成过滤和聚合。
身份步骤在层级中编号为第 5 步,但实际发生在第一次受保护的调用之前:第 3 步会让 Agent 得知哪些方法需要已签名的 principal,因此所有受限制的操作——例如受保护的
execute
或任何 update 调用——都必须等待 delegation 完成。只有无需认证的读取操作可以提前执行。
第 1 至第 3 步只需三次往返请求,就能让 Agent 从一个裸 URL 到达正确编码且正确理解的调用。任何未发布的层级,都会用猜测代替其中一步——仅有未加标签的清单,意味着每个 canister 都要额外获取一次
candid:service
(参见陷阱 10)。

Deployment Checklist

部署检查清单

  • Terms accepted: the app's operator — not a developer or agent acting for them — has read the ICP MCP App Operator Terms and confirmed, before the manifest ships. Publishing it is the acceptance; there is no separate step.
  • Registration (optional): if the operator wants notices and a record of who accepted which version, they email
    mcp@dfinity.org
    with the details in Before Layer 1, including the app's own privacy-policy URL.
  • Composition: the deploy pipeline emits
    /.well-known/ic-architecture
    (real JSON, extensionless path) with real per-environment canister IDs.
  • Content type: a
    _headers
    rule serves the manifest as
    application/json
    .
  • Reachability (non-static-site hosts only):
    /.well-known/ic-architecture
    actually resolves. Automatic on the static-site canister; on the legacy
    @dfinity/asset-canister
    the directory needs an
    .ic-assets.json5
    un-ignore rule to be uploaded at all; on a non-IC host, exempt
    /.well-known/*
    from the SPA catch-all if that host's rewrites shadow real files.
  • Interface:
    candid:service
    metadata is present (not stripped).
  • Behavior: the backend exposes
    getApiDoc
    /
    get_api_doc
    returning markdown.
  • Data (if applicable): data-rich canisters expose OQL
    schema
    +
    execute
    .
  • Identity (if custom): publish the effective origin in
    /.well-known/ii-derivation-origin
    (canonical
    https://host
    , one line).
  • 已接受条款: 应用的运营方——而不是开发者或代其行动的 Agent——已经阅读 ICP MCP App Operator Terms,并在清单发布前作出确认。发布清单即表示接受条款,不存在单独步骤。
  • 注册(可选): 如果运营方希望接收通知并留存由谁接受哪个版本的记录,应按照 第 1 层之前章节中的要求向
    mcp@dfinity.org
    发送详细信息,其中包括应用自身的隐私策略 URL。
  • 组成: 部署流水线会生成
    /.well-known/ic-architecture
    (真实 JSON、无扩展名路径),其中包含各环境真实的 canister ID。
  • Content type:
    _headers
    规则会将清单以
    application/json
    提供。
  • 可达性(仅非 static-site 主机):
    /.well-known/ic-architecture
    确实可以解析。在 static-site canister 上自动生效;在旧版
    @dfinity/asset-canister
    上,需要通过
    .ic-assets.json5
    的 un-ignore 规则才能上传目录;在非 IC 主机上,如果重写规则会遮蔽真实文件,则需将
    /.well-known/*
    从 SPA catch-all 中豁免。
  • 接口: 存在
    candid:service
    元数据(未被移除)。
  • 行为: 后端公开返回 markdown 的
    getApiDoc
    /
    get_api_doc
    。
  • 数据(如适用): 数据丰富的 canister 公开 OQL
    schema
    +
    execute
    。
  • 身份(如使用自定义 origin): 在
    /.well-known/ii-derivation-origin
    发布生效的 origin(规范化
    https://host
    ,单行格式)。

Verify (Acceptance Tests)

验证(验收测试)

Run against the deployed origin (
APP
= your frontend host):
bash
undefined
针对已部署的源站运行以下测试(
APP
= 前端主机):
bash
undefined

1. Manifest is real JSON listing the canisters (not the SPA shell).

1. Manifest is real JSON listing the canisters (not the SPA shell).

curl -s https://APP/.well-known/ic-architecture | jq '.canisters[].id'
curl -s https://APP/.well-known/ic-architecture | jq '.canisters[].id'

2. Backend exposes candid:service; fetch it against a canister ID from step 1

2. Backend exposes candid:service; fetch it against a canister ID from step 1

(confirm it declares getApiDoc, plus schema/execute if data-rich).

(confirm it declares getApiDoc, plus schema/execute if data-rich).

icp canister metadata <BACKEND_ID> candid:service --network ic
icp canister metadata <BACKEND_ID> candid:service --network ic

3. If you pin a CUSTOM derivation origin, it is published as the canonical

3. If you pin a CUSTOM derivation origin, it is published as the canonical

https://host. Use -f so a 404 is an error and the fallback fires: curl -s

https://host. Use -f so a 404 is an error and the fallback fires: curl -s

alone exits 0 on 404, so the "default" branch would never run.

alone exits 0 on 404, so the "default" branch would never run.


Locally, the static-site recipe serves the same paths — e.g. `curl http://frontend.local.localhost:8000/.well-known/ic-architecture`.

在本地,static-site recipe 会提供相同的路径——例如 `curl http://frontend.local.localhost:8000/.well-known/ic-architecture`。

Pitfalls

陷阱

  1. Hard-coding canister IDs. IDs differ per network, so committing them ships a manifest that is wrong on every environment but the one it was written for. Generate at deploy time in
    presync
    .
  2. Putting ID resolution in
    build
    instead of
    presync
    .
    build
    runs before the canisters exist, so no IDs are available (
    ICP_CLI_CID_*
    are unset and
    icp canister status
    has nothing to return). Only
    presync
    runs after creation with IDs available.
  3. Assuming the manifest is served, without setting its content type. The extensionless file is served, but not as
    application/json
    unless a
    _headers
    rule says so. Add the
    Content-Type: application/json
    block above.
  4. Expecting
    .ic-assets.json5
    to matter.
    That is the legacy asset canister's config; the static-site (certified-assets) canister ignores it.
    .well-known/
    is uploaded automatically and needs no un-ignore rule. The legacy canister is the reverse: it needs
    { "match": ".well-known", "ignore": false }
    or the directory is never deployed — an upload problem, not a routing one.
  5. Writing the file with a
    .json
    extension.
    The path is exactly
    /.well-known/ic-architecture
    (and
    /.well-known/ii-derivation-origin
    ) — no extension, matching the IC
    .well-known
    convention (
    ic-domains
    ,
    ii-alternative-origins
    ).
  6. envsubst
    clobbering unintended
    ${...}
    .
    With no arguments
    envsubst
    substitutes every environment variable it finds. If a template contains a
    ${...}
    you do not want replaced, restrict it:
    envsubst '$ICP_CLI_CID_FRONTEND $ICP_CLI_CID_BACKEND'
    .
  7. A missing
    tmpl.<env>.json
    , or templates in the wrong directory.
    $ICP_CLI_ENVIRONMENT
    selects the template by name; if the file for the current environment is absent — or lives at the repo root while
    presync
    runs from the canister directory —
    envsubst
    reads nothing and writes an empty manifest. Keep one template per environment, under the frontend canister directory.
  8. Reading
    ii-alternative-origins
    to find the derivation origin.
    It is the inverse relation (who may derive against this origin), not a pointer to it. There is no reverse lookup; using it backwards silently yields the wrong principal — a plausible wrong answer, not an error. Publish and read
    ii-derivation-origin
    for the forward fact.
  9. Naming the behavior method undiscoverably. The name must appear in
    candid:service
    , so use
    getApiDoc
    /
    get_api_doc
    . A method reachable only via an out-of-band hint defeats zero-knowledge discovery.
  10. Listing canisters without labels that identify them.
    id
    is the only required field, so a manifest of bare IDs is valid, and it still earns its keep: the agent gets the app's canisters without discovering them out of band. What it loses is the routing — with nothing to tell the backend from the frontend, the agent pays a
    candid:service
    fetch per entry and infers roles from method names. Label every entry with whatever identifies it (
    name
    is often enough; add
    role
    , and
    description
    where the purpose is not obvious from the name).
  11. Stripping
    candid:service
    .
    Some minified/size-optimized builds drop wasm metadata. Keep it — it is what makes the interface fetchable. Verify with
    icp canister metadata <id> candid:service --network ic
    .
  12. Publishing the manifest without asking the operator. The likeliest agent failure here is treating
    /.well-known/ic-architecture
    as ordinary build config and adding it unprompted. It is the act that accepts the ICP MCP App Operator Terms and opts the app into query and update calls from AI assistants. Confirm with the user first, and confirm they are the operator — section 1 says a developer who does not operate the app cannot accept for its operator.
  13. Mistaking registration for the opt-in, or for the opt-out. Registration is optional and changes nothing about participation: an unregistered app whose manifest is published is fully participating and fully bound. Registration only tells DFINITY who accepted, which version, and where to send notices. Symmetrically, there is nothing to "unregister" to stop participating — removing the manifest is the off switch. Removing it deactivates participation; terminating the agreement is a separate act, a notice to
    mcp@dfinity.org
    (section 11). Neither undoes calls already executed on the Internet Computer, and sections 8, 12, 13 and 15 — personal data, warranties, liability and governing law — survive termination. "Delete the file and you are done" is wrong, not merely incomplete.
  14. Expecting manifest removal to delist the app entirely. Deleting it stops new metadata reads and query/update calls once ICP MCP observes the removal, but ICP MCP may still fetch the app's public website and describe publicly available information. To be dropped from user-facing presentation, the operator asks DFINITY at
    mcp@dfinity.org
    .
  15. Declaring canisters the operator does not control. It is tempting to list a third-party ledger or an ecosystem canister the app merely calls. Serving the manifest is a repeated representation (section 5) that every declared canister is operated by the operator or under their authority, and it makes those canisters eligible for update calls under the app's participation. List only your own.
  1. 硬编码 canister ID。 ID 会因网络而异,因此提交硬编码值会导致清单在除编写时所用环境之外的所有环境中都错误。应在
    presync
    中于部署时生成。
  2. 把 ID 解析放在
    build
    而不是
    presync
    中。
    build
    在 canister 创建之前运行,因此无法获得 ID(
    ICP_CLI_CID_*
    未设置,
    icp canister status
    也没有内容可返回)。只有
    presync
    会在创建后运行,并提供可用 ID。
  3. 假定清单会被提供,却未设置 content type。 无扩展名文件会被提供,但除非
    _headers
    规则指定,否则不会使用
    application/json
    。请添加上面的
    Content-Type: application/json
    配置块。
  4. 以为
    .ic-assets.json5
    会起作用。
    那是旧版 asset canister 的配置;static-site(certified-assets)canister 会忽略它。
    .well-known/
    会自动上传,不需要 un-ignore 规则。旧版 canister 的情况恰好相反:需要
    { "match": ".well-known", "ignore": false }
    ,否则该目录永远不会被部署——这是上传问题,而不是路由问题。
  5. 给文件添加
    .json
    扩展名。
    路径必须严格为
    /.well-known/ic-architecture
    (以及
    /.well-known/ii-derivation-origin
    ),不能带扩展名,以符合 IC 的
    .well-known
    约定(
    ic-domains
    、
    ii-alternative-origins
    )。
  6. envsubst
    替换了非预期的
    ${...}
    。
    不带参数调用
    envsubst
    时,它会替换找到的每一个环境变量。如果模板包含不应替换的
    ${...}
    ,请限制替换范围:
    envsubst '$ICP_CLI_CID_FRONTEND $ICP_CLI_CID_BACKEND'
    。
  7. 缺少
    tmpl.<env>.json
    ,或模板目录错误。
    $ICP_CLI_ENVIRONMENT
    会按名称选择模板;如果当前环境对应的文件不存在,或者文件位于仓库根目录而
    presync
    在 canister 目录中运行,
    envsubst
    将读不到任何内容并写入空清单。请在 frontend canister 目录下为每个环境保留一个模板。
  8. 通过读取
    ii-alternative-origins
    查找 derivation origin。
    它表示的是反向关系(哪些 origin 可以针对该 origin 进行派生),而不是指向该 origin 的指针。不存在反向查询;反向使用它会静默产生错误的 principal——结果看似合理,却并非错误提示。请发布并读取
    ii-derivation-origin
    以获取正向事实。
  9. 以无法被发现的方式命名行为方法。 名称必须出现在
    candid:service
    中,因此应使用
    getApiDoc
    /
    get_api_doc
    。只能通过带外提示访问的方法,无法实现零知识发现。
  10. 列出 canister,却不提供可识别它们的标签。
    id
    是唯一必填字段,因此仅含裸 ID 的清单也是有效的,并且仍有价值:Agent 可以获知应用的 canister,而不必从带外渠道发现它们。但这样会失去路由能力——如果没有任何信息能区分后端和前端,Agent 就必须为每个条目额外获取一次
    candid:service
    ,并根据方法名推测角色。请使用能够标识每个条目的信息(通常
    name
    就足够;如果用途无法仅从名称看出,还应添加
    role
    和
    description
    )。
  11. 移除
    candid:service
    。
    某些压缩或体积优化构建会丢弃 wasm 元数据。必须保留它,因为它是可供获取接口的机制。请使用
    icp canister metadata <id> candid:service --network ic
    验证。
  12. 未询问运营方就发布清单。 这里最可能的 Agent 失误是把
    /.well-known/ic-architecture
    当作普通构建配置,未经提示便将其加入。该行为会接受 ICP MCP App Operator Terms,并使应用允许 AI 助手发起查询和 update 调用。请先向用户确认,并确认用户是运营方——第 1 条规定,不负责运营应用的开发者不能代其运营方接受条款。
  13. 误以为注册就是加入或退出的方式。 注册是可选的,不会改变参与状态:未注册但已发布清单的应用仍会完全参与并受到全面约束。注册只会告知 DFINITY 谁接受了条款、接受了哪个版本,以及应向哪里发送通知。对称地,也不存在用于停止参与的“取消注册”——移除清单才是关闭开关。移除清单会停用参与;终止协议则是另一项独立操作,需向
    mcp@dfinity.org
    发出通知(第 11 条)。两者都不会撤销此前已在 Internet Computer 上执行的调用,而第 8、12、13 和 15 条——个人数据、保证、责任和适用法律——在终止后仍然有效。“删除文件后就结束了”不仅不完整,而且完全错误。
  14. 期望移除清单会将应用完全下架。 删除清单后,一旦 ICP MCP 发现移除,新的元数据读取及查询/update 调用便会停止,但 ICP MCP 仍可能获取应用的公开网站并描述公开信息。如果希望从面向用户的展示中移除应用,需由运营方联系 DFINITY,邮箱为
    mcp@dfinity.org
    。
  15. 声明运营方无法控制的 canister。 人们很容易列出应用仅仅会调用的第三方 ledger 或生态系统 canister。提供清单是一项持续性陈述(第 5 条),确认每个已声明的 canister 均由运营方运营或处于其授权之下,同时这会使这些 canister 可在应用参与期间接受 update 调用。只应列出自己的 canister。

Additional References

补充参考

  • Load
    static-site
    for the
    @dfinity/static-site
    recipe:
    presync
    /
    build
    ,
    _redirects
    /
    _headers
    ,
    .well-known/
    auto-upload, and canister-ID injection.
  • Load
    agent-web-identity
    for the agent/CLI side that consumes the derivation origin (
    icp identity link web --app <domain>
    ).
  • Load
    user-sign-in
    for adding II sign-in to a frontend (it also explains when not to set
    derivationOrigin
    ).
  • Load
    custom-domains
    for serving from your own domain, which then becomes your derivation origin.
  • Load
    icp-cli
    for
    icp.yaml
    /
    canister.yaml
    , environments, and the recipe system.
  • Load
    canister-security
    for access control on the methods agents call.
  • Authoritative human guide: Service discoverability.
  • The terms publishing the manifest accepts: ICP MCP App Operator Terms, and what ICP MCP is: ICP MCP.
  • What ICP MCP discloses to a participating app, and what it processes on registration: ICP MCP Privacy Policy.
  • Candid interface reference for the typed interface agents read: Candid interface.
  • Community example of the Layer 1 generation (a personal repo — illustrative, not a stable dependency):
    raymondk/demo-ic-architecture
    .
  • 加载
    static-site
    ,了解
    @dfinity/static-site
    recipe 的
    presync
    /
    build
    、
    _redirects
    /
    _headers
    、
    .well-known/
    自动上传及 canister ID 注入。
  • 加载
    agent-web-identity
    ,了解消费 derivation origin 的 Agent/CLI 端(
    icp identity link web --app <domain>
    )。
  • 加载
    user-sign-in
    ,了解如何为前端添加 II 登录(其中也说明了何时不应设置
    derivationOrigin
    )。
  • 加载
    custom-domains
    ,了解如何通过自有域名提供服务,该域名随后会成为 derivation origin。
  • 加载
    icp-cli
    ,了解
    icp.yaml
    /
    canister.yaml
    、环境及 recipe 系统。
  • 加载
    canister-security
    ,了解 Agent 所调用方法上的访问控制。
  • 权威人工指南:Service discoverability。
  • 发布清单即表示接受的条款:ICP MCP App Operator Terms,以及 ICP MCP 是什么:ICP MCP。
  • ICP MCP 会向参与应用披露哪些内容,以及注册时会处理哪些信息:ICP MCP Privacy Policy。
  • Agent 所读取的类型化接口参考:Candid interface。
  • 第 1 层生成的社区示例(个人仓库,仅作说明,并非稳定依赖项):
    raymondk/demo-ic-architecture
    。