Skip to content

fix: skip cloud-only research tools on self-hosted instances - #342

Open
Mohith26 wants to merge 2 commits into
firecrawl:mainfrom
Mohith26:fix/research-search-papers-self-hosted
Open

fix: skip cloud-only research tools on self-hosted instances#342
Mohith26 wants to merge 2 commits into
firecrawl:mainfrom
Mohith26:fix/research-search-papers-self-hosted

Conversation

@Mohith26

@Mohith26 Mohith26 commented Jul 29, 2026

Copy link
Copy Markdown

Fixes #341, reported by @inv-Eldho (same report as firecrawl/firecrawl#4166).

The five firecrawl_research_* tools wrap /v2/search/research/* endpoints that only exist on the cloud API, so on self-hosted Firecrawl every call returned a bare 404.

The fix skips registering those tools at startup when FIRECRAWL_API_URL points at a self-hosted instance (anything other than the trailing-slash-normalized cloud URL), logging a stderr notice in the same style as the existing keyless-mode notice. The CLOUD_SERVICE === 'true' exemption keeps the hosted deployment untouched, since it fronts a backend via the same env var (the existing search-profile tests pin that behavior).

Two new stdio smoke tests lock in the gating: tools absent + notice on self-hosted, present with an explicit cloud URL. The gating test fails without the fix. Suite: 61 passed, zero new failures; eslint clean.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Skip registering cloud-only research tools on self-hosted Firecrawl to avoid 404s when FIRECRAWL_API_URL points to a non-cloud instance. This keeps the tool list accurate and prevents broken calls.

  • Bug Fixes
    • Added gating: if FIRECRAWL_API_URL (trimmed) is not https://api.firecrawl.dev and CLOUD_SERVICE is not 'true', do not register firecrawl_research_* tools. Write a clear stderr notice explaining why.
    • Added stdio smoke tests: self-hosted hides the tools and logs the notice; an explicit cloud URL keeps the tools registered.

Written for commit 9c94f49. Summary will update on new commits.

Review in cubic

Mohith26 added 2 commits July 29, 2026 11:48
The firecrawl_research_* tools wrap the /v2/search/research/* endpoints,
which only exist on the Firecrawl cloud API. When FIRECRAWL_API_URL points
at a self-hosted instance, every research call fails with a bare 404
(e.g. firecrawl_research_search_papers in firecrawl#341).

Skip registering the research tools when the configured target is
self-hosted (FIRECRAWL_API_URL set to something other than the cloud API,
outside the hosted CLOUD_SERVICE deployment, which also sets
FIRECRAWL_API_URL but always fronts the cloud), and log why on stderr.

Fixes firecrawl#341
Self-hosted FIRECRAWL_API_URL must hide every firecrawl_research_* tool
from tools/list (with a stderr notice) while leaving the rest of the
surface intact; an explicit https://api.firecrawl.dev/ URL must keep
them registered. The hosted CLOUD_SERVICE exemption and the default
cloud registration stay covered by the existing search-profile and
stdio smoke tests.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/research.ts">

<violation number="1" location="src/research.ts:38">
P3: Duplicate cloud API URL constant — `src/index.ts` already defines `DEFAULT_CLOUD_API_URL` with the same value at line 1908. This change introduces a third copy of the string (fourth if counting `DEFAULT_API_URL` in `src/monitor.ts`), creating a maintenance hazard: if the cloud API domain ever changes, all copies must be updated in lockstep. Consider exporting the constant from `src/index.ts` (or a shared constants location) and importing it here instead.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/research.ts
const BASE = '/v2/search/research';
const ORIGIN_HEADERS = { 'X-Origin': 'mcp-fastmcp' };

const DEFAULT_CLOUD_API_URL = 'https://api.firecrawl.dev';

@cubic-dev-ai cubic-dev-ai Bot Jul 29, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Duplicate cloud API URL constant — src/index.ts already defines DEFAULT_CLOUD_API_URL with the same value at line 1908. This change introduces a third copy of the string (fourth if counting DEFAULT_API_URL in src/monitor.ts), creating a maintenance hazard: if the cloud API domain ever changes, all copies must be updated in lockstep. Consider exporting the constant from src/index.ts (or a shared constants location) and importing it here instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/research.ts, line 38:

<comment>Duplicate cloud API URL constant — `src/index.ts` already defines `DEFAULT_CLOUD_API_URL` with the same value at line 1908. This change introduces a third copy of the string (fourth if counting `DEFAULT_API_URL` in `src/monitor.ts`), creating a maintenance hazard: if the cloud API domain ever changes, all copies must be updated in lockstep. Consider exporting the constant from `src/index.ts` (or a shared constants location) and importing it here instead.</comment>

<file context>
@@ -35,6 +35,23 @@ type GetClient = (session?: SessionData) => unknown;
 const BASE = '/v2/search/research';
 const ORIGIN_HEADERS = { 'X-Origin': 'mcp-fastmcp' };
 
+const DEFAULT_CLOUD_API_URL = 'https://api.firecrawl.dev';
+
+/**
</file context>
Fix with cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

firecrawl_research_search_papers returns 404 when using self-hosted Firecrawl

1 participant