# Connect the MultitaskAI MCP server to OpenAI Agents JS

The OpenAI Agents SDK for TypeScript connects agents to MCP servers. Create an MCPServerStreamableHttp for MultitaskAI and add it to mcpServers.

## Endpoint

```text
https://mcp.multitaskai.com
```

## Steps

1. Create an API key in your MultitaskAI account.
2. Create the server below with @openai/agents, with your key in place of YOUR_API_KEY.
3. Add it to your agent's mcpServers and call connect() before running.
4. Run the agent and check that it answers with MultitaskAI tools, then call close().

```typescript
import { Agent, run, MCPServerStreamableHttp } from '@openai/agents';

const mcpServer = new MCPServerStreamableHttp({
  url: 'https://mcp.multitaskai.com',
  name: 'multitaskai',
  requestInit: {
    headers: { Authorization: 'Bearer YOUR_API_KEY' },
  },
});

const agent = new Agent({
  name: 'Assistant',
  instructions: 'Use the MultitaskAI tools to respond to user requests.',
  mcpServers: [mcpServer],
});

await mcpServer.connect();
const result = await run(agent, 'Which MultitaskAI tools can you use?');
console.log(result.finalOutput);
await mcpServer.close();
```

## Authentication

OpenAI Agents JS sends your MultitaskAI API key in the Authorization header. Create a key in your account and use it in place of YOUR_API_KEY. Keep the key out of files you share or commit.

```text
Authorization: Bearer YOUR_API_KEY
```

## Good to know

- requestInit is passed through to fetch, so the Authorization header goes there.
- Call connect() before running the agent and close() when you are done.
- hostedMcpTool lets the Responses API call the server instead of your process; its requireApproval defaults to never.

## Official documentation

The [OpenAI MCP documentation](https://openai.github.io/openai-agents-js/guides/mcp/) covers OpenAI Agents JS's own settings in detail. See the [overview](/docs.md) for the endpoint and authentication, and [pricing](/pricing/) for the daily free requests.
