Muhammad Ahmad is the founder of Leadloadz, building agent-first B2B lead generation and real-time email verification tooling for modern sales teams.
Author: Muhammad Ahmad
Published: June 23, 2026
Category: Tutorial
---
Why GPT-5, Not Claude?
Everyone talks about Claude agents. And for good reason — Claude's MCP support is excellent. But GPT-5 with function calling plus the Leadloadz MCP server is arguably more powerful for lead generation at scale. Here is why:
Structured output: GPT-5's function calling produces stricter JSON schemas, which means fewer parsing errors when handling lead data
Parallel tool calls: GPT-5 can call `search_leads` and `verify_email` simultaneously, reducing total runtime
Ecosystem: OpenAI's platform has broader third-party integration support
Cost control: GPT-5's API pricing is predictable and scales linearly
This guide walks you through building a fully autonomous lead generation agent using GPT-5, the Leadloadz MCP server, and Python. Setup time: 15 minutes. Results: immediate.
---
Prerequisites
Before you start, you will need:
1. An OpenAI account with GPT-5 API access
2. A Leadloadz account (Free tier is sufficient to start)
3. Python 3.10+ installed
4. Basic familiarity with Python and JSON
---
Step 1: Install Dependencies
Create a virtual environment and install the required packages:
bash
Ready to Supercharge Your Outreach?
Get verified B2B lead lists with 90%+ deliverability and start closing more deals today.
The Leadloadz MCP server is available as an npm package. Install it globally:
bash
npm install -g @leadloadz/mcp-server
Verify it works:
bash
npx @leadloadz/mcp-server --version
You should see version `1.x.x` output.
---
Step 3: Create the Agent Script
Create a file called `lead_agent.py`:
python
import os
import json
import asyncio
from openai import AsyncOpenAI
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
from dotenv import load_dotenv
load_dotenv()
client = AsyncOpenAI(api_key=os.getenv("OPENAI_API_KEY"))
server_params = StdioServerParameters(
command="npx",
args=["-y", "@leadloadz/mcp-server"],
env={"LEADLOADZ_API_KEY": os.getenv("LEADLOADZ_API_KEY")}
)
SYSTEM_PROMPT = """You are an autonomous B2B lead generation agent.
Your job is to find, verify, and organize leads for the user's specified target profile.
Available tools:
- search_leads: Search for B2B contacts by industry, location, company size, and seniority
- verify_email: Verify the deliverability of an email address
- get_user_stats: Check your current usage and plan limits
Rules:
1. Always verify emails before presenting them as final results
2. Only return verified leads
3. Format output as clean markdown tables
4. If rate limited, wait and retry
"""
async def run_agent(user_request: str):
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
# Discover available tools
tools_response = await session.list_tools()
tools = []
for tool in tools_response.tools:
tools.append({
"type": "function",
"function": {
"name": tool.name,
"description": tool.description or "",
"parameters": tool.inputSchema
}
})
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_request}
]
# First GPT-5 call to get tool calls
response = await client.chat.completions.create(
model="gpt-5",
messages=messages,
tools=tools,
tool_choice="auto"
)
message = response.choices[0].message
messages.append(message)
# Execute tool calls
if message.tool_calls:
for tool_call in message.tool_calls:
tool_name = tool_call.function.name
tool_args = json.loads(tool_call.function.arguments)
result = await session.call_tool(tool_name, tool_args)
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"name": tool_name,
"content": result.content[0].text if result.content else "{}"
})
# Second GPT-5 call to synthesize results
final_response = await client.chat.completions.create(
model="gpt-5",
messages=messages
)
return final_response.choices[0].message.content
return message.content
if __name__ == "__main__":
request = input("What leads do you need? ")
result = asyncio.run(run_agent(request))
print("\n" + result)
---
Step 4: Run Your First Search
bash
python lead_agent.py
When prompted, enter:
Find 10 verified SaaS CEOs in Austin, TX with companies of 11-50 employees
The agent will:
1. Call `search_leads` with your parameters
2. Call `verify_email` for each result
3. Return a clean markdown table of verified leads
Sample output:
markdown
| Name | Title | Company | Email | Verified |
|------|-------|---------|-------|----------|
| Sarah Chen | CEO | CloudPath | sarah@cloudpath.io | Yes |
| Mike Ross | CEO | DataLabs | mike@datalabs.com | Yes |
| ... | ... | ... | ... | ... |
---
Step 5: Add Verification and Filtering Logic
For production use, you want stricter filtering. Update the `SYSTEM_PROMPT`:
python
SYSTEM_PROMPT = """You are an autonomous B2B lead generation agent.
Verification rules:
- Only accept emails with verification score >= 95
- Reject disposable emails, catch-all domains, and role accounts
- Reject free email providers (gmail, yahoo, hotmail) for B2B leads
- If verification fails for a lead, do not include it in results
Output format:
- Markdown table with columns: Name, Title, Company, Email, Verification Score
- Summary line: "X verified leads out of Y searched"
- If rate limited, say "Rate limited — retry in 2 minutes"
"""
---
Step 6: Deploy as a Background Agent
For continuous lead generation, schedule the agent with cron or a task runner.
Cron (Linux/Mac)
bash
# Run every weekday at 9 AM
0 9 * * 1-5 cd /path/to/agent && python lead_agent.py <<< "Find fintech leads raised Series A in last 6 months"
Python Schedule Library
python
import schedule
import time
def daily_lead_search():
asyncio.run(run_agent(
"Find 20 verified healthtech CTOs in California"
))
schedule.every().day.at("09:00").do(daily_lead_search)
while True:
schedule.run_pending()
time.sleep(60)
---
Advanced: Multi-Agent Orchestration
For complex workflows, run multiple specialized agents:
The Leadloadz MCP server provides `search_leads`, `verify_email`, and `get_user_stats`
Parallel tool calls in GPT-5 reduce total runtime vs sequential agents
Multi-agent orchestration lets you specialize: research → verify → enrich → outreach
For non-technical users, Claude Desktop may be easier; for developers, GPT-5 offers more control
---
Frequently Asked Questions
1. Do I need a paid OpenAI account?
Yes. GPT-5 API access requires a paid OpenAI account. Costs are typically $0.50-$2.00 per 1,000 leads generated, depending on prompt complexity.
2. Can I run this without knowing Python?
Not easily. For non-technical users, we recommend Claude Desktop with the Leadloadz MCP server instead. See our MCP protocol guide for details.
3. How many leads can I generate per day?
Leadloadz rate limits are 30 requests per minute. At 10 leads per search, you can generate thousands of leads daily. API costs are the real constraint.
4. Is my OpenAI API key secure?
Store it in a `.env` file and never commit it to version control. Use environment variables in production.
5. Can I integrate this with Slack or my CRM?
Yes. Add Slack webhooks or CRM API calls as additional steps in the orchestration pipeline. The agent can push verified leads anywhere.
6. What is the difference between MCP and direct API calls?
MCP handles tool discovery, parameter validation, and error handling automatically. Direct API calls require you to manage all of that yourself.