Skip to content

Conversation

devin-ai-integration[bot]
Copy link
Contributor

feat: implement cancel crawl functionality in MCP server

Summary

Adds a new firecrawl_cancel_crawl tool to the Firecrawl MCP server that allows users to cancel running crawl jobs. This implementation leverages the existing cancelCrawl method from the Firecrawl JS SDK and follows the same patterns as other tools in the server.

Key Changes:

  • Added CANCEL_CRAWL_TOOL definition with proper input schema and documentation
  • Integrated the tool into the MCP server's tool registry and request handler
  • Added retry logic and error handling consistent with existing tools
  • Included comprehensive test coverage for the new functionality

The tool accepts a crawl job ID and returns a confirmation message when the cancellation is successful.

Review & Testing Checklist for Human

  • Verify SDK Integration: Test the cancelCrawl method behavior with a real Firecrawl instance to ensure the response format matches our assumptions (success/error fields)
  • End-to-End Testing: Create a real crawl job and attempt to cancel it using the new MCP tool to verify the complete workflow works
  • Error Scenario Testing: Test edge cases like canceling already completed crawls, invalid job IDs, and network timeouts during cancellation
  • Tool Registration: Verify the new tool appears correctly in MCP client tool lists and has proper schema validation

Recommended Test Plan:

  1. Start a crawl job using firecrawl_crawl tool
  2. While the crawl is running, use firecrawl_cancel_crawl with the job ID
  3. Verify the crawl status shows as cancelled using firecrawl_check_crawl_status
  4. Test with invalid/non-existent job IDs to ensure proper error handling

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    subgraph "MCP Server Components"
        A["src/index.ts<br/>Main Server File"]:::major-edit
        B["src/index.test.ts<br/>Test File"]:::major-edit
        C["CANCEL_CRAWL_TOOL<br/>Tool Definition"]:::major-edit
        D["isCancelCrawlOptions<br/>Type Guard"]:::major-edit
        E["CallToolRequestSchema<br/>Handler"]:::major-edit
    end
    
    subgraph "External Dependencies"
        F["@mendable/firecrawl-js<br/>SDK"]:::context
        G["cancelCrawl()<br/>SDK Method"]:::context
    end
    
    subgraph "MCP Framework"
        H["ListToolsRequestSchema<br/>Tool Registry"]:::minor-edit
        I["Tool Interface<br/>Type System"]:::context
    end
    
    A --> C
    A --> D
    A --> E
    A --> H
    C --> I
    E --> G
    E --> F
    B --> A
    
    subgraph Legend
        L1["Major Edit"]:::major-edit
        L2["Minor Edit"]:::minor-edit
        L3["Context/No Edit"]:::context
    end

classDef major-edit fill:#90EE90
classDef minor-edit fill:#87CEEB
classDef context fill:#FFFFFF
Loading

Notes

  • The implementation reuses the StatusCheckOptions interface for type validation since both cancel and status check operations only require an id field
  • Retry logic with exponential backoff is included via the withRetry wrapper, consistent with other tools
  • The tool follows the same error handling and response formatting patterns as existing tools
  • All existing tests continue to pass, and new test coverage has been added

Link to Devin run: https://app.devin.ai/sessions/6da4eeb600f44cad9e9ec98342e50b36
Requested by: @nickscamara

devin-ai-integration bot and others added 2 commits August 5, 2025 21:28
- Add CANCEL_CRAWL_TOOL with proper input schema and description
- Add firecrawl_cancel_crawl handler with retry logic and error handling
- Add type guard function isCancelCrawlOptions for input validation
- Add test coverage for cancel crawl functionality
- Follow existing patterns for consistency

Co-Authored-By: Nick <[email protected]>
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

0 participants