The Good Tech Companies - MCP + OpenAI Agents SDK: How to Build a Powerful AI Agent

Episode Date: May 27, 2025

This story was originally published on HackerNoon at: https://hackernoon.com/mcp-openai-agents-sdk-how-to-build-a-powerful-ai-agent. Let's see how to integrate the OpenA...I Agents SDK library with a real-world MCP server for AI agent development Check more stories related to machine-learning at: https://hackernoon.com/c/machine-learning. You can also check exclusive content about #ai-agent, #ai, #mcp, #python, #bright-data, #mcp-+-openai-agents, #openai-agents-sdk, #good-company, and more. This story was written by: @brightdata. Learn more about this writer by checking @brightdata's about page, and for more stories, please visit hackernoon.com. OpenAI’s new Agents SDK simplifies building goal-driven AI agents, while MCP (Model Context Protocol) gives them real-world data access. This guide shows how to combine them using Bright Data’s MCP server and Gemini LLM to build powerful, context-aware agents.

Transcript
Discussion (0)
Starting point is 00:00:00 This audio is presented by Hacker Noon, where anyone can learn anything about any technology. MCP plus OpenAI Agents SDK. How to build a powerful AI agent, by Bright Data. When OpenAI dropped their Agents SDK a few weeks ago, devs everywhere gothiped, and for good reason. Finally, a straightforward way to build goal-driven AI agents that can actually reason and get work done exploding head. But almost in the same breath, MCP exploded onto the scene, quickly becoming the next hot trend in this wild AI landscape. So, why not smash these two powerhouses together? That's precisely what we're about to do right here Fire. In this guide, we're going to forge a formidable AI agent leveraging the openAI Agents SDK and plugging it directly into the real-world tools provided by an MCP server.
Starting point is 00:00:49 Get ready to supercharge your AI. A quick intro to MCP plus OpenAI Agents SDK integration. OpenAI Agents SDK is one of the most popular Python toolkits for crafting intelligent AI agents, letting them reason and act. But here's the kicker, without external info, they're often stuck in a training data bubble. That's where MCP, Model Context Protocol, swoops in. Think of MCP as the universal USB-C port for your AI, giving it a standardized way to plug into any external data source or tool local files, APIs, databases, you name it.
Starting point is 00:01:25 Electric plug integrating MCP with the OpenAI Agents SDK means your agents get real-time, dynamic context, turning them from smart but isolated bots into powerhouse data explorers and action-takers. Brain building an AI agent with MCP integration using OpenAI Agents SDK. Alright, enough theory, you get it. MCP supercharges AI agents like their Ironman in his iconic metal suit. Mechanical arm in this step-by-step section, we're going to use the OpenAI agents SDK. Yep.
Starting point is 00:01:56 The new Python SDK from OpenAI for building an AI agent with MCP integration. Why OpenAI agents SDK and not another library? Because it has native MCP support, which means your agent can go from smart to superpowered in seconds. Now, small catch. OpenAI's API isn't free. Cold sweat smile so in this guide, we'll runitis ingeimani as the LLM engine instead, don't worry.
Starting point is 00:02:23 We'll show how to swap an open AI or any other model to repeat button. Question mark, but wait, what MCP server are we using? Question mark, great question. To get started fast, we're plugging into Bright Data MCP server, an MCP server built for web automation and data tasks. It lets your AI agent search, browse, take action,
Starting point is 00:02:44 and extract real-time data from the web with built-in stealth to dodge captures and anti-bot traps. Specifically, below are all the tools supported by the bright data MCP server hammer and wrench. Tool description scrape SERP data from Google, Bing, Yandex, and more. Scrape a URL and return content in clean markdown. Scrape a URL and return full HTML content view tool usage during the current session. Get Amazon product info by URL. Fetch Amazon reviews for a product. Grab LinkedIn profile data. Fetch LinkedIn company data. Get Zoom info company profile. Fetch Instagram profile details. Get Instagram post data. Grab Instagram
Starting point is 00:03:22 real data. Fetch comments from an Instagram post extract Facebook post info get Facebook marketplace listings scrape Facebook business reviews fetch data from ex formerly Twitter posts get Zillow property listings fetch booking In a virtual browser, go back one page in the browser, go forward one page in the browser, click a page element, need selector. Get all links and selectors on the page type into a form or input, wait for an element to appear, capture a screenshot of the current page, get raw HTML from the page, extract text content from the page, ready to roll? See how to get your AI agent talking to the MCP server for unlimited power. High Voltage High Voltage Step Number 1 AI agent talking to the MCP server for unlimited power. High voltage, high voltage step number one. Project setup to follow along with this tutorial section. Make sure you've got the following prerequisites in place. Python 3. 10 plus installed locally snake.
Starting point is 00:04:16 Node. JS installed locally green square. An API key from a supported LLM provider for the open AI agents SDK. We recommend Gemini for this one, key. We'll skip the boring setup fluff and assume you've already created a Python project with this structure. Now, activate your virtual environment, and install the required packages. Where, is the OpenAI Agents Python SDK?
Starting point is 00:04:41 Your gateway to AI Agent Magic Magic Wand, is for reading values from a file closed lock. Next, open and wire up your imports. Time to read in those environment variable sand prep for agent launch, bomb boom. You're up and running with the basics. Step number two. Get started with the bright data MCP server so, you want your AI agent to talk to an MCP server? Drum drum drum well, guess what, you'll need an MCP server running first, yes, captain
Starting point is 00:05:10 obvious reporting for duty. Saluting face, as mentioned earlier, we'll be using the Bright Data MCP server for this part. First, grab your API key and initialize the server as per the official Bright Data MCP server docs. Once you're ready, launch the server with this command. If everything's configured correctly, you should see output similar to this. Nice.
Starting point is 00:05:34 Surfing now, set up the environment variables that the agent will use to connect to the Bright Data MCP Server. Open your file and add these two lines. Replace the placeholders with the values you got as explained in the Bright Data MCP Server docs. Back in, read in those two ENVs like so. We'll use these values shortly when initializing the MCP connection from code. Test tube and just like that, bam collision, your MCP server is up, running, and ready to serve your AI agent like a loyal sidekick.
Starting point is 00:06:12 Onward. Step number 3. Create your AIAGENTAs teased in the intro of this section, we're going to use Gemini, yep, GoogleShiny LLM, with the OpenAI agent's SDK. First off, can you even do that? And second, why not just use OpenAI directly? Thinking face response. Yes, you can do that. Thumbs up Gemini exposes an OpenAI compatible API, which means you can plug it right into the OpenAI agent's SDK like a drop in replacement. The best part? It's free, unlike OpenAI, which likes to charge you be the token. Flying money so, here's why it makes sense to use Gemini instead of OpenAI directly. Light bulb enough chit chat, let's wire things up high voltage. First, grab your Gemini API key from Google AI Studio and pop it into your file. Then, in, read that key like so. Now, build a function that ties everything together, the Gemini model, OpenAI SDK, and the MCP server,
Starting point is 00:07:05 which we'll configure in the code soon stopwatch. If you want to use a different supported model, like Claude, Mistral, or other models, just swap the in model name accordingly. Plus extra. Want to use OpenAI instead? No problem. Just add your and replace the above logic with, easy swap, same interface. That's the beauty of the SDK. Cool. Oh, and if you're wondering where the argument comes from, we'll initialize it in the next step.
Starting point is 00:07:33 I spoiler alert. Keep reading. Step number four, initialize the MCP server inside your async function. Spin up the bright data MCP server using like this gear. What's happening here? This launches the MCP server using, passing in your credentials via environment variables. Note. Don't forget to bump to seconds. Default is, because real-time scraping, captcha solving, and anti-bot ninja moves performed by the Bright Data MCP server takes time ninja.
Starting point is 00:08:03 You don't want it timing out mid-mission. Check mark suite. The only thing left is to kick off the AI agent loop. Let's wrap ITUP. Step number 5. Define the AI agent loop inside the MCP server async block. Drop in a REPL. Read eval print. Loop sousers can type in their requests. Send them through the MCP powered agent, and jet back the magic sparkles. This little python snippet is your AI agent's command center. It continuously grabs your requests, feeds them to the agent, and then spits out the final, glorious result. Think of it as the no-frills console for your AI brain, ready
Starting point is 00:08:41 to take orders until you tell it to, exit, hand waving. Did you just have that, woah, moment? If not, let me spell it out for you. You just wired up a full AI agent loop using the OpenAI Agents SDK plus Bright.isMCP server plus Gemini. Now you're ready to look at the full code, all stitched together like a beautiful Frankenstein's monster of AI automation. Troll step number 6.
Starting point is 00:09:05 Put it all together this is your final python script for openAI agents SDK plus MCP integration. Powered by Gemini to save money money mouth face. Bulls eye just 81 lines of code. And what do you get? An AI agent that can surf the web, bypass anti-bots, grabs real-time data, and talks back, like it's no big deal. Even Superman might get jealous of this one. Man superhero thanks to new AI protocols and dev-first tools like OpenAI Agents SDK and
Starting point is 00:09:34 Bright Data MCP, AI automation is now almost too easy. Step number 7. Test the MCP-powered AI agent run your AI agent from the terminal with, or on Linux, Mac OS. You'll be greeted by a friendly prompt like, for example, try asking the agent what MCP tools it has, you'll get back something like, as you can see, your AI agent is aware of all the bright data MCP tools it can connect to, and it's ready to use them, alright, time to unleash the beast. Let's put those shiny MCP tools to the ultimate test.
Starting point is 00:10:09 Command your AI agent to scrape some juicy data from the Amazon P5 page video game. To achieve that, give it a prompt like, execute it and the result will be. In particular, the output should be something like, exploding head wow, exploding head one prompt, and you just scraped all the data from an Amazon product page. And not just any site, Amazon is notoriously tough to scrape thanks to aggressive captures and anti-bot defenses. So, how did that work? Behind the scenes, the AI agent called on the MCP tool, one of the pre-built power tools exposed by the bright data MCP server. It handled the dirty work, solving captures, bypassing bod detection, and fetching the goods. And it doesn't stop there, that scraped data? You can use it to ask the AI agent for further
Starting point is 00:10:56 analysis by crafting more complex prompts. After all, AI agent can freely choose and chain together tools from its MCP-powered toolkit, so the possibilities are truly endless. Infinity with a setup this powerful, the world is yours. Just don't go full Tony Montana cold sweat smile, final thoughts. Now you know how to supercharge any AI Agent built with the OpenAI Agent's SDK, whether it's running on GPT, Gemini, or whatever's next, by plugging it into an MCP server. In detail, we tapped into the powerful Bright Data MCP server, just one of the many
Starting point is 00:11:32 services we've built to support real-world AI workflows at scale. At Bright Data, our mission is simple. Make AI accessible for everyone, everywhere. So until next time, stay curious, stay bold, and keep building the future of AI with creativity. Globe thank you for listening to this Hacker Noon story, read by Artificial Intelligence. Visit HackerNoon.com to read, write, learn and publish.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.