# update()

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/mcp/update/
Language: zh

`api.mcp.update(name, { tools?, category?, token?, label?, url? }) → Promise<Server>`

更改允许的工具、 许可类别、 符号、 标签或地址。 只有您所通过时被触动 。

Status: PATCH · tools replaces the list · a new address is checked

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `tools` | string[] |  | **替换** 允许列表。 `[]` 不允许设置任何。 |
| `category` | string |  | `read` · `write` · `exec`. |
| `token` | string|null |  | 新的代币,同样清洁 `null` 把它删除 |
| `label` | string |  | 显示名称 。 |
| `url` | string |  | 新地址—— 检查为新连接 。 |

```javascript
// Allow two tools and nothing else
await api.mcp.update("example", { tools: ["search_docs", "get_issue"] });

// Make them free to call in auto mode
await api.mcp.update("example", { category: "read" });

// Rotate the token
await api.mcp.update("example", { token: process.env.EXAMPLE_TOKEN_NEW });

// Turn the server off without disconnecting it
await api.mcp.update("example", { tools: [] });
```

## 替换工具, 它不添加 {#replaces}

> **传递您想要的全部列表**
>
> 发送一个名字时, 将允许使用一个工具。 要添加一个, 请在获取 () 时读取当前列表, 并随添加后寄回它 。

```javascript
const server = await api.mcp.get("example");
const allowed = server.tools.filter((t) => t.allowed).map((t) => t.name);
await api.mcp.update("example", { tools: [...allowed, "create_issue"] });
```

## 更改类别是许可决定 {#category}

`read` 服务器的每一个工具都让服务器的每个工具都能够自由在每一个模式中呼用,但计划除外。 只有当您知道所有服务器都做什么时才设定它, 类别是服务器的,而不是工具的, 所以每读中写一个是足够的理由, 离开它 `exec`.

## 新的地址通过相同的检查 {#url}

计划,它公开解决。 拒绝没有通过地址的地址 `url_blocked` 连接保持原样

## 关闭服务器 {#off}

`tools: []` 保留连接及其标记, 而不声明任何内容。 有助于阻止服务器的错误行为到达任何运行, 同时又不丢失证书 。

- [允许的工具](/zh/sdk/mcp/allowed-tools): 为什么没有默认允许?
- [disconnect()](/zh/sdk/ref/mcp/disconnect): 完全删除
- [api.mcp](/zh/sdk/ref/mcp): 连接、列出和使用服务器。

```python
import os

# Allow two tools and nothing else
api.mcp.update("example", tools=["search_docs", "get_issue"])

# Make them free to call in auto mode
api.mcp.update("example", category="read")

# Rotate the token
api.mcp.update("example", token=os.environ["EXAMPLE_TOKEN_NEW"])

# Turn the server off without disconnecting it
api.mcp.update("example", tools=[])
```

```python
server = api.mcp.get("example")
allowed = [t["name"] for t in server["tools"] if t["allowed"]]
api.mcp.update("example", tools=[*allowed, "create_issue"])
```
