Skip to content

Commit 6a9c9b3

Browse files
authored
Merge pull request #13 from vrknetha/feature/remove-rate-limit
Feature/remove rate limit
2 parents 2791859 + 1895fec commit 6a9c9b3

File tree

5 files changed

+130
-34
lines changed

5 files changed

+130
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ npm-debug.log*
1313
.env
1414
.env.local
1515
.env.*.local
16+
claude_desktop_config.json
1617

1718
# IDE
1819
.idea/

CHANGELOG.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
# Changelog
22

3+
## [1.2.4] - 2024-02-05
4+
5+
### Added
6+
7+
- Environment variable support for all configuration options
8+
- Detailed configuration documentation in README
9+
10+
### Changed
11+
12+
- Made retry and credit monitoring settings configurable via environment variables:
13+
- `FIRE_CRAWL_RETRY_MAX_ATTEMPTS`
14+
- `FIRE_CRAWL_RETRY_INITIAL_DELAY`
15+
- `FIRE_CRAWL_RETRY_MAX_DELAY`
16+
- `FIRE_CRAWL_RETRY_BACKOFF_FACTOR`
17+
- `FIRE_CRAWL_CREDIT_WARNING_THRESHOLD`
18+
- `FIRE_CRAWL_CREDIT_CRITICAL_THRESHOLD`
19+
- Enhanced configuration examples with detailed comments and use cases
20+
- Improved documentation for retry behavior and credit monitoring
21+
22+
### Documentation
23+
24+
- Added comprehensive configuration examples for both cloud and self-hosted setups
25+
- Added detailed explanations of retry behavior with timing examples
26+
- Added credit monitoring threshold explanations
27+
- Updated Claude Desktop configuration documentation
28+
29+
## [1.2.3] - 2024-02-05
30+
31+
### Changed
32+
33+
- Removed redundant batch configuration to rely on FireCrawl library's built-in functionality
34+
- Simplified batch processing logic by leveraging library's native implementation
35+
- Optimized parallel processing and rate limiting handling
36+
- Reduced code complexity and potential configuration conflicts
37+
38+
### Technical
39+
40+
- Removed custom `CONFIG.batch` settings (`maxParallelOperations` and `delayBetweenRequests`)
41+
- Simplified batch operation processing to use library's built-in batch handling
42+
- Updated server startup logging to remove batch configuration references
43+
- Maintained credit usage tracking and error handling functionality
44+
345
## [1.2.2] - 2025-02-05
446

547
### Fixed

README.md

Lines changed: 78 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A Model Context Protocol (MCP) server implementation that integrates with FireCr
99
## Features
1010

1111
- Web scraping with JavaScript rendering
12-
- Batch scraping with parallel processing and queuing
12+
- Efficient batch processing with built-in rate limiting
1313
- URL discovery and crawling
1414
- Web search with content extraction
1515
- Automatic retries with exponential backoff
@@ -39,32 +39,60 @@ npm install -g mcp-server-firecrawl
3939

4040
### Environment Variables
4141

42+
#### Required for Cloud API
43+
4244
- `FIRE_CRAWL_API_KEY`: Your FireCrawl API key
4345
- Required when using cloud API (default)
4446
- Optional when using self-hosted instance with `FIRE_CRAWL_API_URL`
4547
- `FIRE_CRAWL_API_URL` (Optional): Custom API endpoint for self-hosted instances
4648
- Example: `https://firecrawl.your-domain.com`
4749
- If not provided, the cloud API will be used (requires API key)
4850

51+
#### Optional Configuration
52+
53+
##### Retry Configuration
54+
55+
- `FIRE_CRAWL_RETRY_MAX_ATTEMPTS`: Maximum number of retry attempts (default: 3)
56+
- `FIRE_CRAWL_RETRY_INITIAL_DELAY`: Initial delay in milliseconds before first retry (default: 1000)
57+
- `FIRE_CRAWL_RETRY_MAX_DELAY`: Maximum delay in milliseconds between retries (default: 10000)
58+
- `FIRE_CRAWL_RETRY_BACKOFF_FACTOR`: Exponential backoff multiplier (default: 2)
59+
60+
##### Credit Usage Monitoring
61+
62+
- `FIRE_CRAWL_CREDIT_WARNING_THRESHOLD`: Credit usage warning threshold (default: 1000)
63+
- `FIRE_CRAWL_CREDIT_CRITICAL_THRESHOLD`: Credit usage critical threshold (default: 100)
64+
4965
### Configuration Examples
5066

