A Claude Code research agent combines MCP servers for Perplexity and Firecrawl, three business context files, and a plain English agent file. This lesson shows how to set it up so a short prompt returns a structured research brief with competitor gaps, angles and an outline in 3-4 minutes, at under $0.10 a run.
What you will be able to do
- Create a .mcp.json file that connects Perplexity and Firecrawl to Claude Code
- Write business_context.md, content_strategy.md and competitor_watchlist.md, either by letting Claude interview you or by feeding it your existing articles
- Write a plain English agent file with cost optimization rules that cap Perplexity spend
- Run the agent with a one-line intent and read the brief it saves to research-output/
- Fall back to Jina AI when Firecrawl credits run low
Before you start
- Claude Code installed, with a project folder open (lessons 1 to 3 of the course cover this)
- A Firecrawl account (500 free scrapes, no credit card) and its API key
- A Perplexity API key, which needs a credit top-up of $5 minimum
- An editor that can preview markdown: VS Code needs the Markdown Previewer plugin, Cursor previews it natively
Reference
| File or setting | Where it lives | What it does |
|---|---|---|
| .mcp.json | Project root | Defines the perplexity and firecrawl servers and their API keys. Claude Code detects it when you open the project |
| PERPLEXITY_API_KEY | env block in .mcp.json | Key for the Perplexity MCP server (package @modelcontextprotocol/server-perplexity-ask) |
| FIRECRAWL_API_KEY | env block in .mcp.json | Key for the Firecrawl MCP server (package firecrawl-mcp) |
| business_context.md | .claude/research-profiles/ | Who you are, mission, audience avatars, post history, focus areas, local terms to keep |
| content_strategy.md | .claude/research-profiles/ | Content pillars, SEO/AEO focus, brand voice, topics to cover and topics to avoid |
| competitor_watchlist.md | .claude/research-profiles/ | Direct competitors, adjacent competitors, your differentiation statement |
| agents/content-researcher.md | Agent file | Front matter with name, description, tools and model, then Role, Behavior Rules, Cost Optimization and Output Format sections |
| Cost rules in the agent file | Top and bottom of the agent file | Max 3 Perplexity calls per session, batch queries into one call, never use Sonar Deep Research (sonar or sonar-pro only), keep spend under $0.10 per run |
| research-output/ | Project folder | Saves [topic]-brief.json and [topic]-brief.md for each run |
Common errors and fixes
| What goes wrong | The fix |
|---|---|
| The MCP config has an error | Select the .mcp.json file in Claude Code, paste the error message into Claude, and ask it to fix the config |
| Perplexity credits run out within minutes | The Sonar Deep Research model was running on every query. Add the cost rules to the agent file: max 3 calls, batched queries, sonar or sonar-pro only |
| Claude's built-in webfetch fails silently mid-run | Use Firecrawl for competitor scraping, with Perplexity for search, so the run does not stop halfway |
| Firecrawl credits are running low | Fall back to Jina AI, which is free, for page fetching. Say so in the agent file's behavior rules |
| The .md brief is hard to read in VS Code | Install the Markdown Previewer plugin, or use Cursor, which previews markdown natively |
Watch it inside the full course
The whole course is also one long video on YouTube, all 8 lessons in order. Lesson 4 starts at 2:08:04.
Read the written version
The Substack article covers the same build step by step, with the prompts and files to copy. Read Lesson 4 on Substack.
More in this section
Continue the course
See all 8 lessons in the Claude Code Full Course: Build AI Systems Without Writing Code.