Web Auth MCP Server
Enables executing HTTP requests with automatic browser-based authentication, supporting OAuth, form login, and cookie/session management.
README
Web Auth MCP Server
An MCP (Model Context Protocol) server that handles HTTP requests with automatic browser-based authentication.
Features
- Execute HTTP requests through MCP tools
- Automatic detection of authentication requirements
- Browser-based authentication for OAuth flows and login forms
- Chrome password manager integration - automatically use saved passwords
- Automatic form filling and submission - streamlined login process
- Retry requests with captured authentication credentials
- Support for cookies, tokens, and session management
- Configurable browser profiles (system or temporary)
Installation
Quick Install
./install.sh
Manual Install
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install package
pip install -e .
Usage
Running the MCP Server
Stdio Mode (Default)
# Activate virtual environment
source venv/bin/activate
# Run the server with stdio transport
web-auth-mcp
HTTP/SSE Mode
# Activate virtual environment
source venv/bin/activate
# Run the server with HTTP transport on default port 8080
web-auth-mcp-http
# Or specify custom host and port
web-auth-mcp --http 0.0.0.0 8080
# Access the server at: http://localhost:8080/sse
MCP Client Configuration
For Stdio Transport
Add to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"web-auth-mcp": {
"command": "python",
"args": ["-m", "web_auth_mcp.server"],
"env": {
"BROWSER_HEADLESS": "false",
"BROWSER_TIMEOUT": "60"
}
}
}
}
For HTTP/SSE Transport
Configure your MCP client to connect to the HTTP endpoint:
{
"mcpServers": {
"web-auth-mcp": {
"url": "http://localhost:8080/sse",
"env": {
"BROWSER_HEADLESS": "false",
"BROWSER_TIMEOUT": "60"
}
}
}
}
Testing
# Run tests
pytest
# Run example
python example_usage.py
Configuration
Create a .env file with optional configuration:
# Browser configuration
BROWSER_HEADLESS=false
BROWSER_TIMEOUT=60
BROWSER_WINDOW_SIZE=1920x1080
# Chrome Password Manager (NEW!)
BROWSER_USE_DEFAULT_PROFILE=false
BROWSER_ENABLE_PASSWORD_MANAGER=true
BROWSER_AUTO_FILL_PASSWORDS=true
# Authentication configuration
AUTH_CACHE_TTL=3600
AUTH_RETRY_ATTEMPTS=3
# Authentication timing (fixes quick closing issue)
BROWSER_TIMEOUT=300
MANUAL_AUTH_TIMEOUT=180
AUTH_WAIT_TIME=10
# Logging configuration
LOG_LEVEL=INFO
SUPPRESS_MCP_WARNINGS=true
Chrome Password Manager Integration
The server now supports using Chrome's saved passwords for automatic authentication:
Quick Start
-
Enable password manager features:
export BROWSER_ENABLE_PASSWORD_MANAGER=true export BROWSER_AUTO_FILL_PASSWORDS=true export BROWSER_HEADLESS=false -
Choose profile mode:
- System Profile (access to all saved passwords):
export BROWSER_USE_DEFAULT_PROFILE=true - Temporary Profile (session-only passwords):
export BROWSER_USE_DEFAULT_PROFILE=false
- System Profile (access to all saved passwords):
-
Test the functionality:
python test_password_manager.py python example_password_manager.py
How It Works
- Automatic Detection: Detects login forms on web pages
- Chrome Autofill: Triggers Chrome's built-in password autofill
- Form Submission: Automatically submits forms when credentials are found
- Fallback: Manual interaction available if auto-fill fails
Supported Login Forms
- Standard HTML login forms
- Email/username + password combinations
- Common form field patterns and selectors
- Various submit button types
For detailed documentation, see CHROME_PASSWORD_MANAGER.md.
Troubleshooting
MCP Initialization Warnings
You may see warnings like:
WARNING - Failed to validate request: Received request before initialization was complete
This is normal MCP protocol behavior and doesn't affect functionality. These warnings occur during the client-server handshake when requests are received before initialization completes.
To suppress these warnings:
export SUPPRESS_MCP_WARNINGS=true
# or add to your .env file:
echo "SUPPRESS_MCP_WARNINGS=true" >> .env
The server will continue to function correctly regardless of these warnings.
Tools
http_request
Execute HTTP requests with automatic authentication handling.
Parameters:
url(string): The URL to requestmethod(string): HTTP method (GET, POST, PUT, DELETE, etc.)headers(object, optional): Request headersbody(string, optional): Request bodyauth_required(boolean, optional): Force authentication flow
Returns:
- Response status, headers, and body
- Authentication details if authentication was performed
How It Works
- HTTP Request: The server receives an HTTP request through the MCP tool
- Authentication Detection: Checks if authentication is required by examining:
- HTTP status codes (401, 403)
- Redirect responses to login pages
- Content indicators ("please log in", etc.)
- WWW-Authenticate headers
- Browser Authentication: If authentication is needed:
- Opens a browser window (headless or visible)
- Navigates to the URL requiring authentication
- Waits for user to complete authentication
- Extracts authentication data (cookies, tokens, headers)
- Request Retry: Retries the original request with authentication data
- Response: Returns the final response with authentication status
Supported Authentication Types
- OAuth 2.0 flows (Authorization Code, Implicit, etc.)
- Form-based login (username/password forms)
- Cookie-based sessions
- Token-based authentication (JWT, Bearer tokens)
- CSRF protection (automatic token extraction)
Browser Automation
The server uses Selenium WebDriver with Chrome to handle authentication:
- Supports both headless and visible browser modes
- Automatically detects authentication completion
- Extracts tokens from localStorage, sessionStorage, and cookies
- Handles CSRF tokens from meta tags
- Configurable timeouts and window sizes
Troubleshooting
Browser Issues
Browser doesn't open:
- Check that
BROWSER_HEADLESS=false(default) - Ensure Chrome is installed on your system
Browser opens but doesn't close:
- The server detects authentication completion automatically
- Wait for the success message: "✅ Authentication completed successfully!"
- If stuck, check that you've completed the login process fully
Authentication timeout:
- Increase timeout:
BROWSER_TIMEOUT=120(default: 60 seconds) - Ensure you complete authentication within the timeout period
Common Solutions
# Force visible browser
export BROWSER_HEADLESS=false
# Increase timeout
export BROWSER_TIMEOUT=120
# Debug mode
export LOG_LEVEL=DEBUG
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。