> For the complete documentation index, see [llms.txt](https://docs.goassay.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.goassay.ai/developers/zh/di-ceng-yuan-li/architecture.md).

# 架构

了解 Assay 的各个部分，以及调用、签名和资金如何在它们之间流转。

Assay 将 AI 客户端连接到提供方运行的工具。托管服务器寻找提供方并检查结果。对于付费调用，本地进程签署付款许可，合约则持有资金。

## 工作原理

```mermaid
flowchart LR
    AI[AI client] <-->|stdio| Local[Local assay-mcp]
    Local <-->|MCP over HTTPS| Server[Assay MCP server]
    Web[Assay web app] <--> Backend[Assay backend]
    Server <--> Backend
    Server <-->|Mapped request and result| Provider[Provider endpoint and request verifier]
    Backend --> Checks[Result checks and settlement jobs]
    Local -->|Signed payment via Assay| Backend
    Backend <--> Contracts[Escrow, stake and config contracts]
    Web <-->|Wallet approval| Contracts
```

客户端通过 `assay-mcp` 连接到 `https://mcp.goassay.ai/`。托管 MCP 服务器提供该 URL 和智能体访问策略允许的工具。它将工具调用转换为发给合格提供方的请求，再返回映射后的提供方结果和收据。

网页应用用于管理账户、连接、工具和资金。其后端为 MCP 服务器提供目录、访问检查、路由、调用记录和结算处理。图中按职责分组，并不要求这些部分在同一进程运行。

## 各个部分

| 部分             | 职责                                         | 信任边界                         |
| -------------- | ------------------------------------------ | ---------------------------- |
| 网页应用           | 管理智能体、通过钱包批准支出、配置提供方上架条目。                  | 页面或批准链接本身不代表链上交易已完成。         |
| 托管 MCP 服务器     | 提供工具发现、验证调用，并执行 URL、访问和支出规则。               | 缓存的工具名称不能绕过当前访问检查。           |
| 本地 `assay-mcp` | 在操作系统密钥链中保存登录令牌和支付私钥。检查付款请求，为获准请求签名，并转发调用。 | 支付密钥保留在电脑上；本地限额和钱包批准的限额同时适用。 |
| 提供方端点          | 运行工具背后的服务。Assay 将工具参数映射为请求，再将响应映射回来。       | 提供方必须执行所选身份认证。               |
| 提供方请求验证器       | 检查签名请求是否来自 Assay、未被修改且未被使用。可在中间件或网关中运行。    | 它认证传入请求，不评判返回数据。             |
| 结果检查           | 使用工具配置的策略评判映射响应，并为收据记录证据。                  | 已返回的结果仍可能等待判定。               |
| 托管合约           | 持有客户资金，执行付款权限和上限，并在收款或退款前暂扣付款。             | Assay 可提交签名；合约检查其能否兑付。       |
| 质押合约           | 持有提供方保证金，处理拟议罚没和争议。                        | 结果失败不会立即扣除质押。                |
| 配置合约           | 提供角色、验证方密钥、暂停状态和共享限额。                      | 这些是合约设置，与本地客户端设置分开。          |

付款使用 **Robinhood Chain** 上的 **USDG**。客户托管余额和提供方质押用途不同：托管余额用于支付调用；质押为提供方的质量承诺兜底。

## 示例：选择连接方式

付费调用请使用带 `assay-mcp` 的本地客户端。claude.ai 和 ChatGPT 中的托管连接器无法持有本地支付密钥，因此只能免费调用。设置见[安装 assay-mcp](/developers/zh/shi-yong-gong-ju-ru-men/install-assay-mcp.md)，批准流程见[付费流程](/developers/zh/shi-yong-gong-ju-ru-men/how-paying-works.md)。

对于提供方，请求验证器可以放在应用内，也可以放在应用前方。[身份认证选择](/developers/zh/shang-jia-ni-de-api-ru-men/api-key-or-signature.md)说明了端点必须执行的检查。

## 延伸阅读

* [安全模型](/developers/zh/shi-yong-gong-ju-jin-jie/security-model.md)
* [将你的 API 映射到工具契约](/developers/zh/shang-jia-ni-de-api-jin-jie/map-your-api.md)

## 下一步

* [一次付费调用的全过程](/developers/zh/di-ceng-yuan-li/life-of-a-call.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.goassay.ai/developers/zh/di-ceng-yuan-li/architecture.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
