How mcporter Integrates with Exa for Semantic Web Search in Agent Reach
Agent Reach delegates semantic web search to Exa via the mcporter MCP client, which bridges local CLI commands to Exa's hosted search service.
The Agent Reach repository (Panniantong/Agent-Reach) does not implement its own search engine. Instead, it leverages Exa, a hosted semantic search service, through mcporter—an MCP (Micro-Command-Protocol) client that exposes remote services as local CLI commands. This architecture allows Agent Reach to offer powerful semantic web search capabilities without embedding proprietary search code.
Understanding the mcporter-to-Exa Architecture
mcporter functions as a local MCP client that runs as a CLI tool. When installed globally (npm install -g mcporter), it can call remote MCP services and expose them as local commands. Exa operates as the remote service provider, hosting its MCP endpoint at https://mcp.exa.ai/mcp.
Agent Reach interacts with this stack by invoking the local mcporter executable, which translates these calls into HTTP requests to Exa's API. The raw JSON responses are then piped back through mcporter and parsed by Agent Reach's channel implementation.
Configuring the Exa MCP Endpoint
Before Agent Reach can search, the mcporter configuration must register the Exa endpoint. Users run the following command to add the service:
mcporter config add exa https://mcp.exa.ai/mcp
This entry is stored in mcporter's local configuration and enables the CLI to invoke Exa RPCs. Detailed setup instructions are documented in the user guide at agent_reach/guides/setup-exa.md.
Core Search Methods Available via mcporter
Once configured, mcporter exposes two primary Exa search methods that Agent Reach utilizes:
exa.web_search_exa(query: "...", numResults: N)– Returns a list of web results containing snippets, URLs, and titles for general semantic queries.exa.get_code_context_exa(query: "...", tokensNum: M)– Returns code-relevant passages optimized for programming questions.
These method signatures are documented in the skill reference files at agent_reach/skill/references/search.md and agent_reach/skill/SKILL.md.
The Agent Reach Channel Implementation
The integration logic resides in agent_reach/channels/exa_search.py. This channel first validates that mcporter is installed and configured for Exa:
probe = probe_command("mcporter", ["config", "list"], timeout=10, package="mcporter")
if not probe.ok or "exa" not in probe.output:
# hint user to install / configure mcporter
The probe_command helper, defined in agent_reach/utils/process.py, wraps subprocess execution and captures stdout/stderr with UTF-8 encoding flags via mcporter_utf8_env_args() to prevent encoding issues.
When executing a search, the channel runs:
result = probe_command(
"mcporter",
["call", "exa.web_search_exa(query:\"{q}\",numResults:{n})"],
timeout=15,
)
The raw JSON returned by Exa is parsed and presented to the caller.
End-to-End Integration Flow
The complete data flow from user query to search results follows this path:
- User code calls Agent Reach Core
- Agent Reach Core invokes
ExaSearchChannel.search() - The channel calls
probe_commandto execute the local mcporter executable - mcporter sends an HTTP request to the Exa MCP endpoint
- Exa returns ranked, semantic results
- mcporter pipes the JSON response back to the channel
- Agent Reach parses the JSON and returns structured results to the user
Practical Usage Examples
High-Level Python API
from agent_reach.core import AgentReach
ar = AgentReach()
results = ar.search("latest AI research papers 2024", num_results=5, include_domains=["arxiv.org"])
for r in results:
print(r.title, r.url, r.snippet)
Manual CLI Usage
$ mcporter call 'exa.web_search_exa(query: "quantum computing breakthroughs", numResults: 3)'
Direct Low-Level Call
from agent_reach.utils.process import probe_command
resp = probe_command(
"mcporter",
["call", "exa.web_search_exa(query:\"OpenAI GPT-4\",numResults:2)"],
timeout=10,
)
print(resp.output) # JSON string from Exa
Installation Helpers
Agent Reach also provides automated setup via agent_reach/cli.py, which contains the _install_mcporter and _install_mcporter_safe functions to handle package installation and Exa MCP configuration.
Summary
- mcporter acts as a local MCP client that bridges Agent Reach to Exa's hosted semantic search service.
- Configuration requires running
mcporter config add exa https://mcp.exa.ai/mcpto register the Exa endpoint. - The
ExaSearchChannelclass inagent_reach/channels/exa_search.pyvalidates mcporter availability and executes searches viaprobe_command. - Two primary methods are exposed:
web_search_exafor general web content andget_code_context_exafor code-specific queries. - The
probe_commandutility inagent_reach/utils/process.pyhandles subprocess execution with proper UTF-8 encoding viamcporter_utf8_env_args.
Frequently Asked Questions
What is mcporter in the context of Agent Reach?
mcporter is an MCP (Micro-Command-Protocol) client that runs as a local Node.js CLI tool. In Agent Reach, it serves as the bridge that translates local command-line calls into HTTP requests to Exa's remote MCP endpoint, enabling semantic web search without requiring direct API integration code in the Agent Reach repository.
How does Agent Reach verify that mcporter is properly configured?
Agent Reach checks mcporter configuration through the ExaSearchChannel in agent_reach/channels/exa_search.py. It executes probe_command("mcporter", ["config", "list"], ...) and verifies that the string "exa" appears in the output, confirming that the Exa MCP endpoint has been registered.
What are the specific Exa search methods available through mcporter?
According to the skill documentation in agent_reach/skill/references/search.md, mcporter exposes exa.web_search_exa(query, numResults) for general semantic web searches and exa.get_code_context_exa(query, tokensNum) for retrieving code-specific context. Both methods return JSON data that Agent Reach parses into structured results.
How does the integration handle character encoding issues?
The integration prevents encoding errors through the mcporter_utf8_env_args() function in agent_reach/utils/process.py, which sets UTF-8 environment flags when spawning the mcporter subprocess. This ensures that search results containing international characters or special symbols are correctly captured and parsed.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →