<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Tommaso Bertocchi - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Tommaso Bertocchi - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Fri, 15 May 2026 09:47:37 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/SonoTommy/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Build an Autonomous OSINT Agent in Python Using Claude's Tool Use API ]]>
                </title>
                <description>
                    <![CDATA[ When I started studying OSINT, I always felt I was just putting random values into software without deeply understanding what I was doing. After months in the field, I realized I wasn't really investi ]]>
                </description>
                <link>https://www.freecodecamp.org/news/build-autonomous-agent-in-python-using-claude/</link>
                <guid isPermaLink="false">6a06669ebaf09db7a64df6cf</guid>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AI ]]>
                    </category>
                
                    <category>
                        <![CDATA[ mcp ]]>
                    </category>
                
                    <category>
                        <![CDATA[ claude ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Tommaso Bertocchi ]]>
                </dc:creator>
                <pubDate>Fri, 15 May 2026 00:19:42 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/uploads/covers/5fc16e412cae9c5b190b6cdd/5890d77b-0678-4c68-a9c3-2304fb2a02ad.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>When I started studying OSINT, I always felt I was just putting random values into software without deeply understanding what I was doing. After months in the field, I realized I wasn't really investigating — I was just executing steps that follow a predictable pattern. That's exactly what an AI agent is good at. So I built one.</p>
<p>In this tutorial you'll learn how to set up OpenOSINT, an open-source Python OSINT framework with an AI agent at its core. You'll learn how Claude's native tool use API works, how to run autonomous investigations from the terminal using the interactive AI REPL, how to use the direct CLI for scripting, and how to expose all the tools to Claude Code or Claude Desktop via an MCP server.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a href="#heading-what-is-osint-and-why-manual-workflows-break-down">What Is OSINT and Why Manual Workflows Break Down</a></p>
</li>
<li><p><a href="#heading-what-youll-build">What You'll Build</a></p>
</li>
<li><p><a href="#heading-prerequisites">Prerequisites</a></p>
</li>
<li><p><a href="#heading-how-claudes-tool-use-api-works">How Claude's Tool Use API Works</a></p>
</li>
<li><p><a href="#heading-how-to-install-openosint">How to Install OpenOSINT</a></p>
</li>
<li><p><a href="#heading-how-to-use-the-interactive-ai-repl">How to Use the Interactive AI REPL</a></p>
</li>
<li><p><a href="#heading-how-to-run-individual-tools-from-the-cli">How to Run Individual Tools from the CLI</a></p>
</li>
<li><p><a href="#heading-how-to-set-up-the-mcp-server">How to Set Up the MCP Server</a></p>
</li>
<li><p><a href="#heading-how-the-agent-loop-works-under-the-hood">How the Agent Loop Works Under the Hood</a></p>
</li>
<li><p><a href="#heading-project-architecture">Project Architecture</a></p>
</li>
<li><p><a href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-what-is-osint-and-why-manual-workflows-break-down">What Is OSINT and Why Manual Workflows Break Down</h2>
<p>Open Source Intelligence (OSINT) is the practice of collecting and analyzing information from publicly available sources. Security researchers use it during penetration tests. Journalists use it to verify identities and trace connections. Threat analysts use it to profile infrastructure.</p>
<p>A typical OSINT workflow looks like this:</p>
<ol>
<li><p>You have a target email address</p>
</li>
<li><p>You run <code>holehe</code> to find which platforms that email is registered on</p>
</li>
<li><p>You notice a username in the output</p>
</li>
<li><p>You manually copy that username and run <code>sherlock</code> to search 300+ platforms</p>
</li>
<li><p>You switch to a browser to check HaveIBeenPwned</p>
</li>
<li><p>You open another tab for a WHOIS lookup</p>
</li>
<li><p>You take notes and repeat</p>
</li>
</ol>
<p>Every tool is a silo. Every pivot is manual. The investigation logic — what to run next, what to chain, what the findings mean — lives entirely in your head.</p>
<p>When you close the terminal, it's gone.</p>
<p>This tutorial walks you through <a href="https://github.com/OpenOSINT/OpenOSINT">OpenOSINT</a>, an open-source Python framework that replaces that fragmented workflow with an AI agent that chains tools autonomously, executes them against real binaries, and saves a structured Markdown report.</p>
<p>More importantly, you'll learn the core design principle that makes it trustworthy for security research: <strong>hallucination in tool results is structurally impossible</strong>.</p>
<h2 id="heading-what-youll-build">What You'll Build</h2>
<p>By the end of this tutorial, you'll have a working OSINT agent that you can use in three ways:</p>
<ul>
<li><p><strong>Interactive AI REPL</strong> — type a target in natural language and the agent decides what to run</p>
</li>
<li><p><strong>Direct CLI</strong> — run individual tools without AI, useful for scripting</p>
</li>
<li><p><strong>MCP Server</strong> — expose all tools to Claude Code or Claude Desktop</p>
</li>
</ul>
<p>Here's what a real session looks like:</p>
<pre><code class="language-plaintext">$ openosint
openosint ❯ investigate target@example.com

  → generate_dorks('target@example.com')
  → search_email('target@example.com')
  ✓ Found: Spotify, WordPress, Gravatar, Office365

  → search_breach('target@example.com')
  ✓ Found in 2 breaches: LinkedIn (2016), Adobe (2013)

  → search_username('target_handle')
  ✓ Found on: GitHub, Reddit, HackerNews, Twitter

  ╭──────────────── Report ────────────────╮
  │ ## Online Presence                     │
  │ Spotify · WordPress · Gravatar         │
  │                                        │
  │ ## Data Breaches                       │
  │ LinkedIn (2016) · Adobe (2013)         │
  ╰────────────────────────────────────────╯

  ✓ Report saved → reports/2026-05-11_report.md
</code></pre>
<p>The agent went from email → linked accounts → username pivot → cross-platform search with no human orchestration at any step.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>To follow this tutorial, you'll need:</p>
<ul>
<li><p>Python 3.10 or later installed on your machine</p>
</li>
<li><p>Basic familiarity with the command line</p>
</li>
<li><p>An <a href="https://console.anthropic.com/">Anthropic API key</a> — only required for the AI REPL, not for the CLI or MCP server</p>
</li>
<li><p>Git installed</p>
</li>
</ul>
<p>You don't need prior experience with OSINT tools or the Anthropic SDK.</p>
<h2 id="heading-how-claudes-tool-use-api-works">How Claude's Tool Use API Works</h2>
<p>Before you dive into installation, it's worth understanding the mechanism that makes this framework trustworthy for security research.</p>
<p>Most AI applications that wrap external tools work by generating text that describes what a tool <em>would</em> return. That's a problem when accuracy matters — the model can hallucinate plausible-looking usernames, fake subdomains, or data breaches that never happened.</p>
<p>Claude's tool use API works differently. When the model decides it needs to call a tool, it does <strong>not</strong> generate the output. It stops and emits a structured <code>tool_use</code> block containing the tool name and the arguments it wants to pass.</p>
<p>Your code then runs the actual binary — <code>holehe</code>, <code>sherlock</code>, or whatever else — and sends the real output back as a <code>tool_result</code>. The model reads that real output and decides its next step.</p>
<p>Here's the flow:</p>
<pre><code class="language-plaintext">User prompt
    ↓
Model decides to call search_email()
    ↓
Hard stop — model emits tool_use block
    ↓
Your code runs holehe against the real target
    ↓
Real output sent back as tool_result
    ↓
Model reads actual results, decides next step
    ↓