51-
For cloud API usage (default):
67+
For cloud API usage with custom retry and credit monitoring:
5268

5369
```bash
70+
# Required for cloud API
5471
export FIRE_CRAWL_API_KEY=your-api-key
55-
```
5672

57-
For self-hosted instance without authentication:
73+
# Optional retry configuration
74+
export FIRE_CRAWL_RETRY_MAX_ATTEMPTS=5 # Increase max retry attempts
75+
export FIRE_CRAWL_RETRY_INITIAL_DELAY=2000 # Start with 2s delay
76+
export FIRE_CRAWL_RETRY_MAX_DELAY=30000 # Maximum 30s delay
77+
export FIRE_CRAWL_RETRY_BACKOFF_FACTOR=3 # More aggressive backoff
5878

59-
```bash
60-
export FIRE_CRAWL_API_URL=https://firecrawl.your-domain.com
79+
# Optional credit monitoring
80+
export FIRE_CRAWL_CREDIT_WARNING_THRESHOLD=2000 # Warning at 2000 credits
81+
export FIRE_CRAWL_CREDIT_CRITICAL_THRESHOLD=500 # Critical at 500 credits
6182
```
6283

63-
For self-hosted instance with authentication:
84+
For self-hosted instance:
6485

6586
```bash
87+
# Required for self-hosted
6688
export FIRE_CRAWL_API_URL=https://firecrawl.your-domain.com
67-
export FIRE_CRAWL_API_KEY=your-api-key # Optional for authenticated self-hosted instances
89+
90+
# Optional authentication for self-hosted
91+
export FIRE_CRAWL_API_KEY=your-api-key # If your instance requires auth
92+
93+
# Custom retry configuration
94+
export FIRE_CRAWL_RETRY_MAX_ATTEMPTS=10
95+
export FIRE_CRAWL_RETRY_INITIAL_DELAY=500 # Start with faster retries
6896
```
6997

7098
### Usage with Claude Desktop
@@ -78,7 +106,15 @@ Add this to your `claude_desktop_config.json`:
78106
"command": "npx",
79107
"args": ["-y", "mcp-server-firecrawl"],
80108
"env": {
81-
"FIRE_CRAWL_API_KEY": "YOUR_API_KEY_HERE"
109+
"FIRE_CRAWL_API_KEY": "YOUR_API_KEY_HERE",
110+
111+
"FIRE_CRAWL_RETRY_MAX_ATTEMPTS": "5",
112+
"FIRE_CRAWL_RETRY_INITIAL_DELAY": "2000",
113+
"FIRE_CRAWL_RETRY_MAX_DELAY": "30000",
114+
"FIRE_CRAWL_RETRY_BACKOFF_FACTOR": "3",
115+
116+
"FIRE_CRAWL_CREDIT_WARNING_THRESHOLD": "2000",
117+
"FIRE_CRAWL_CREDIT_CRITICAL_THRESHOLD": "500"
82118
}
83119
}
84120
}
@@ -87,35 +123,50 @@ Add this to your `claude_desktop_config.json`:
87123

88124
### System Configuration
89125

90-
The server includes several configurable parameters:
126+
The server includes several configurable parameters that can be set via environment variables. Here are the default values if not configured:
91127

