> 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/shi-yong-gong-ju-jin-jie/access-policy.md).

# 访问策略

了解 URL、智能体访问权限和提供方限制如何决定哪些调用可以执行。

只有 MCP URL 提供某个工具，且访问策略也允许时，智能体才能调用它。连接范围更广的 URL 不会扩大智能体权限。先请已连接的客户端查找所需工具；发现工具时已经会执行这两项检查。

## 如何执行访问控制

服务器会对每次调用重新检查。策略变更后，客户端保存的工具列表不能授予访问权限。

| 层级      | 决定什么                              | 拒绝结果                                      |
| ------- | --------------------------------- | ----------------------------------------- |
| URL 视图  | 此 URL 是否提供该工具，包括其筛选条件和工具集版本。      | `TOOL_NOT_IN_TOOLSET`                     |
| 智能体访问权限 | 智能体能否使用该工具。受限访问允许指定工具，或获准工具集中的工具。 | `TOOL_NOT_ALLOWED`                        |
| 连接凭据    | 此连接是否进一步缩小智能体的访问范围。它只能减少权限。       | `TOOL_NOT_ALLOWED`                        |
| 提供方规则   | 可用提供方是否同时符合智能体规则和此工具集条目的规则。       | 规则排除所有提供方时返回 `NO_PROVIDER_MATCHES_RULES`。 |
| 本地付款防护  | 所选收款方是否在此配置文件的可选提供方允许列表中。         | 签名前触发 G8 拒绝。                              |

智能体默认访问模式为 `ALL`。在 `RESTRICTED` 模式下，可以直接允许某个工具，也可以通过获准的工具集允许它。工具集授权可要求调用必须通过该工具集自己的 URL。在这种情况下，通过 `/` 访问同一工具仍会被阻止，除非有其他授权允许这样访问。

例如，若智能体仅获准通过研究工具集自己的 URL 使用该工具集，就必须连接那个 URL。将 `/` 添加到客户端或本地付费 URL 列表，无法绕过服务器的这项检查。

## 提供方规则如何合并

智能体规则适用于所有 URL。使用工具集自己的 URL 时，还会应用工具集条目规则。

| 规则          | 合并后的行为                                             |
| ----------- | -------------------------------------------------- |
| 工具集条目允许的提供方 | 只有该集合中的提供方可成为候选。                                   |
| 排除的提供方      | 同时应用智能体和条目的排除规则。                                   |
| 最高价格        | 可比较时，采用较低的最高价格。                                    |
| 最低提供方等级     | 采用较高的最低等级。                                         |
| 没有匹配的提供方    | 通常拒绝。配置为 `FALLBACK_BEST` 的条目可放弃自身的提供方偏好，但仍保留智能体规则。 |

{% hint style="warning" %}
最低质量限制尚未生效。请勿依赖它来限制提供方。
{% endhint %}

本地提供方允许列表是一项独立的付款检查。它比较收款方地址，而非服务器的提供方 ID，也不会告诉服务器该选哪个提供方。服务器选出的提供方即使符合服务器规则，仍可能被本地拒绝。本地列表不限制免费调用。

## 查看本地限制

```sh
npx -y @goassay-ai/mcp limits
```

`providers: any` 表示此本地检查没有限制。服务器访问权限和提供方规则仍然适用。如果找不到工具，请对照目标工具集 URL 的发现结果，检查登录时所选智能体的策略。

## 确认是否成功

获准工具有可路由的供应时，会出现在发现结果中。直接调用 URL 范围或策略之外的工具时，即使客户端记得其名称，服务器仍会拒绝。向本地列表之外的收款方发起付费调用，会在签名前被拒绝。

<details>

<summary>可选：限制本地付款接收方</summary>

在交互式终端使用 `limits set`，在 `--providers` 后提供逗号分隔的收款方地址列表。即使只修改提供方，也必须填写 `--per-call` 和 `--per-day`。列表接受 1–100 个地址。请使用目标提供方已验证的收款地址；此处不能使用提供方 ID。

省略 `--providers` 会保留现有列表。要移除本地限制并保留默认美元上限：

```sh
npx -y @goassay-ai/mcp limits set --per-call 0.50 --per-day 5 --providers off
```

此示例也会修改美元上限。如果你预期的上限不同，请使用自己的值。此命令不会修改智能体的服务器端策略或钱包批准的上限。

</details>

<details>

<summary>可选：了解策略版本和工具集</summary>

获准工具集可以指向已发布的快照。你自己的不带版本工具集授权使用其草稿；不带版本的官方授权跟随最新公开版本。其他组织的获准工具集会固定到某个已发布版本。发布新版本不会悄悄扩大这项固定授权。

策略、连接限制或工具集草稿变更后，服务器会使访问缓存失效。下一个请求会解析更新后的权限。修改工具集 URL 和修改访问授权是两件独立的事；两者都必须允许该工具。

</details>

## 错误

| 代码或消息                                                                                                             | 含义                | 解决方法                                                                              |
| ----------------------------------------------------------------------------------------------------------------- | ----------------- | --------------------------------------------------------------------------------- |
| `TOOL_NOT_IN_TOOLSET`                                                                                             | 工具不在此 URL 的视图范围内。 | 使用目标 [URL](/developers/zh/shi-yong-gong-ju-jin-jie/urls-and-profiles.md)，或修正筛选条件。 |
| `TOOL_NOT_ALLOWED`                                                                                                | 智能体或连接访问权限阻止了调用。  | 请账户所有者检查权限；重新连接 `/` 不会授予权限。                                                       |
| `NO_PROVIDER_MATCHES_RULES`                                                                                       | 提供方规则排除了所有合格提供方。  | 查看拒绝信息中的规则来源，选择兼容规则或其他工具。                                                         |
| **Assay asked for a payment this app refused: the provider is not in the allow-list.**（`G8_PROVIDER_NOT_ALLOWED`） | 收款方未通过本地付款允许列表检查。 | 请自行检查目标收款方和本地限制。                                                                  |

## 延伸阅读

* [URL 与配置文件](/developers/zh/shi-yong-gong-ju-jin-jie/urls-and-profiles.md)
* [安全模型](/developers/zh/shi-yong-gong-ju-jin-jie/security-model.md)

## 下一步

* [重试与幂等](/developers/zh/shi-yong-gong-ju-jin-jie/retries-and-idempotency.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/shi-yong-gong-ju-jin-jie/access-policy.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.