Repeat until investigation is complete
</code></pre>
<p>The model never generates tool output. It only ever reads it. If <code>sherlock</code> finds 12 profiles, those 12 URLs go back into the context verbatim. The model cannot add a 13th that doesn't exist.</p>
<p>This is not a prompting trick or a system prompt instruction. It is how the API is architected. Keep this in mind as you read through the agent loop code later in this tutorial.</p>
<h2 id="heading-how-to-install-openosint">How to Install OpenOSINT</h2>
<p>Start by cloning the repository and installing the package:</p>
<pre><code class="language-bash">git clone https://github.com/OpenOSINT/OpenOSINT.git
cd OpenOSINT
pip install -e .
</code></pre>
<p>Alternatively, if you just want to use the tool without modifying the source, install it directly from PyPI:</p>
<pre><code class="language-bash">pip install openosint
</code></pre>
<p>Next, set your Anthropic API key. This is only required for the interactive AI REPL — the direct CLI and MCP server work without it:</p>
<pre><code class="language-bash">export ANTHROPIC_API_KEY=sk-ant-...
</code></pre>
<h3 id="heading-how-to-install-the-external-tool-dependencies">How to Install the External Tool Dependencies</h3>
<p>OpenOSINT wraps several standalone OSINT tools. Install the ones you plan to use:</p>
<pre><code class="language-bash">pip install holehe            # email account enumeration
pip install sherlock-project  # username search across 300+ platforms
pip install sublist3r         # subdomain enumeration
</code></pre>
<p>For phone intelligence, <code>phoneinfoga</code> is a standalone binary. Download the release for your platform from its <a href="https://github.com/sundowndev/phoneinfoga/releases">GitHub releases page</a> and place it somewhere in your <code>PATH</code>.</p>
<h3 id="heading-how-to-configure-optional-api-keys">How to Configure Optional API Keys</h3>
<p>Two tools work at higher rate limits with optional API keys:</p>
<pre><code class="language-bash">export HIBP_API_KEY=your_key    # required for breach checks via HaveIBeenPwned v3
export IPINFO_TOKEN=your_token  # optional — raises ipinfo.io rate limits
</code></pre>
<p>If a binary is missing or an API key is not configured, that specific tool returns a descriptive error string. All other tools continue to work normally.</p>
<h2 id="heading-how-to-use-the-interactive-ai-repl">How to Use the Interactive AI REPL</h2>
<p>Run <code>openosint</code> with no arguments to start the AI-powered REPL. You can also use <code>openosint shell</code> — it's equivalent:</p>
<pre><code class="language-bash">$ openosint
# or
$ openosint shell
</code></pre>
<p>If you prefer to pass the API key inline rather than via environment variable, use the <code>--api-key</code> flag:</p>
<pre><code class="language-bash">$ openosint --api-key sk-ant-...
</code></pre>
<p>You'll get a prompt where you can type targets or questions in natural language:</p>
<pre><code class="language-plaintext">openosint ❯ investigate target@example.com
openosint ❯ find all accounts for johndoe99
openosint ❯ what subdomains does example.com have?
openosint ❯ check if +14155552671 is a mobile number
</code></pre>
<p>The agent decides which tools to run based on your input. You don't need to specify which tools to use or in what order. If you type an email address, the agent will run email enumeration. If it finds a linked username, it may pivot and search that username across platforms.</p>
<p>Reports are saved automatically to the <code>reports/</code> directory after every investigation that produces structured findings.</p>
<p>Here are the commands available inside the REPL:</p>
<table>
<thead>
<tr>
<th>Command</th>
<th>Description</th>
</tr>
</thead>
<tbody><tr>
<td><code>clear</code></td>
<td>Reset the conversation memory</td>
</tr>
<tr>
<td><code>save</code></td>
<td>Manually save the last report</td>
</tr>
<tr>
<td><code>tools</code></td>
<td>Show available tools and their status</td>
</tr>
<tr>
<td><code>config</code></td>
<td>Show current configuration</td>
</tr>
<tr>
<td><code>help</code></td>
<td>List all commands</td>
</tr>
<tr>
<td><code>exit</code> or Ctrl-D</td>
<td>Quit</td>
</tr>
</tbody></table>
<h2 id="heading-how-to-run-individual-tools-from-the-cli">How to Run Individual Tools from the CLI</h2>
<p>If you want to run a single tool without the AI layer — for scripting, automation, or quick lookups — use the direct CLI:</p>
<pre><code class="language-bash"># Email account enumeration (default timeout: 120s)
openosint email target@example.com

# With a custom timeout in seconds
openosint email target@example.com -t 60

# Username search across 300+ platforms (default timeout: 180s)
openosint username johndoe99

