feat: Add max_results parameter and nginx auth proxy#45
Conversation
This commit adds two major features: 1. **max_results parameter for search tool** - Added configurable max_results parameter (default: 5) to search_tool - Updated Serper client to use "num" parameter for result limiting - Updated DuckDuckGo client to respect max_results - Removed broken tool-level authentication (moved to proxy) 2. **Nginx reverse proxy with bearer token authentication** - Created Dockerfile.nginx-simple for single-image deployment - Added nginx config with dynamic auth via entrypoint script - Nginx validates bearer token before proxying to WebCat - WebCat runs without auth on internal port 4000 - Nginx exposes authenticated endpoint on port 8000 - Supports optional auth: works with or without WEBCAT_API_KEY **Testing:** - test_mcp_no_auth.py: Tests MCP protocol with real API calls - test_nginx_auth.py: Tests nginx auth (blocks without token, allows with token) - All tests use real Serper API, no mocks **Breaking Changes:** - search_tool() now requires max_results parameter (default=5) - Removed ctx parameter from search_tool (auth moved to nginx) - WEBCAT_API_KEY no longer validated at tool level 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. WalkthroughAdds an nginx-authenticated deployment path for WebCat, including a single-image Dockerfile with nginx+supervisord, nginx configs, an entrypoint for runtime auth templating, Docker Compose for proxying, updated MCP server ports/paths, removal of in-app auth from search_tool, expanded tests (proxy/no-auth), and enhanced auth debug logging. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant N as nginx proxy
participant W as WebCat MCP Server
rect rgb(240,248,255)
note right of N: Startup
N->>N: EntryPoint templates nginx.conf (WEBCAT_API_KEY)
N->>N: Launch via supervisord (nginx + webcat)
end
C->>N: HTTP POST /mcp initialize (optional Authorization)
alt Authorization provided and valid
N->>W: Proxy request (headers, no buffering)
W-->>N: 200 + headers (mcp-session-id)
N-->>C: 200 + headers
else Missing/invalid Authorization
N-->>C: 401 { "error": "Unauthorized" }
end
C->>N: notifications/initialized (with session id)
N->>W: Proxy
W-->>N: 200
N-->>C: 200
C->>N: tools/call search (stream/SSE)
N->>W: Proxy (keep-alive, long timeouts)
W-->>N: SSE stream
N-->>C: SSE stream
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (14)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Removed auth-related tests (auth moved to nginx) - Added tests for max_results parameter (default and custom values) - Updated existing tests to pass max_results parameter - All 57 unit tests now passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
This PR adds two major features to WebCat:
1. max_results Parameter for Search Tool
max_resultsparameter (default: 5) to control search result count"num"parameter for result limitingmax_results2. Nginx Reverse Proxy with Bearer Token Authentication
Dockerfile.nginx-simplefor single-image deployment with built-in authWEBCAT_API_KEYArchitecture Changes
Testing
All tests use real APIs (no mocks):
test_mcp_no_auth.py- Tests MCP protocol with real Serper API callstest_nginx_auth.py- Tests nginx auth (blocks without token, allows with valid token)test_real_mcp_server.py- Full MCP handshake with max_results verificationTest Results:
Breaking Changes
search_tool()signature changed: addedmax_resultsparameter (has default, backward compatible)ctxparameter fromsearch_tool(auth moved to nginx)WEBCAT_API_KEYno longer validated at tool levelDeployment Options
Option 1: Without Auth (existing Dockerfile)
Option 2: With Nginx Auth (new Dockerfile.nginx-simple)
docker build -f docker/Dockerfile.nginx-simple -t webcat-nginx . docker run -p 8000:8000 --env-file .env webcat-nginxTest Plan
🤖 Generated with Claude Code
Summary by CodeRabbit