Autonomous research agent with web search, source analysis, and report synthesis. Built on Pi agent core. Available as CLI, programmatic API, and MCP server. Features: - 4 built-in tools: web_search, read_url, save_note, synthesize_report - CLI with TUI and print modes - Programmatic API via ResearchAgent class - MCP server with 3 tools: research, quick_search, read_url - Skills system for custom research behavior - Automatic .env file loading for API keys - Configurable max turns, output formats (markdown/JSON/bullet) - Automatic report saving to research-output/
Examples
This directory contains working examples of how to use Pi Research Agent.
Prerequisites
Before running any example, make sure you have:
- Built the project:
npm run build(from the package root) - Set up environment variables in a
.envfile or exported in your shell:TAVILY_API_KEY=your-tavily-key OPENROUTER_API_KEY=your-openrouter-key
Examples
basic.ts
The simplest example — basic programmatic research.
npx tsx examples/basic.ts
custom-model.ts
Using a custom LLM model (GPT-4o instead of the default).
npx tsx examples/custom-model.ts
custom-skills.ts
Adding custom research skills to specialize the agent's behavior.
npx tsx examples/custom-skills.ts
with-env.ts
Loading API keys from a .env file automatically.
npx tsx examples/with-env.ts
mcp-client.ts
Connecting to the MCP server programmatically from another agent.
npx tsx examples/mcp-client.ts
MCP Configuration Files
mcp-config-claude.json
Configuration for Claude Desktop. Copy to:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
mcp-config-cursor.json
Configuration for Cursor. Copy to .cursor/mcp.json in your project root.
Running Examples
All examples use tsx to run TypeScript files directly. You can run them with:
# From the package root
npx tsx examples/<example-name>.ts
# Or with a specific environment variable
TAVILY_API_KEY=*** OPENROUTER_API_KEY=*** npx tsx examples/basic.ts
Output
Examples will:
- Connect to Tavily and OpenRouter APIs
- Run the research workflow
- Print progress to the console
- Save results to
./research-output/ - Display the final report
Troubleshooting
If you get an error about missing API keys:
- Make sure your
.envfile exists in the package root - Or export the variables in your shell before running
If you get a build error:
- Run
npm run buildfirst - Make sure dependencies are installed:
npm install