92128
```typescript
93129
const CONFIG = {
94130
retry: {
95-
maxAttempts: 3,
96-
initialDelay: 1000, // 1 second
97-
maxDelay: 10000, // 10 seconds
98-
backoffFactor: 2,
99-
},
100-
batch: {
101-
delayBetweenRequests: 2000, // 2 seconds
102-
maxParallelOperations: 3,
131+
maxAttempts: 3, // Number of retry attempts for rate-limited requests
132+
initialDelay: 1000, // Initial delay before first retry (in milliseconds)
133+
maxDelay: 10000, // Maximum delay between retries (in milliseconds)
134+
backoffFactor: 2, // Multiplier for exponential backoff
103135
},
104136
credit: {
105-
warningThreshold: 1000,
106-
criticalThreshold: 100,
137+
warningThreshold: 1000, // Warn when credit usage reaches this level
138+
criticalThreshold: 100, // Critical alert when credit usage reaches this level
107139
},
108140
};
109141
```
110142

111-
### Rate Limits
143+
These configurations control:
112144

113-
The server implements rate limiting to prevent API abuse:
145+
1. **Retry Behavior**
114146

115-
- 3 requests per minute on free tier
116-
- Automatic retries with exponential backoff
117-
- Parallel processing for batch operations
118-
- Higher limits available on paid plans
147+
- Automatically retries failed requests due to rate limits
148+
- Uses exponential backoff to avoid overwhelming the API
149+
- Example: With default settings, retries will be attempted at:
150+
- 1st retry: 1 second delay
151+
- 2nd retry: 2 seconds delay
152+
- 3rd retry: 4 seconds delay (capped at maxDelay)
153+
154+
2. **Credit Usage Monitoring**
155+
- Tracks API credit consumption for cloud API usage
156+
- Provides warnings at specified thresholds
157+
- Helps prevent unexpected service interruption
158+
- Example: With default settings:
159+
- Warning at 1000 credits remaining
160+
- Critical alert at 100 credits remaining
161+
162+
### Rate Limiting and Batch Processing
163+
164+
The server utilizes FireCrawl's built-in rate limiting and batch processing capabilities:
165+
166+
- Automatic rate limit handling with exponential backoff
167+
- Efficient parallel processing for batch operations
168+
- Smart request queuing and throttling
169+
- Automatic retries for transient errors
119170

120171
## Available Tools
121172

@@ -142,7 +193,7 @@ Scrape content from a single URL with advanced options.
142193

143194
### 2. Batch Scrape Tool (`fire_crawl_batch_scrape`)
144195

145-
Scrape multiple URLs with parallel processing and queuing.
196+
Scrape multiple URLs efficiently with built-in rate limiting and parallel processing.
146197

147198
```json
148199
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mcp-server-firecrawl",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"description": "MCP server for FireCrawl web scraping integration. Supports both cloud and self-hosted instances. Features include web scraping, batch processing, structured data extraction, and LLM-powered content analysis.",
55
"type": "module",
66
"bin": "dist/src/index.js",

src/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,14 +677,16 @@ const client = new FirecrawlApp({
677677
// Configuration for retries and monitoring
678678
const CONFIG = {
679679
retry: {
680-
maxAttempts: 3,
681-
initialDelay: 1000,
682-
maxDelay: 10000,
683-
backoffFactor: 2,
680+
maxAttempts: Number(process.env.FIRE_CRAWL_RETRY_MAX_ATTEMPTS) || 3,
681+
initialDelay: Number(process.env.FIRE_CRAWL_RETRY_INITIAL_DELAY) || 1000,
682+
maxDelay: Number(process.env.FIRE_CRAWL_RETRY_MAX_DELAY) || 10000,
683+
backoffFactor: Number(process.env.FIRE_CRAWL_RETRY_BACKOFF_FACTOR) || 2,
684684
},
685685
credit: {
686-
warningThreshold: 1000,
687-
criticalThreshold: 100,
686+
warningThreshold:
687+
Number(process.env.FIRE_CRAWL_CREDIT_WARNING_THRESHOLD) || 1000,
688+
criticalThreshold:
689+
Number(process.env.FIRE_CRAWL_CREDIT_CRITICAL_THRESHOLD) || 100,
688690
},
689691
};
690692

0 commit comments

Comments
 (0)