OpenCode plugin for Perplexity AI web search integration.
This plugin automatically detects when you're asking for web searches or research and nudges the OpenCode agent to use the Perplexity MCP server.
- Automatic detection: Recognizes search-related keywords in your messages
- Smart nudging: Guides the agent to use Perplexity for web searches
- Recency hints: Suggests appropriate time filters for different query types
- Citation support: Encourages including sources in responses
- Perplexity API Key: Get one from Perplexity Settings
- perplexity-mcp: The MCP server that provides the actual search functionality
bunx perplexity-opencode@latest installThis will:
- Prompt for your Perplexity API key
- Create
~/.config/opencode/perplexity.jsonwith your config - Add the plugin to
~/.config/opencode/opencode.json - Configure the Perplexity MCP server
- Add usage instructions to
~/.config/opencode/AGENTS.md
bunx perplexity-opencode@latest install --no-tui --api-key pplx-xxx-
Install the MCP server:
uv tool install perplexity-mcp
-
Add to
~/.config/opencode/opencode.json:{ "plugin": ["perplexity-opencode@latest"], "mcp": { "perplexity": { "type": "local", "command": ["uv", "tool", "run", "perplexity-mcp"], "environment": { "PERPLEXITY_API_KEY": "pplx-xxx" } } } } -
Create
~/.config/opencode/perplexity.json:{ "apiKey": "pplx-xxx", "keywords": { "enabled": true } } -
Restart OpenCode
{
"apiKey": "pplx-xxx",
"keywords": {
"enabled": true,
"customPatterns": ["\\bmy-custom-trigger\\b"]
}
}PERPLEXITY_API_KEY: Your Perplexity API keyPERPLEXITY_DEBUG: Set totruefor debug logging
The plugin activates when it detects phrases like:
Search triggers:
- "search the web", "look up", "find information"
- "what is the latest", "recent news", "current events"
- "who is", "when did", "where is", "how much"
- "compare", "alternatives to", "vs"
- "perplexity", "ask perplexity"
Research triggers (for deeper analysis):
- "deep dive", "comprehensive research"
- "thorough investigation", "in-depth analysis"
- "detailed research", "detailed report"
- Message interception: The plugin hooks into OpenCode's
chat.messageevent - Keyword detection: Scans your message for search-related patterns
- Nudge injection: Adds a synthetic hint message guiding the agent to use Perplexity
- Agent action: The OpenCode agent sees the hint and uses the
perplexity_search_webtool
# Install dependencies
bun install
# Build
bun run build
# Type check
bun run typecheck
# Clean
bun run clean- perplexity-mcp - The MCP server this plugin integrates with
MIT