# Enable verbose output for debugging
openosint -v email target@example.com
</code></pre>
<p>The direct CLI doesn't require an Anthropic API key. It runs the underlying binary and prints the output to the terminal.</p>
<p>This mode is useful when you need predictable, scriptable behavior — for example, piping output into another tool or running automated checks.</p>
<h2 id="heading-how-to-set-up-the-mcp-server">How to Set Up the MCP Server</h2>
<p>OpenOSINT also ships as a Model Context Protocol (MCP) server. This exposes all 9 tools to any MCP-compatible AI client.</p>
<h3 id="heading-how-to-register-with-claude-code">How to Register with Claude Code</h3>
<pre><code class="language-bash">claude mcp add openosint python /absolute/path/to/OpenOSINT/openosint/mcp_server.py
</code></pre>
<p>Verify the registration worked:</p>
<pre><code class="language-bash">claude mcp list
</code></pre>
<p>Once registered, you can drive investigations from the Claude Code prompt:</p>
<pre><code class="language-plaintext">&gt; Investigate target@example.com. If you find a linked username,
  trace it across other platforms and compile a full report.
</code></pre>
<h3 id="heading-how-to-configure-claude-desktop">How to Configure Claude Desktop</h3>
<p>Add the following to your Claude Desktop config at <code>~/Library/Application Support/Claude/claude_desktop_config.json</code>:</p>
<pre><code class="language-json">{
  "mcpServers": {
    "openosint": {
      "command": "python",
      "args": ["/absolute/path/to/OpenOSINT/openosint/mcp_server.py"]
    }
  }
}
</code></pre>
<p>Restart Claude Desktop after saving the file. The tools will appear in Claude's tool list.</p>
<p>The MCP server uses stdio transport and does not need a persistent background process. Claude Code or Claude Desktop starts it on demand.</p>
<h2 id="heading-how-the-agent-loop-works-under-the-hood">How the Agent Loop Works Under the Hood</h2>
<p>Here is a simplified version of the agent loop from <code>openosint/agent.py</code>:</p>
<pre><code class="language-python">import anthropic
import asyncio

client = anthropic.Anthropic()

async def run_investigation(user_prompt: str) -&gt; str:
    messages = [{"role": "user", "content": user_prompt}]

    while True:
        response = client.messages.create(
            model="claude-...",   # model configured via --api-key / env var
            max_tokens=4096,
            tools=TOOL_SCHEMAS,   # JSON schemas for all 9 tools
            messages=messages
        )

        # Agent is done — extract and return the final report
        if response.stop_reason == "end_turn":
            return extract_text(response)

        # Agent needs a tool — run the real binary
        if response.stop_reason == "tool_use":
            tool_results = []

            for block in response.content:
                if block.type == "tool_use":
                    # Runs holehe, sherlock, etc. as real subprocesses
                    real_output = await execute_tool(block.name, block.input)

                    tool_results.append({
                        "type": "tool_result",
                        "tool_use_id": block.id,
                        "content": real_output  # real output, never generated
                    })

            # Append assistant turn and real tool results to conversation
            messages.append({"role": "assistant", "content": response.content})
            messages.append({"role": "user", "content": tool_results})
</code></pre>
<p>There are a few important things to understand in this code.</p>
<ol>
<li><p><strong>The loop runs until</strong> <code>stop_reason == "end_turn"</code>: The agent decides when it has gathered enough information to write the final report. It may call one tool or ten, depending on what it finds.</p>
</li>
<li><p><code>execute_tool()</code> <strong>runs real subprocesses</strong>: It's a thin async wrapper around Python's <code>asyncio.create_subprocess_exec()</code> with a configurable timeout. There's no simulation and no mocked data at any point.</p>
</li>
<li><p><strong>Conversation history is maintained across the entire loop</strong>: Each tool result goes back into <code>messages</code>, so the model always has full context of what it found when deciding what to run next.</p>
</li>
<li><p><strong>Tool schemas are defined as JSON</strong>: Each tool has a name, description, and parameter schema. The model uses these to know what tools exist and what arguments they accept. Here's a simplified example for <code>search_email</code>:</p>
</li>
</ol>
<pre><code class="language-python">{
    "name": "search_email",
    "description": (
        "Enumerates online services and social accounts "
        "associated with an email address using holehe."
    ),
    "input_schema": {
        "type": "object",
        "properties": {
            "email": {
                "type": "string",
                "description": "Target email address"
            }
        },
        "required": ["email"]
    }
}
</code></pre>
<p>The same pattern applies to all 9 tools. The model reads these schemas at the start of every request and uses them to decide what's available and how to call it.</p>
<h2 id="heading-project-architecture">Project Architecture</h2>
<p>The codebase is organized in five layers. The hard rule across the codebase is that no layer imports from a layer above it:</p>
<pre><code class="language-plaintext">openosint/tools/        Core tools
                        Async wrappers around external binaries and APIs.
                        Stateless. No AI. No CLI. Pure functions.

