API Reference
FerrumMCP provides 40 browser automation tools through the Model Context Protocol (MCP). All tools return responses in a standardized JSON format with a success boolean and either data or error fields.
Important Notes
- Session-Based Architecture: All browser operation tools (except session management tools) require a valid
session_idparameter - Session Creation: You must create a session using
create_sessionbefore using any browser automation tools - Session Lifecycle: Sessions auto-close after 30 minutes of inactivity or can be manually closed with
close_session - Multiple Sessions: You can run multiple concurrent browser sessions with different configurations
- Screenshot Format: The
screenshottool returns base64-encoded image data - Selector Support: Every element-based tool accepts a CSS selector, an XPath (
xpath:prefix or starting with//) or a snapshot ref (ref:e12, see snapshot) - Tabs: tools act on the session's current tab; use new_tab / switch_tab to change it
Tools
Response Format
All tools return responses in this standard format:
Success Response:
json
{
"success": true,
"data": {
// Tool-specific data
}
}Error Response:
json
{
"success": false,
"error": "Error message describing what went wrong"
}Image Response (screenshot tool):
json
{
"type": "image",
"data": "base64-encoded-image-data",
"mime_type": "image/png"
}Common Error Scenarios
- Missing session_id: "session_id is required. Create a session first using create_session tool."
- Invalid session: "Session not found: {session_id}"
- Element not found: "Element not found: {selector}"
- Timeout errors: "Navigation timed out" / "Timed out after 10s waiting for #x to be visible"
- Any other tool failure: "{tool_name} failed: {error}" (e.g. "execute_script failed: ReferenceError: foo is not defined")
Best Practices
- Always create a session first: Use
create_sessionbefore any browser operations - Use resource discovery: Query
ferrum://browsersandferrum://bot-profilesto see available configurations - Handle sessions properly: Close sessions when done to free resources
- Snapshot before acting: call
snapshotand use the returned refs (ref:e12) instead of guessing selectors - Wait explicitly: use
wait_for_selector/wait_for_text/wait_for_network_idlerather than fixed delays - Use appropriate selectors: Prefer CSS selectors for performance, XPath for complex queries
- Set timeouts wisely: Increase timeout for slow-loading pages
- Force clicks sparingly: Only use
force: truewhen necessary, as it bypasses visibility checks - Screenshot optimization: Use
jpegformat for smaller file sizes when quality is not critical