# How to integrate Lever MCP with OpenAI Agents SDK

```json
{
  "title": "How to integrate Lever MCP with OpenAI Agents SDK",
  "toolkit": "Lever",
  "toolkit_slug": "lever",
  "framework": "OpenAI Agents SDK",
  "framework_slug": "open-ai-agents-sdk",
  "url": "https://composio.dev/toolkits/lever/framework/open-ai-agents-sdk",
  "markdown_url": "https://composio.dev/toolkits/lever/framework/open-ai-agents-sdk.md",
  "updated_at": "2026-05-12T10:17:29.451Z"
}
```

## Introduction

This guide walks you through connecting Lever to the OpenAI Agents SDK using the Composio tool router. By the end, you'll have a working Lever agent that can list all open job postings, get candidate details by email, schedule interview for specific candidate through natural language commands.
This guide will help you understand how to give your OpenAI Agents SDK agent real control over a Lever account through Composio's Lever MCP server.
Before we dive in, let's take a quick look at the key ideas and tools involved.

## Also integrate Lever with

- [Claude Agent SDK](https://composio.dev/toolkits/lever/framework/claude-agents-sdk)
- [Claude Code](https://composio.dev/toolkits/lever/framework/claude-code)
- [Claude Cowork](https://composio.dev/toolkits/lever/framework/claude-cowork)
- [Codex](https://composio.dev/toolkits/lever/framework/codex)
- [OpenClaw](https://composio.dev/toolkits/lever/framework/openclaw)
- [Hermes](https://composio.dev/toolkits/lever/framework/hermes-agent)
- [CLI](https://composio.dev/toolkits/lever/framework/cli)
- [Google ADK](https://composio.dev/toolkits/lever/framework/google-adk)
- [LangChain](https://composio.dev/toolkits/lever/framework/langchain)
- [Vercel AI SDK](https://composio.dev/toolkits/lever/framework/ai-sdk)
- [Mastra AI](https://composio.dev/toolkits/lever/framework/mastra-ai)
- [LlamaIndex](https://composio.dev/toolkits/lever/framework/llama-index)
- [CrewAI](https://composio.dev/toolkits/lever/framework/crew-ai)

## TL;DR

Here's what you'll learn:
- Get and set up your OpenAI and Composio API keys
- Install the necessary dependencies
- Initialize Composio and create a Tool Router session for Lever
- Configure an AI agent that can use Lever as a tool
- Run a live chat session where you can ask the agent to perform Lever operations

## What is OpenAI Agents SDK?

The OpenAI Agents SDK is a lightweight framework for building AI agents that can use tools and maintain conversation state. It provides a simple interface for creating agents with hosted MCP tool support.
Key features include:
- Hosted MCP Tools: Connect to external services through hosted MCP endpoints
- SQLite Sessions: Persist conversation history across interactions
- Simple API: Clean interface with Agent, Runner, and tool configuration
- Streaming Support: Real-time response streaming for interactive applications

## What is the Lever MCP server, and what's possible with it?

The Lever MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Lever account. It provides structured and secure access to your recruiting pipeline, so your agent can perform actions like managing candidates, scheduling interviews, updating job postings, tracking offers, and analyzing hiring metrics on your behalf.
- End-to-end candidate management: Let your agent add, update, or move candidates through different stages of your hiring process seamlessly.
- Automated interview scheduling: Have the agent create, modify, or cancel interviews and coordinate with both candidates and interviewers to streamline the process.
- Job posting and requisition updates: Direct your agent to create new job postings, update existing requisitions, or close filled roles instantly.
- Offer and feedback tracking: Enable your agent to manage offer letters, track acceptance rates, and collect structured feedback from interviewers.
- Recruiting analytics and reporting: Ask the agent to generate reports on pipeline activity, source effectiveness, and diversity metrics—helping you make data-driven hiring decisions.

## Supported Tools

| Tool slug | Name | Description |
|---|---|---|
| `LEVER_ADD_OPPORTUNITY_LINKS` | Add Opportunity Links | Tool to add links to a contact associated with an opportunity. Use when you need to attach URLs like LinkedIn profiles, GitHub accounts, personal websites, or other social media links to a candidate. Adding new links does not replace existing links. |
| `LEVER_ADD_OPPORTUNITY_SOURCES` | Add Opportunity Sources | Tool to add sources to an opportunity. Use when you need to attribute specific recruitment channels or sources to an existing opportunity. |
| `LEVER_ADD_OPPORTUNITY_TAGS` | Add Opportunity Tags | Tool to add tags to an opportunity. Use when you need to append labels or categorize an existing opportunity. |
| `LEVER_CREATE_FORM` | Create Form Submission | Tool to create a completed profile form submission for a candidate's opportunity profile. Use when you need to submit a filled form based on an existing template. |
| `LEVER_CREATE_FORM_TEMPLATE` | Create Form Template | Tool to create a profile form template for an account. Use when you need to create a new form template with custom fields. |
| `LEVER_CREATE_INTERVIEW` | Create Interview | Tool to create an interview on an externally-managed panel in Lever. Use when scheduling a new interview for an opportunity on a panel where externallyManaged is true. |
| `LEVER_CREATE_NOTE` | Create Note | Tool to create a note on an opportunity profile or add a threaded comment to an existing note. |
| `LEVER_CREATE_OPPORTUNITY` | Create Opportunity | Tool to create a new candidate opportunity in Lever. Use when adding a new candidate to the system with automatic email-based deduplication. |
| `LEVER_CREATE_PANEL` | Create Panel | Tool to create a new interview panel for an opportunity. Use when scheduling interviews for a candidate. |
| `LEVER_CREATE_REQUISITION` | Create Requisition | Tool to create a new requisition in Lever for tracking hiring needs. Use when establishing job requisitions to manage headcount and hiring workflows. |
| `LEVER_CREATE_REQUISITION_FIELD` | Create Requisition Field | Tool to create a custom requisition field schema for use across requisitions. Use when establishing requisition field schemas for your account. |
| `LEVER_CREATE_REQUISITION_FIELD_OPTION` | Create Requisition Field Option | Tool to add new options to a dropdown requisition field without replacing existing options. Use when you need to expand dropdown choices for requisition fields. |
| `LEVER_CREATE_UPLOAD` | Upload File | Tool to upload a file temporarily to Lever for use with posting applications. Use when you need to attach resumes or documents before creating opportunities. Files expire after 24 hours and have a 30MB size limit. |
| `LEVER_CREATE_USER` | Create User | Tool to create a new user in the Lever system. Use when adding a new team member with configurable access role. |
| `LEVER_DEACTIVATE_USER` | Deactivate User | Tool to deactivate a user in the Lever system. Use when you need to prevent a user from logging in while preserving their historical records. Deactivated users remain in the system for historical record keeping but can no longer log in and use Lever. |
| `LEVER_DELETE_FORM_TEMPLATE` | Delete Form Template | Tool to delete a profile form template from account. Use when you need to remove a custom API-created form template. System templates cannot be deleted. |
| `LEVER_DELETE_INTERVIEW` | Delete Interview | Tool to delete an interview from an opportunity panel. Use when you need to remove an externally managed interview on behalf of a user. Only interviews with externallyManaged=true can be deleted. |
| `LEVER_DELETE_NOTE` | Delete Note | Tool to delete a note on an opportunity. Use when you need to remove an API-created note. |
| `LEVER_DELETE_PANEL` | Delete Panel | Tool to delete a panel from an opportunity. Use when you need to remove an externally managed panel on behalf of a user. Only panels with externallyManaged=true can be deleted. |
| `LEVER_DELETE_REQUISITION` | Delete Requisition | Tool to delete or archive a requisition from Lever account. Use when you need to remove a requisition. |
| `LEVER_DELETE_REQUISITION_FIELD` | Delete Requisition Field | Tool to delete a requisition field from the account. Use when you need to remove a requisition field that is no longer in use. |
| `LEVER_DELETE_REQUISITION_FIELD_OPTION` | Delete Requisition Field Option | Tool to remove specific options from a dropdown requisition field. Use when you need to delete dropdown choices without removing the entire field. |
| `LEVER_DOWNLOAD_FILE` | Download File | Tool to download a file associated with an opportunity. Use when you have opportunity and file UIDs and need to retrieve the actual file content. |
| `LEVER_GET_FILE` | Get File Metadata | Tool to retrieve metadata for a single file on an opportunity. Use when you have opportunity and file UIDs and need details like name, size, and status before downloading. |
| `LEVER_GET_FORM` | Get Form | Tool to retrieve a specific profile form for an opportunity. Use when you need to fetch details of a form including field values and completion status. |
| `LEVER_GET_FORM_TEMPLATE` | Get Form Template | Tool to retrieve a single form template by unique identifier. Use when you need to obtain a reference template for creating a new profile form. |
| `LEVER_GET_INTERVIEW` | Get Interview | Tool to retrieve a single interview for an opportunity. Use when you need to fetch detailed interview information by opportunity and interview UIDs. |
| `LEVER_GET_NOTE` | Get Note | Tool to retrieve a single note for an opportunity. Use when you need to fetch detailed information for a specific note after confirming the opportunity and note IDs. |
| `LEVER_GET_OPPORTUNITY` | Get Opportunity | Tool to retrieve detailed information about a single opportunity. Use when you need to fetch comprehensive candidate details including contact information, stage progression, sources, tags, and applications. |
| `LEVER_GET_PANEL` | Get Panel | Tool to retrieve a single interview panel for an opportunity. Use when you need to fetch detailed panel info by opportunity and panel UIDs. |
| `LEVER_GET_REQUISITION` | Get Requisition | Tool to retrieve detailed information about a single requisition by ID. Use when you need to fetch comprehensive requisition details including hiring status, headcount, and associated postings. |
| `LEVER_GET_REQUISITION_FIELD` | Get Requisition Field | Tool to retrieve detailed information about a single custom requisition field by ID. Use when you need to fetch the schema and configuration of a specific requisition field. |
| `LEVER_GET_STAGE` | Get Stage | Tool to retrieve detailed information about a single stage by its UUID. Use when you need to fetch stage details from the recruiting pipeline workflow. |
| `LEVER_GET_USER` | Get User | Tool to retrieve detailed information about a single user by their UUID. Use when you need to fetch complete user profile data including access role, contact links, and organizational details. |
| `LEVER_LIST_FILES` | List Opportunity Files | Tool to list all files on an opportunity. Use after obtaining the opportunity UID. |
| `LEVER_LIST_FORMS` | List Forms | Tool to list all profile forms for an opportunity. Use when you need to retrieve all forms associated with a candidate's profile. |
| `LEVER_LIST_FORM_TEMPLATES` | List Form Templates | Tool to list all active form templates. Use when you need to retrieve all profile form templates for an account. |
| `LEVER_LIST_INTERVIEWS` | List Interviews | Tool to list all interviews for an opportunity. Use when you have an opportunity UID and need to retrieve all its interviews. |
| `LEVER_LIST_NOTES` | List Notes | Tool to list notes on an opportunity profile. Use when you have an opportunity UID and need to retrieve its notes. |
| `LEVER_LIST_OFFERS` | List Offers | Tool to list offers for an opportunity. Use when you have an opportunity UID and need to retrieve its offers. |
| `LEVER_LIST_OPPORTUNITIES` | List Opportunities | Tool to list all opportunities in the hiring pipeline. Use when you need to retrieve candidate opportunities with optional filtering by contact, posting, stage, tags, time ranges, or other criteria. |
| `LEVER_LIST_PANELS` | List Panels | Tool to list all interview panels for an opportunity. Use when you need to retrieve all panels associated with a specific opportunity UID. |
| `LEVER_LIST_POSTINGS` | List Postings | Tool to list all job postings including published, internal, closed, draft, pending, and rejected postings. Use when you need to retrieve job postings with optional filtering by state, team, department, location, commitment, level, tag, or update timestamp. |
| `LEVER_LIST_REFERRALS` | List Referrals | Tool to list all referrals for an opportunity. Use when you have an opportunity UID and need to retrieve its referrals. |
| `LEVER_LIST_REQUISITION_FIELDS` | List Requisition Fields | Tool to list all requisition field schemas in your Lever account with optional filtering. Use when you need to retrieve requisition fields with optional filtering by required status or field type. |
| `LEVER_LIST_REQUISITIONS` | List Requisitions | Tool to list all requisitions with filtering and pagination. Use when you need to retrieve requisitions, optionally filtered by status, code, confidentiality, or creation date. |
| `LEVER_LIST_RESUMES` | List Opportunity Resumes | Tool to list all resumes for an opportunity. Use after obtaining the opportunity UID to retrieve candidate resumes. |
| `LEVER_LIST_SOURCES` | List Sources | Tool to list all recruitment sources in your Lever account. Use when you need to retrieve information about sources (e.g., LinkedIn, Indeed, referrals, career site). |
| `LEVER_LIST_STAGES` | List Stages | Tool to retrieve all pipeline stages in your Lever account. Use when you need to list all hiring stages. |
| `LEVER_LIST_TAGS` | List Tags | Tool to list all tags in your Lever account. Use when you need to retrieve tags used to categorize candidates, opportunities, and postings. |
| `LEVER_LIST_USERS` | List Users | Tool to retrieve all active users in your Lever account with optional filters. Use when you need to list users, filter by email, access role, or include deactivated users. |
| `LEVER_REACTIVATE_USER` | Reactivate User | Tool to reactivate a previously deactivated user in the Lever system. Use when you need to restore login and Lever access to a user. After reactivation, the user's deactivatedAt field will be set to null, indicating the user is active again. |
| `LEVER_REMOVE_CONTACT_LINKS_BY_OPPORTUNITY` | Remove Contact Links by Opportunity | Tool to remove links from a contact associated with an opportunity. Useful when invalid or outdated URLs need to be detached from a candidate profile. |
| `LEVER_REMOVE_OPPORTUNITY_SOURCES` | Remove Opportunity Sources | Tool to remove sources from an opportunity. Use when you need to delete source attributions from a candidate's recruitment tracking information. |
| `LEVER_REMOVE_OPPORTUNITY_TAGS` | Remove Opportunity Tags | Tool to remove tags from an opportunity. Use when you need to detach specific labels from an existing opportunity before further updates or archiving. |
| `LEVER_UPDATE_FORM_TEMPLATE` | Update Form Template | Tool to update an existing profile form template. Use when you need to modify a form template's name, instructions, fields, or other properties. |
| `LEVER_UPDATE_INTERVIEW` | Update Interview | Tool to update an interview on an externally-managed panel. Use when modifying all details of an externally-managed panel interview via API. |
| `LEVER_UPDATE_NOTE` | Update Note | Tool to update a note on an opportunity profile. Endpoint: PUT /opportunities/{opportunity}/notes/{note} Notes: Only notes originally created via the API can be updated. |
| `LEVER_UPDATE_PANEL` | Update Panel | Tool to update an externally-managed panel for an opportunity. Use when modifying panel details such as applications, timezone, interviews, or notes after confirming the panel is externally-managed. |
| `LEVER_UPDATE_REQUISITION` | Update Requisition | Tool to update an existing requisition in Lever. Use when modifying requisition details such as name, headcount, status, or other attributes. This performs a full resource update where all required fields must be provided. |
| `LEVER_UPDATE_REQUISITION_FIELD` | Update Requisition Field | Tool to update an existing requisition field in Lever. Use when modifying requisition field properties. IMPORTANT: This is an atomic update - include all properties you want to keep, as omitted properties will be deleted. |
| `LEVER_UPDATE_REQUISITION_FIELD_OPTION` | Update Requisition Field Option | Tool to update existing options in a dropdown requisition field without replacing the entire field object. Use when you need to modify the text of dropdown choices for requisition fields. |
| `LEVER_UPDATE_USER` | Update User | Tool to update an existing user in the Lever system. Use when modifying user information such as name, email, access role, or job details. WARNING: This performs a full resource update - all fields will be overwritten, and missing optional fields will be reset to defaults. |
| `LEVER_UPLOAD_FILE` | Upload File to Opportunity | Tool to upload a file permanently to an opportunity. Use when you need to attach resumes, documents, or other files directly to a candidate's opportunity profile. Files have a 30MB size limit. |

## Supported Triggers

None listed.

## Creating MCP Server - Stand-alone vs Composio SDK

The Lever MCP server is an implementation of the Model Context Protocol that connects your AI agent to Lever. It provides structured and secure access so your agent can perform Lever operations on your behalf through a secure, permission-based interface.
With Composio's managed implementation, you don't have to create your own developer app. For production, if you're building an end product, we recommend using your own credentials. The managed server helps you prototype fast and go from 0-1 faster.

## Step-by-step Guide

### 1. Prerequisites

Before starting, make sure you have:
- Composio API Key and OpenAI API Key
- Primary know-how of OpenAI Agents SDK
- A live Lever project
- Some knowledge of Python or Typescript

### 1. Getting API Keys for OpenAI and Composio

OpenAI API Key
- Go to the [OpenAI dashboard](https://platform.openai.com/settings/organization/api-keys) and create an API key. You'll need credits to use the models, or you can connect to another model provider.
- Keep the API key safe.
Composio API Key
- Log in to the [Composio dashboard](https://dashboard.composio.dev?utm_source=toolkits&utm_medium=framework_docs).
- Go to Settings and copy your API key.

### 2. Install dependencies

Install the Composio SDK and the OpenAI Agents SDK.
```python
pip install composio_openai_agents openai-agents python-dotenv
```

```typescript
npm install @composio/openai-agents @openai/agents dotenv
```

### 3. Set up environment variables

Create a .env file and add your OpenAI and Composio API keys.
```bash
OPENAI_API_KEY=sk-...your-api-key
COMPOSIO_API_KEY=your-api-key
USER_ID=composio_user@gmail.com
```

### 4. Import dependencies

What's happening:
- You're importing all necessary libraries.
- The Composio and OpenAIAgentsProvider classes are imported to connect your OpenAI agent to Composio tools like Lever.
```python
import asyncio
import os
from dotenv import load_dotenv

from composio import Composio
from composio_openai_agents import OpenAIAgentsProvider
from agents import Agent, Runner, HostedMCPTool, SQLiteSession
```

```typescript
import 'dotenv/config';
import { Composio } from '@composio/core';
import { OpenAIAgentsProvider } from '@composio/openai-agents';
import { Agent, hostedMcpTool, run, OpenAIConversationsSession } from '@openai/agents';
import * as readline from 'readline';
```

### 5. Set up the Composio instance

No description provided.
```python
load_dotenv()

api_key = os.getenv("COMPOSIO_API_KEY")
user_id = os.getenv("USER_ID")

if not api_key:
    raise RuntimeError("COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key")

# Initialize Composio
composio = Composio(api_key=api_key, provider=OpenAIAgentsProvider())
```

```typescript
dotenv.config();

const composioApiKey = process.env.COMPOSIO_API_KEY;
const userId = process.env.USER_ID;

if (!composioApiKey) {
  throw new Error('COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key');
}
if (!userId) {
  throw new Error('USER_ID is not set');
}

// Initialize Composio
const composio = new Composio({
  apiKey: composioApiKey,
  provider: new OpenAIAgentsProvider(),
});
```

### 6. Create a Tool Router session

What is happening:
- You give the Tool Router the user id and the toolkits you want available. Here, it is only lever.
- The router checks the user's Lever connection and prepares the MCP endpoint.
- The returned session.mcp.url is the MCP URL that your agent will use to access Lever.
- This approach keeps things lightweight and lets the agent request Lever tools only when needed during the conversation.
```python
# Create a Lever Tool Router session
session = composio.create(
    user_id=user_id,
    toolkits=["lever"]
)

mcp_url = session.mcp.url
```

```typescript
// Create Tool Router session for Lever
const session = await composio.create(userId as string, {
  toolkits: ['lever'],
});
const mcpUrl = session.mcp.url;
```

### 7. Configure the agent

No description provided.
```python
# Configure agent with MCP tool
agent = Agent(
    name="Assistant",
    model="gpt-5",
    instructions=(
        "You are a helpful assistant that can access Lever. "
        "Help users perform Lever operations through natural language."
    ),
    tools=[
        HostedMCPTool(
            tool_config={
                "type": "mcp",
                "server_label": "tool_router",
                "server_url": mcp_url,
                "headers": {"x-api-key": api_key},
                "require_approval": "never",
            }
        )
    ],
)
```

```typescript
// Configure agent with MCP tool
const agent = new Agent({
  name: 'Assistant',
  model: 'gpt-5',
  instructions:
    'You are a helpful assistant that can access Lever. Help users perform Lever operations through natural language.',
  tools: [
    hostedMcpTool({
      serverLabel: 'tool_router',
      serverUrl: mcpUrl,
      headers: { 'x-api-key': composioApiKey },
      requireApproval: 'never',
    }),
  ],
});
```

### 8. Start chat loop and handle conversation

No description provided.
```python
print("\nComposio Tool Router session created.")

chat_session = SQLiteSession("conversation_openai_toolrouter")

print("\nChat started. Type your requests below.")
print("Commands: 'exit', 'quit', or 'q' to end\n")

async def main():
    try:
        result = await Runner.run(
            agent,
            "What can you help me with?",
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")
    except Exception as e:
        print(f"Error: {e}\n")

    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit", "q"}:
            print("Goodbye!")
            break

        result = await Runner.run(
            agent,
            user_input,
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")

asyncio.run(main())
```

```typescript
// Keep conversation state across turns
const conversationSession = new OpenAIConversationsSession();

// Simple CLI
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  prompt: 'You: ',
});

console.log('\nComposio Tool Router session created.');
console.log('\nChat started. Type your requests below.');
console.log("Commands: 'exit', 'quit', or 'q' to end\n");

try {
  const first = await run(agent, 'What can you help me with?', { session: conversationSession });
  console.log(`Assistant: ${first.finalOutput}\n`);
} catch (e) {
  console.error('Error:', e instanceof Error ? e.message : e, '\n');
}

rl.prompt();

rl.on('line', async (userInput) => {
  const text = userInput.trim();

  if (['exit', 'quit', 'q'].includes(text.toLowerCase())) {
    console.log('Goodbye!');
    rl.close();
    process.exit(0);
  }

  if (!text) {
    rl.prompt();
    return;
  }

  try {
    const result = await run(agent, text, { session: conversationSession });
    console.log(`\nAssistant: ${result.finalOutput}\n`);
  } catch (e) {
    console.error('Error:', e instanceof Error ? e.message : e, '\n');
  }

  rl.prompt();
});

rl.on('close', () => {
  console.log('\n👋 Session ended.');
  process.exit(0);
});
```

## Complete Code

```python
import asyncio
import os
from dotenv import load_dotenv

from composio import Composio
from composio_openai_agents import OpenAIAgentsProvider
from agents import Agent, Runner, HostedMCPTool, SQLiteSession

load_dotenv()

api_key = os.getenv("COMPOSIO_API_KEY")
user_id = os.getenv("USER_ID")

if not api_key:
    raise RuntimeError("COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key")

# Initialize Composio
composio = Composio(api_key=api_key, provider=OpenAIAgentsProvider())

# Create Tool Router session
session = composio.create(
    user_id=user_id,
    toolkits=["lever"]
)
mcp_url = session.mcp.url

# Configure agent with MCP tool
agent = Agent(
    name="Assistant",
    model="gpt-5",
    instructions=(
        "You are a helpful assistant that can access Lever. "
        "Help users perform Lever operations through natural language."
    ),
    tools=[
        HostedMCPTool(
            tool_config={
                "type": "mcp",
                "server_label": "tool_router",
                "server_url": mcp_url,
                "headers": {"x-api-key": api_key},
                "require_approval": "never",
            }
        )
    ],
)

print("\nComposio Tool Router session created.")

chat_session = SQLiteSession("conversation_openai_toolrouter")

print("\nChat started. Type your requests below.")
print("Commands: 'exit', 'quit', or 'q' to end\n")

async def main():
    try:
        result = await Runner.run(
            agent,
            "What can you help me with?",
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")
    except Exception as e:
        print(f"Error: {e}\n")

    while True:
        user_input = input("You: ").strip()
        if user_input.lower() in {"exit", "quit", "q"}:
            print("Goodbye!")
            break

        result = await Runner.run(
            agent,
            user_input,
            session=chat_session
        )
        print(f"Assistant: {result.final_output}\n")

asyncio.run(main())
```

```typescript
import 'dotenv/config';
import { Composio } from '@composio/core';
import { OpenAIAgentsProvider } from '@composio/openai-agents';
import { Agent, hostedMcpTool, run, OpenAIConversationsSession } from '@openai/agents';
import * as readline from 'readline';

const composioApiKey = process.env.COMPOSIO_API_KEY;
const userId = process.env.USER_ID;

if (!composioApiKey) {
  throw new Error('COMPOSIO_API_KEY is not set. Create a .env file with COMPOSIO_API_KEY=your_key');
}
if (!userId) {
  throw new Error('USER_ID is not set');
}

// Initialize Composio
const composio = new Composio({
  apiKey: composioApiKey,
  provider: new OpenAIAgentsProvider(),
});

async function main() {
  // Create Tool Router session
  const session = await composio.create(userId as string, {
    toolkits: ['lever'],
  });
  const mcpUrl = session.mcp.url;

  // Configure agent with MCP tool
  const agent = new Agent({
    name: 'Assistant',
    model: 'gpt-5',
    instructions:
      'You are a helpful assistant that can access Lever. Help users perform Lever operations through natural language.',
    tools: [
      hostedMcpTool({
        serverLabel: 'tool_router',
        serverUrl: mcpUrl,
        headers: { 'x-api-key': composioApiKey },
        requireApproval: 'never',
      }),
    ],
  });

  // Keep conversation state across turns
  const conversationSession = new OpenAIConversationsSession();

  // Simple CLI
  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    prompt: 'You: ',
  });

  console.log('\nComposio Tool Router session created.');
  console.log('\nChat started. Type your requests below.');
  console.log("Commands: 'exit', 'quit', or 'q' to end\n");

  try {
    const first = await run(agent, 'What can you help me with?', { session: conversationSession });
    console.log(`Assistant: ${first.finalOutput}\n`);
  } catch (e) {
    console.error('Error:', e instanceof Error ? e.message : e, '\n');
  }

  rl.prompt();

  rl.on('line', async (userInput) => {
    const text = userInput.trim();

    if (['exit', 'quit', 'q'].includes(text.toLowerCase())) {
      console.log('Goodbye!');
      rl.close();
      process.exit(0);
    }

    if (!text) {
      rl.prompt();
      return;
    }

    try {
      const result = await run(agent, text, { session: conversationSession });
      console.log(`\nAssistant: ${result.finalOutput}\n`);
    } catch (e) {
      console.error('Error:', e instanceof Error ? e.message : e, '\n');
    }

    rl.prompt();
  });

  rl.on('close', () => {
    console.log('\nSession ended.');
    process.exit(0);
  });
}

main().catch((err) => {
  console.error('Fatal error:', err);
  process.exit(1);
});
```

## Conclusion

This was a starter code for integrating Lever MCP with OpenAI Agents SDK to build a functional AI agent that can interact with Lever.
Key features:
- Hosted MCP tool integration through Composio's Tool Router
- SQLite session persistence for conversation history
- Simple async chat loop for interactive testing
You can extend this by adding more toolkits, implementing custom business logic, or building a web interface around the agent.

## How to build Lever MCP Agent with another framework

- [Claude Agent SDK](https://composio.dev/toolkits/lever/framework/claude-agents-sdk)
- [Claude Code](https://composio.dev/toolkits/lever/framework/claude-code)
- [Claude Cowork](https://composio.dev/toolkits/lever/framework/claude-cowork)
- [Codex](https://composio.dev/toolkits/lever/framework/codex)
- [OpenClaw](https://composio.dev/toolkits/lever/framework/openclaw)
- [Hermes](https://composio.dev/toolkits/lever/framework/hermes-agent)
- [CLI](https://composio.dev/toolkits/lever/framework/cli)
- [Google ADK](https://composio.dev/toolkits/lever/framework/google-adk)
- [LangChain](https://composio.dev/toolkits/lever/framework/langchain)
- [Vercel AI SDK](https://composio.dev/toolkits/lever/framework/ai-sdk)
- [Mastra AI](https://composio.dev/toolkits/lever/framework/mastra-ai)
- [LlamaIndex](https://composio.dev/toolkits/lever/framework/llama-index)
- [CrewAI](https://composio.dev/toolkits/lever/framework/crew-ai)

## Related Toolkits

- [Ashby](https://composio.dev/toolkits/ashby) - Ashby is an applicant tracking system that handles job postings, candidate management, and hiring analytics.
- [Async interview](https://composio.dev/toolkits/async_interview) - Async interview is an on-demand video interview platform for streamlined hiring. Candidates record responses on their schedule, so employers can review anytime.
- [Bamboohr](https://composio.dev/toolkits/bamboohr) - BambooHR is a cloud-based HR management platform for small and mid-sized businesses. It streamlines employee data, HR workflows, and reporting in one easy interface.
- [Breathe HR](https://composio.dev/toolkits/breathehr) - Breathe HR is cloud-based HR software for SMEs to manage employee data, absences, and performance. It simplifies HR admin, making it easy to keep employee records accurate and up to date.
- [Connecteam](https://composio.dev/toolkits/connecteam) - Connecteam is a workforce management platform for deskless teams, streamlining operations, HR, and team communication. It helps businesses save time by automating scheduling, time tracking, and staff engagement tasks.
- [Recruitee](https://composio.dev/toolkits/recruitee) - Recruitee is collaborative hiring software that centralizes recruitment tasks for teams. It streamlines sourcing, interviewing, and hiring so you can fill roles faster.
- [Remote retrieval](https://composio.dev/toolkits/remote_retrieval) - Remote retrieval is a logistics automation tool for managing laptop and monitor returns. It streamlines return tracking, saving time and hassle for IT and ops teams.
- [Sap successfactors](https://composio.dev/toolkits/sap_successfactors) - Sap successfactors is a cloud-based human capital management suite for HR, payroll, recruiting, and talent management. It helps organizations centralize employee data and streamline the entire employee lifecycle.
- [Talenthr](https://composio.dev/toolkits/talenthr) - TalentHR is an intuitive, all-in-one HR tool for managing employee records, leave, and HR workflows. It streamlines HR operations so businesses can focus on people, not paperwork.
- [Workable](https://composio.dev/toolkits/workable) - Workable is an all-in-one HR software platform that streamlines hiring, employee management, and payroll. It helps teams simplify recruiting, onboarding, and staff operations in one place.
- [Workday](https://composio.dev/toolkits/workday) - Workday is a cloud-based ERP platform for HR, finance, and workforce analytics. It streamlines employee management, payroll, and business operations in a single system.
- [Gmail](https://composio.dev/toolkits/gmail) - Gmail is Google's email service with powerful spam protection, search, and G Suite integration. It keeps your inbox organized and makes communication fast and reliable.
- [Google Calendar](https://composio.dev/toolkits/googlecalendar) - Google Calendar is a time management service for scheduling meetings, events, and reminders. It streamlines personal and team organization with integrated notifications and sharing options.
- [Google Drive](https://composio.dev/toolkits/googledrive) - Google Drive is a cloud storage platform for uploading, sharing, and collaborating on files. It's perfect for keeping your documents accessible and organized across devices.
- [Outlook](https://composio.dev/toolkits/outlook) - Outlook is Microsoft's email and calendaring platform for unified communications and scheduling. It helps users stay organized with powerful email, contacts, and calendar management.
- [Twitter](https://composio.dev/toolkits/twitter) - Twitter is a social media platform for sharing real-time updates, conversations, and news. Stay connected, informed, and engaged with communities worldwide.
- [Google Sheets](https://composio.dev/toolkits/googlesheets) - Google Sheets is a cloud-based spreadsheet tool for real-time collaboration and data analysis. It lets teams work together from anywhere, updating information instantly.
- [Supabase](https://composio.dev/toolkits/supabase) - Supabase is an open-source backend platform offering scalable Postgres databases, authentication, storage, and real-time APIs. It lets developers build modern apps without managing infrastructure.
- [Composio](https://composio.dev/toolkits/composio) - Composio is an integration platform that connects AI agents with hundreds of business tools. It streamlines authentication and lets you trigger actions across services—no custom code needed.
- [Notion](https://composio.dev/toolkits/notion) - Notion is a collaborative workspace for notes, docs, wikis, and tasks. It streamlines team knowledge, project tracking, and workflow customization in one place.

## Frequently Asked Questions

### What are the differences in Tool Router MCP and Lever MCP?

With a standalone Lever MCP server, the agents and LLMs can only access a fixed set of Lever tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Lever and many other apps based on the task at hand, all through a single MCP endpoint.

### Can I use Tool Router MCP with OpenAI Agents SDK?

Yes, you can. OpenAI Agents SDK fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Lever tools.

### Can I manage the permissions and scopes for Lever while using Tool Router?

Yes, absolutely. You can configure which Lever scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

### How safe is my data with Composio Tool Router?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Lever data and credentials are handled as safely as possible.

---
[See all toolkits](https://composio.dev/toolkits) · [Composio docs](https://docs.composio.dev/llms.txt)
