Skip to main content
Glama

Safari MCP Server

by lxman
PROJECT_OVERVIEW.mdโ€ข5.99 kB
# Safari MCP Server - Project Overview ## ๐ŸŽฏ Project Summary You now have a complete Safari MCP Server project at: ``` /Users/<USERNAME>/source/repos/safari-mcp-server/ ``` This server provides AI assistants with comprehensive Safari browser automation and developer tools access through the Model Context Protocol (MCP). ## ๐Ÿ“ Project Structure ``` safari-mcp-server/ โ”œโ”€โ”€ src/ # TypeScript source code โ”‚ โ”œโ”€โ”€ index.ts # Main entry point โ”‚ โ”œโ”€โ”€ safari-mcp-server.ts # MCP server implementation โ”‚ โ”œโ”€โ”€ safari-driver.ts # Safari WebDriver manager โ”‚ โ””โ”€โ”€ types.ts # TypeScript definitions โ”œโ”€โ”€ build/ # Compiled JavaScript (after build) โ”œโ”€โ”€ tests/ # Test files โ”‚ โ””โ”€โ”€ basic-tests.ts # Basic validation tests โ”œโ”€โ”€ examples/ # Usage examples โ”‚ โ””โ”€โ”€ example-usage.ts # Programmatic usage example โ”œโ”€โ”€ package.json # Project configuration โ”œโ”€โ”€ tsconfig.json # TypeScript configuration โ”œโ”€โ”€ setup.sh # macOS setup script โ”œโ”€โ”€ setup.bat # Windows info script โ”œโ”€โ”€ claude_desktop_config.json # Claude Desktop config example โ”œโ”€โ”€ .gitignore # Git ignore rules โ””โ”€โ”€ README.md # Comprehensive documentation ``` ## ๐Ÿš€ Quick Start ### 1. Install Dependencies ```bash cd "/Users/<USERNAME>/source/repos/safari-mcp-server" npm install ``` ### 2. Build the Project ```bash npm run build ``` ### 3. Test the Setup ```bash npm test ``` ### 4. Run the Server ```bash npm start ``` ## ๐Ÿ› ๏ธ Available NPM Scripts | Script | Description | |--------|-------------| | `npm run build` | Compile TypeScript to JavaScript | | `npm start` | Start the MCP server | | `npm run dev` | Build and start in development mode | | `npm run watch` | Watch TypeScript files for changes | | `npm run clean` | Clean build directory | | `npm test` | Run basic validation tests | | `npm run setup` | Run setup script (macOS only) | | `npm run example` | Run usage example | | `npm run inspect` | Start with MCP inspector for debugging | ## ๐Ÿ”ง Safari MCP Tools Available ### Session Management - **safari_start_session** - Start automation session with dev tools - **safari_close_session** - Close automation session - **safari_list_sessions** - List active sessions ### Navigation & Page Info - **safari_navigate** - Navigate to URLs - **safari_get_page_info** - Get current page URL and title ### Developer Tools Access - **safari_get_console_logs** - Browser console logs with filtering - **safari_get_network_logs** - Network activity monitoring - **safari_get_performance_metrics** - Page performance data ### Browser Interaction - **safari_execute_script** - Execute JavaScript in browser - **safari_take_screenshot** - Capture page screenshots - **safari_inspect_element** - DOM element inspection ## ๐Ÿ“ฑ Integration with Claude Desktop ### Configuration File Location - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json` ### Add This Configuration: ```json { "mcpServers": { "safari-devtools": { "command": "node", "args": [ "/Users/<USERNAME>/source/repos/safari-mcp-server/build/index.js" ] } } } ``` ## โš ๏ธ Important Notes ### Platform Requirements - **This server only works on macOS** - Safari and SafariDriver are macOS exclusive - **Node.js 18+** required - **Safari 10+** with WebDriver support ### Safari Configuration Required Before using, you must: 1. Enable Safari Developer menu: Safari โ†’ Preferences โ†’ Advanced โ†’ "Show Develop menu in menu bar" 2. Enable automation: Develop โ†’ Allow Remote Automation 3. Authorize SafariDriver: `sudo safaridriver --enable` ### Limitations - **Single session limit** - Safari only allows one WebDriver session at a time - **Limited network logging** - Safari's debugging API is more limited than Chrome DevTools Protocol - **macOS dependency** - Cannot run on Windows or Linux ## ๐Ÿงช Testing Your Setup ### 1. Basic Tests ```bash npm test ``` ### 2. Interactive Testing with MCP Inspector ```bash npm run inspect ``` ### 3. Example Usage ```bash npm run example ``` ## ๐Ÿ” Development & Debugging ### Watch Mode for Development ```bash npm run watch ``` ### Using MCP Inspector The MCP Inspector provides a web interface to test your server: ```bash npm run inspect ``` Then open the provided URL in your browser to interactively test tools. ### Logging The server logs to stderr to avoid interfering with MCP protocol communication on stdout. ## ๐Ÿšจ Troubleshooting ### Common Issues 1. **"Platform not supported"** - This server only works on macOS - For Windows/Linux, consider Chrome CDP-based solutions 2. **"SafariDriver not enabled"** - Run: `sudo safaridriver --enable` - Check Safari โ†’ Develop โ†’ Allow Remote Automation is enabled 3. **"Session not found"** - Start a session first with `safari_start_session` - Only one Safari session can be active at a time 4. **"Permission denied"** - Make sure Terminal has necessary permissions - Check macOS Security & Privacy settings ### Getting Help - Check the README.md for detailed documentation - Run tests to validate setup: `npm test` - Use MCP Inspector for interactive debugging: `npm run inspect` ## ๐ŸŽ‰ You're Ready! Your Safari MCP Server is now fully set up and ready to provide AI assistants with powerful Safari automation and developer tools access. The server implements the complete MCP specification and provides comprehensive browser control capabilities. Remember: This server must run on macOS to function properly, as it depends on Safari and SafariDriver which are exclusive to Apple platforms.

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lxman/safari-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server