# forAgent()

Canonical URL: https://developers.iagenify.com/sdk/ref/mcp/for-agent/
Language: en

`api.mcp.forAgent(names?) → Promise<Server[]>`

Servers ready for the engine: allowed tools and tokens. This is what agents.create({ mcp }) reads — you rarely call it yourself.

Status: tokens included · null means all · [] means none

```javascript
await api.mcp.forAgent();            // every connected server
await api.mcp.forAgent(["example"]); // these
await api.mcp.forAgent([]);          // none — and no request is made
```

## null and [] are different, and both are useful {#null-vs-empty}

| Passed | Means |
| --- | --- |
| `null` or nothing | Every connected server |
| `["a", "b"]` | Those two |
| `[]` | None. It returns immediately without asking. |

> **« All connected » stays bounded**
>
> Only allowed tools come out, so taking every server is not the open door it sounds like. A server with nothing allowed contributes nothing.

## It carries tokens {#tokens}

The engine needs them to contact each server, so this is the one listing that includes them. They are decrypted for the authenticated owner and for nobody else — do not log what this returns.

## The agent reads it for you {#agent}

```javascript
api.agents.create({ runtime: "local", machine: pc, model, mcp: ["example"] });
// mcp absent  → every connected server
// mcp: []     → none
```

It is re-read at the start of every run, so a server connected from another window is available without restarting whatever holds the package.

## When to call it directly {#when-yourself}

When you are building the engine's tool shape yourself — `createMcpTools()` takes exactly what this returns. For declarations alone, [tools()](/sdk/ref/mcp/tools) is the one to use.

- [createMcpTools()](/sdk/ref/mcp-client/create-mcp-tools): What consumes this.
- [Options · tools and library](/sdk/ref/agents/options/tools): The mcp option.
- [api.mcp](/sdk/ref/mcp): Connecting, listing and using a server.

```python
api.mcp.for_agent()              # every connected server
api.mcp.for_agent(["example"])   # these
api.mcp.for_agent([])            # none — and no request is made
```

```python
api.agents.create(runtime="local", machine=pc, model=model, mcp=["example"])
# mcp absent → every connected server
# mcp=[]     → none
```