openosint/agent.py      AI agent
                        Anthropic tool use loop.
                        Per-session conversation history.
                        Imports from tools/. Nothing imports from agent.py.

openosint/repl.py       Interactive REPL (prompt_toolkit + Rich)
openosint/mcp_server.py MCP server (stdio transport)
openosint/cli.py        CLI entry point
</code></pre>
<p>This separation makes each layer independently testable. The core tools are pure async functions that take a string and return a string — you can unit test them without touching the agent or the CLI.</p>
<p>It also means the AI layer is entirely optional. If you don't have an Anthropic API key, you use the CLI and bypass the agent. The MCP server also operates independently of the agent.</p>
<h3 id="heading-the-9-available-tools">The 9 Available Tools</h3>
<table>
<thead>
<tr>
<th>Tool</th>
<th>Backend</th>
<th>What it returns</th>
</tr>
</thead>
<tbody><tr>
<td><code>search_email</code></td>
<td>holehe</td>
<td>Social accounts linked to an email</td>
</tr>
<tr>
<td><code>search_username</code></td>
<td>sherlock</td>
<td>Accounts across 300+ platforms</td>
</tr>
<tr>
<td><code>search_breach</code></td>
<td>HaveIBeenPwned v3</td>
<td>Breach names, dates, leaked data types</td>
</tr>
<tr>
<td><code>search_whois</code></td>
<td>python-whois</td>
<td>Registrant, registrar, creation/expiry</td>
</tr>
<tr>
<td><code>search_ip</code></td>
<td>ipinfo.io</td>
<td>Geolocation, ASN, hostname, org</td>
</tr>
<tr>
<td><code>search_domain</code></td>
<td>sublist3r</td>
<td>Subdomain enumeration</td>
</tr>
<tr>
<td><code>generate_dorks</code></td>
<td>built-in</td>
<td>12 targeted Google dork URLs, no network calls</td>
</tr>
<tr>
<td><code>search_paste</code></td>
<td>psbdmp.ws</td>
<td>Pastebin dump mentions</td>
</tr>
<tr>
<td><code>search_phone</code></td>
<td>phoneinfoga</td>
<td>Carrier, country, line type</td>
</tr>
</tbody></table>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this tutorial, you learned how to set up and use OpenOSINT — a Python OSINT framework built on Claude's tool use API.</p>
<p>The key takeaway is the design principle: by using native tool use, the agent never generates tool output. It only reads real output from real binaries. This makes it suitable for security research where accuracy matters and hallucination isn't an acceptable failure mode.</p>
<p>To recap the three interfaces:</p>
<ul>
<li><p>Run <code>openosint</code> for the interactive AI REPL — best for full investigations with automatic chaining</p>
</li>
<li><p>Run <code>openosint email</code> or <code>openosint username</code> for direct CLI access — best for scripting and automation</p>
</li>
<li><p>Register the MCP server in Claude Code or Claude Desktop to run investigations inside your existing AI environment</p>
</li>
</ul>
<p>The full source code is available on <a href="https://github.com/OpenOSINT/OpenOSINT">GitHub</a> under the MIT license. Contributions and issues are welcome.</p>
<p><strong>Legal note</strong>: OpenOSINT is for authorized security research, penetration testing, and investigative journalism only. Users are solely responsible for compliance with applicable law, including GDPR, CCPA, and the CFAA. See the <a href="https://github.com/OpenOSINT/OpenOSINT/blob/main/DISCLAIMER.md">DISCLAIMER.md</a> for the full notice.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
