Files
Emil e196593c84
CI / Lint & Type Check (push) Canceled after 0s
CI / Test (push) Canceled after 0s
Add Pi Research Agent package
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/
2026-06-04 18:12:11 +03:00
..
2026-06-04 18:12:11 +03:00
2026-06-04 18:12:11 +03:00
2026-06-04 18:12:11 +03:00
2026-06-04 18:12:11 +03:00
2026-06-04 18:12:11 +03:00
2026-06-04 18:12:11 +03:00

Examples

This directory contains working examples of how to use Pi Research Agent.

Prerequisites

Before running any example, make sure you have:

  1. Built the project: npm run build (from the package root)
  2. Set up environment variables in a .env file 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:

  1. Connect to Tavily and OpenRouter APIs
  2. Run the research workflow
  3. Print progress to the console
  4. Save results to ./research-output/
  5. Display the final report

Troubleshooting

If you get an error about missing API keys:

  • Make sure your .env file exists in the package root
  • Or export the variables in your shell before running

If you get a build error:

  • Run npm run build first
  • Make sure dependencies are installed: npm install