Skip to content

Commit f449848

Browse files
committed
2 parents 056ebc4 + 04c8b13 commit f449848

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/index.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,41 @@ describe('Firecrawl Tool Tests', () => {
139139
});
140140
});
141141

142+
// Test scrape with maxAge parameter
143+
test('should handle scrape request with maxAge parameter', async () => {
144+
const url = 'https://example.com';
145+
const options = { formats: ['markdown'], maxAge: 3600000 };
146+
147+
const mockResponse: ScrapeResponse = {
148+
success: true,
149+
markdown: '# Test Content',
150+
html: undefined,
151+
rawHtml: undefined,
152+
url: 'https://example.com',
153+
actions: undefined as never,
154+
};
155+
156+
mockClient.scrapeUrl.mockResolvedValueOnce(mockResponse);
157+
158+
const response = await requestHandler({
159+
method: 'call_tool',
160+
params: {
161+
name: 'firecrawl_scrape',
162+
arguments: { url, ...options },
163+
},
164+
});
165+
166+
expect(response).toEqual({
167+
content: [{ type: 'text', text: '# Test Content' }],
168+
isError: false,
169+
});
170+
expect(mockClient.scrapeUrl).toHaveBeenCalledWith(url, {
171+
formats: ['markdown'],
172+
maxAge: 3600000,
173+
url,
174+
});
175+
});
176+
142177
// Test batch scrape functionality
143178
test('should handle batch scrape request', async () => {
144179
const urls = ['https://example.com'];

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ This is the most powerful, fastest and most reliable scraper tool, if available
3737
"name": "firecrawl_scrape",
3838
"arguments": {
3939
"url": "https://example.com",
40-
"formats": ["markdown"]
40+
"formats": ["markdown"],
41+
"maxAge": 3600000
4142
}
4243
}
4344
\`\`\`
45+
**Performance:** Add maxAge parameter for 500% faster scrapes using cached data.
4446
**Returns:** Markdown, HTML, or other formats as specified.
4547
`,
4648
inputSchema: {
@@ -189,6 +191,10 @@ This is the most powerful, fastest and most reliable scraper tool, if available
189191
},
190192
description: 'Location settings for scraping',
191193
},
194+
maxAge: {
195+
type: 'number',
196+
description: 'Maximum age in milliseconds for cached content. Use cached data if available and younger than maxAge, otherwise scrape fresh. Enables 500% faster scrapes for recently cached pages. Default: 0 (always scrape fresh)',
197+
},
192198
},
193199
required: ['url'],
194200
},

0 commit comments

Comments
 (0)