fix: skip cloud-only research tools on self-hosted instances - #342
Open
Mohith26 wants to merge 2 commits into
Open
fix: skip cloud-only research tools on self-hosted instances#342Mohith26 wants to merge 2 commits into
Mohith26 wants to merge 2 commits into
Conversation
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.
There was a problem hiding this comment.
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
| const BASE = '/v2/search/research'; | ||
| const ORIGIN_HEADERS = { 'X-Origin': 'mcp-fastmcp' }; | ||
|
|
||
| const DEFAULT_CLOUD_API_URL = 'https://api.firecrawl.dev'; |
There was a problem hiding this comment.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_URLpoints 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. TheCLOUD_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.
Need help on this PR? Tag
@codesmith-botwith 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_URLpoints to a non-cloud instance. This keeps the tool list accurate and prevents broken calls.FIRECRAWL_API_URL(trimmed) is nothttps://api.firecrawl.devandCLOUD_SERVICEis not'true', do not registerfirecrawl_research_*tools. Write a clear stderr notice explaining why.Written for commit 9c94f49. Summary will update on new commits.