> Documentation index: https://metorial.com/llms.txt. Every page is available as Markdown by adding .md to its URL.

# Use tools from several apps in one agent session
URL: https://metorial.com/docs/build/guides/use-tools-from-several-apps

List one entry per provider deployment in the providers array of metorial.connect(). The session serves every tool, prefixed with its provider name.

---

To give one agent tools from several apps, list one entry per provider deployment in the `providers` array of `metorial.connect()`. The session serves all of their tools through one connection and prefixes each tool with its provider name, so tools from different apps cannot collide. Each entry carries its own auth and tool filter.

**What you'll learn**

* How to deploy two providers from the CLI
* How to attach both to one session in TypeScript and Python
* How to mix per-user connections and filters in the same session

**Before you start**

* [Install the CLI and sign in](https://metorial.com/docs/build/sandboxes#install-the-tools)
* A secret [API key](https://metorial.com/docs/build/api) in `METORIAL_API_KEY`

## With the CLI

### 1. Deploy two providers

Metorial Search and Metorial Crawl are built in and need no credentials. Copy both deployment IDs (`pde_...`).

```bash
metorial-admin providers deployments create --provider-id metorial-search --name "Metorial Search"
metorial-admin providers deployments create --provider-id metorial-crawl --name "Metorial Crawl"
```

### 2. Export the IDs

```bash
export SEARCH_DEPLOYMENT_ID="pde_..."
export CRAWL_DEPLOYMENT_ID="pde_..."
```

### 3. Optional: save the combination

A session template stores the list under one ID. Pass it as `sessionTemplateId` in a provider entry instead of repeating the list in code.

```bash
metorial-admin sessions templates create \
  --name "Research agent" \
  --providers '[{"provider_deployment_id": "pde_search_id"}, {"provider_deployment_id": "pde_crawl_id"}]'
```

## With the SDK

Install the SDK and an adapter:

**TypeScript**

```bash
npm install metorial @metorial/ai-sdk ai
```

**Python**

```bash
pip install metorial
```

Save this as `session.ts` or `session.py`. It attaches both deployments and prints the combined tool list. Pass `session.tools()` to your model SDK or framework as usual.

**TypeScript**

```typescript
import { metorialAiSdk } from '@metorial/ai-sdk';
import Metorial from 'metorial';

let metorial = new Metorial({ apiKey: process.env.METORIAL_API_KEY! });

let session = await metorial.connect({
  adapter: metorialAiSdk(),
  providers: [
    { providerDeploymentId: process.env.SEARCH_DEPLOYMENT_ID! },
    { providerDeploymentId: process.env.CRAWL_DEPLOYMENT_ID! }
  ]
});

console.log(Object.keys(session.tools()).join(', '));
```

**Python**

```python
import asyncio
import os

from metorial import Metorial, metorial_openai


async def main():
    metorial = Metorial(api_key=os.environ["METORIAL_API_KEY"])

    session = await metorial.connect(
        adapter=metorial_openai(),
        providers=[
            {"provider_deployment_id": os.environ["SEARCH_DEPLOYMENT_ID"]},
            {"provider_deployment_id": os.environ["CRAWL_DEPLOYMENT_ID"]},
        ],
    )

    print(", ".join(tool["function"]["name"] for tool in session.tools()))


asyncio.run(main())
```

## Mix auth and filters per app

Each entry is independent. This list gives an agent web search, one user's Slack account, and read access to the same user's GitHub account:

**TypeScript**

```typescript
import { metorialAiSdk } from '@metorial/ai-sdk';
import Metorial from 'metorial';

let metorial = new Metorial({ apiKey: process.env.METORIAL_API_KEY! });

export let connectForUser = async (user: {
  slackAuthConfigId: string;
  githubAuthConfigId: string;
}) =>
  metorial.connect({
    adapter: metorialAiSdk(),
    providers: [
      { providerDeploymentId: process.env.SEARCH_DEPLOYMENT_ID! },
      {
        providerDeploymentId: process.env.SLACK_DEPLOYMENT_ID!,
        providerAuthConfigId: user.slackAuthConfigId
      },
      {
        providerDeploymentId: process.env.GITHUB_DEPLOYMENT_ID!,
        providerAuthConfigId: user.githubAuthConfigId,
        toolFilters: [{ type: 'tool_regex', pattern: '^(list|get|search)' }]
      }
    ]
  });
```

**Python**

```python
import os

from metorial import Metorial, metorial_openai

metorial = Metorial(api_key=os.environ["METORIAL_API_KEY"])


async def connect_for_user(slack_auth_config_id: str, github_auth_config_id: str):
    return await metorial.connect(
        adapter=metorial_openai(),
        providers=[
            {"provider_deployment_id": os.environ["SEARCH_DEPLOYMENT_ID"]},
            {
                "provider_deployment_id": os.environ["SLACK_DEPLOYMENT_ID"],
                "provider_auth_config_id": slack_auth_config_id,
            },
            {
                "provider_deployment_id": os.environ["GITHUB_DEPLOYMENT_ID"],
                "provider_auth_config_id": github_auth_config_id,
                "tool_filters": [{"type": "tool_regex", "pattern": "^(list|get|search)"}],
            },
        ],
    )
```

The auth config IDs come from [the per-user OAuth flow](https://metorial.com/docs/build/sdk/oauth). A session accepts up to 100 providers.

## Check it worked

The program prints the tools of both providers and `metorial_connection_status`, the diagnostic tool Metorial adds to every session. The AI SDK adapter lowercases tool names, so the TypeScript program prints them in lower case.

```text
metorial_connection_status, metorial_crawl_extractWebContent, metorial_search_getWebContent, metorial_search_webSearch
```

If a provider cannot be reached, the session still works. Ask the agent to call `metorial_connection_status`, or list the session's errors:

```bash
metorial-admin sessions errors list --limit 5
```

## Troubleshooting

### `Cannot associate more than 100 providers to a session`

Split the providers across sessions, or use fewer deployments.

### `Provider requires an auth config to be provided`

One of the entries needs a sign-in and has no provider auth config. Add `providerAuthConfigId` to that entry.

## Next steps

* [Limit the tools an agent can use](https://metorial.com/docs/build/guides/limit-agent-tools): the filter types and how to find tool keys
* [Let each user connect their own account](https://metorial.com/docs/build/sdk/oauth): where the provider auth config IDs come from
* [Sessions](https://metorial.com/docs/build/operate/sessions): connections, messages and session templates