feat: tool execution, Anthropic Messages API, and interactive landing page#31
Conversation
Previously, setting enable_tools=true in the request body would log "Tools enabled by user request" but tools would not actually execute. The Claude Agent SDK requires both: 1. allowed_tools to be set (specifying which tools can be used) 2. permission_mode to be set to "bypassPermissions" for headless/API usage This fix: - Sets allowed_tools to DEFAULT_ALLOWED_TOOLS (Read, Glob, Grep, Bash, Write, Edit) - Sets permission_mode to "bypassPermissions" when tools are enabled - Adds permission_mode parameter passthrough to ClaudeCodeCLI.run_completion() - Fixes parse_claude_message() to return ResultMessage.result for multi-turn conversations (previously it returned only the first AssistantMessage text) Tested with file read/write operations - tools now execute correctly. Authored by: Aaron Lippold <lippold@gmail.com>
…ping - Add tests/test_tool_execution.py with unit tests for: - permission_mode option support in ClaudeAgentOptions - DEFAULT_ALLOWED_TOOLS constant validation - parse_claude_message() handling of ResultMessage and multi-turn conversations - ClaudeCodeCLI.run_completion() permission_mode parameter - Add tests/conftest.py with requires_server marker for integration tests - Add @requires_server decorator to all integration tests that need a running server - Fix test_sdk_quick.py async test with proper pytest.mark.asyncio decorator - Add skip conditions for tests requiring ANTHROPIC_API_KEY This ensures pytest runs cleanly (32 passed, 24 skipped) without needing a running server, while integration tests can still be run manually. Authored by: Aaron Lippold <lippold@gmail.com>
Add support for native Anthropic SDK clients by implementing the /v1/messages endpoint. This enables tools like VC to use this wrapper via custom base URL configuration (e.g., VC_API_BASE=http://localhost:8000). Changes: - Add AnthropicMessagesRequest/Response models in models.py - Add /v1/messages POST endpoint in main.py - Add comprehensive tests in test_anthropic_messages.py - Tools enabled by default for Anthropic SDK clients (agentic workflows) Authored by: Aaron Lippold<lippold@gmail.com>
|
Related PR: steveyegge/vc#7 The Use case: Multi-agent workflows where VC orchestrates tasks and this wrapper provides Claude Code tool execution (file ops, bash, etc.). |
- Add CLAUDE_AUTH_METHOD to explicitly select auth (cli, api_key, bedrock, vertex) - Fixes conflict when ANTHROPIC_API_KEY is set but wrapper should use CLI auth - Add styled landing page at root with Tailwind CSS - Shows auth status, endpoints, quick start, and config options Authored by: Aaron Lippold<lippold@gmail.com>
… version - Add light/dark mode toggle with localStorage persistence - Make GET endpoints clickable with arrow icons - Add version badge (v2.1.0) in header - Add GitHub icon linking to repository - Add /version endpoint returning version info - Update __version__ to 2.1.0 matching pyproject.toml - Full light mode support with dark: Tailwind prefixes Authored by: Aaron Lippold<lippold@gmail.com>
…ighting - GET endpoints now expand on click to show live API response - JSON responses are pretty-printed with 2-space indentation - Syntax highlighting: keys (green), strings (amber), numbers (blue), booleans (purple), null (gray) - Lazy loading: data fetched only when accordion opened - Chevron icon rotates to indicate open/closed state - POST endpoints remain static (no accordion) Authored by: Aaron Lippold<lippold@gmail.com>
Light mode colors now use darker, more saturated values: - Keys: #166534 (dark green) + bold - Strings: #b45309 (dark amber) - Numbers: #1d4ed8 (dark blue) - Booleans: #7c3aed (dark purple) - Null: #4b5563 (dark gray) + italic Authored by: Aaron Lippold<lippold@gmail.com>
- Replace regex-based highlighter with Shiki via CDN (esm.sh) - Use github-light/github-dark themes matching system theme - Lazy-load JSON grammar on demand - Re-highlight when theme toggles - Shiki provides inline styles, no custom CSS needed Authored by: Aaron Lippold<lippold@gmail.com>
- Consistent with JSON endpoint highlighting - Uses bash language for curl syntax - Re-highlights when theme toggles Authored by: Aaron Lippold<lippold@gmail.com>
Coverage improved from 19% to 57%: - parameter_validator: 98% - rate_limiter: 100% - session_manager: 93% - models: 94% - auth: 96% - message_adapter: 100% - claude_cli: 55% Added 308 total tests. Authored by: Aaron Lippold<lippold@gmail.com>
…de_cli - test_tool_manager_unit.py: 48 tests covering ToolMetadata, ToolConfiguration, ToolManager classes - achieves 100% coverage - test_mcp_client_unit.py: 55 tests covering MCPClient async/sync operations, server management, connection lifecycle - achieves 96% coverage - test_claude_cli_unit.py: expanded to 44 tests covering __init__, verify_cli, run_completion methods - achieves 98% coverage Coverage improvements: - tool_manager.py: 50% -> 100% - mcp_client.py: 27% -> 96% - claude_cli.py: 55% -> 98% - Overall: 57% -> 71% Test count: 308 -> 430 tests Authored by: Aaron Lippold<lippold@gmail.com>
- Replace Tailwind CDN (~300KB) with PicoCSS (~10KB) - Use semantic HTML: <article>, <details>/<summary> for accordions - Add light/dark theme support with data-theme attribute - Replace emoji icons with proper SVG icons - Add CSS variables for consistent theming across modes - Global code element reset to fix Pico defaults Authored by: Aaron Lippold<lippold@gmail.com>
- Run tests on Python 3.10, 3.11, 3.12 - Black linting check - Coverage reporting with Codecov - Caching for Poetry dependencies Authored by: Aaron Lippold<lippold@gmail.com>
Authored by: Aaron Lippold<lippold@gmail.com>
Authored by: Aaron Lippold<lippold@gmail.com>
Authored by: Aaron Lippold<lippold@gmail.com>
Security enhancements: - Add RequestSizeLimitMiddleware (10MB default, configurable) - Add RequestIDMiddleware for audit trail (X-Request-ID header) - Add request ID correlation in debug logs CI/CD improvements: - Add mypy type checking (non-blocking) - Add bandit security scanning - Add safety dependency vulnerability check - Add hypothesis for property-based testing Code fixes: - Add 'plan' to VALID_PERMISSION_MODES (was missing) Dependencies: - mypy ^1.14.0 - bandit ^1.8.0 - safety ^3.2.0 - hypothesis ^6.122.0 Authored by: Aaron Lippold<lippold@gmail.com>
- Make host configurable via CLAUDE_WRAPPER_HOST env var - Add nosec B104 comments to suppress bandit warnings - Binding to 0.0.0.0 is intentional for container/development use Authored by: Aaron Lippold<lippold@gmail.com>
- Add CLAUDE_WRAPPER_HOST to .env.example and README - Add MAX_REQUEST_SIZE to .env.example and README - Document security settings for host binding Authored by: Aaron Lippold<lippold@gmail.com>
Addresses Claude Code review recommendation for inline documentation. Authored by: Aaron Lippold<lippold@gmail.com>
|
Closing and reopening to fix Claude Code PR review! |
Code Review for PR #31: Tool Execution, Anthropic Messages API, and Interactive Landing PageSummaryThis is an excellent PR that adds three major features with comprehensive test coverage (57% → 71%). The code quality is high, and the implementation is well-structured. Below are my detailed findings. ✅ Strengths1. Tool Execution Fix (Critical Bug Fix)
2. Anthropic Messages API (
|
|
Thanks for the @aaronlippold - great work! Can you submit a separate PR to update the readme with the new features? |
## New Features (from #31 by @aaronlippold) - Interactive landing page with API explorer at root URL - Anthropic Messages API (`/v1/messages` endpoint) - `CLAUDE_AUTH_METHOD` env var for explicit auth selection - Tool execution fix - `enable_tools: true` now works correctly - `/version` endpoint ## Documentation - Condensed Docker documentation (~135 lines removed) - Added new features to Features and API Endpoints sections - Updated roadmap with v2.2.0 improvements - Fixed SDK version reference (v0.1.8 → v0.1.18) Thanks to @aaronlippold for the significant contributions in PR #31!
… page (RichardAtCT#31) * fix: enable tool execution when enable_tools=true Previously, setting enable_tools=true in the request body would log "Tools enabled by user request" but tools would not actually execute. The Claude Agent SDK requires both: 1. allowed_tools to be set (specifying which tools can be used) 2. permission_mode to be set to "bypassPermissions" for headless/API usage This fix: - Sets allowed_tools to DEFAULT_ALLOWED_TOOLS (Read, Glob, Grep, Bash, Write, Edit) - Sets permission_mode to "bypassPermissions" when tools are enabled - Adds permission_mode parameter passthrough to ClaudeCodeCLI.run_completion() - Fixes parse_claude_message() to return ResultMessage.result for multi-turn conversations (previously it returned only the first AssistantMessage text) Tested with file read/write operations - tools now execute correctly. Authored by: Aaron Lippold <lippold@gmail.com> * test: add unit tests for tool execution and fix integration test skipping - Add tests/test_tool_execution.py with unit tests for: - permission_mode option support in ClaudeAgentOptions - DEFAULT_ALLOWED_TOOLS constant validation - parse_claude_message() handling of ResultMessage and multi-turn conversations - ClaudeCodeCLI.run_completion() permission_mode parameter - Add tests/conftest.py with requires_server marker for integration tests - Add @requires_server decorator to all integration tests that need a running server - Fix test_sdk_quick.py async test with proper pytest.mark.asyncio decorator - Add skip conditions for tests requiring ANTHROPIC_API_KEY This ensures pytest runs cleanly (32 passed, 24 skipped) without needing a running server, while integration tests can still be run manually. Authored by: Aaron Lippold <lippold@gmail.com> * feat: add Anthropic Messages API compatible endpoint (/v1/messages) Add support for native Anthropic SDK clients by implementing the /v1/messages endpoint. This enables tools like VC to use this wrapper via custom base URL configuration (e.g., VC_API_BASE=http://localhost:8000). Changes: - Add AnthropicMessagesRequest/Response models in models.py - Add /v1/messages POST endpoint in main.py - Add comprehensive tests in test_anthropic_messages.py - Tools enabled by default for Anthropic SDK clients (agentic workflows) Authored by: Aaron Lippold<lippold@gmail.com> * feat: add CLAUDE_AUTH_METHOD env var and styled landing page - Add CLAUDE_AUTH_METHOD to explicitly select auth (cli, api_key, bedrock, vertex) - Fixes conflict when ANTHROPIC_API_KEY is set but wrapper should use CLI auth - Add styled landing page at root with Tailwind CSS - Shows auth status, endpoints, quick start, and config options Authored by: Aaron Lippold<lippold@gmail.com> * feat: improve landing page with light/dark mode, clickable endpoints, version - Add light/dark mode toggle with localStorage persistence - Make GET endpoints clickable with arrow icons - Add version badge (v2.1.0) in header - Add GitHub icon linking to repository - Add /version endpoint returning version info - Update __version__ to 2.1.0 matching pyproject.toml - Full light mode support with dark: Tailwind prefixes Authored by: Aaron Lippold<lippold@gmail.com> * feat: add accordion endpoints with live JSON preview and syntax highlighting - GET endpoints now expand on click to show live API response - JSON responses are pretty-printed with 2-space indentation - Syntax highlighting: keys (green), strings (amber), numbers (blue), booleans (purple), null (gray) - Lazy loading: data fetched only when accordion opened - Chevron icon rotates to indicate open/closed state - POST endpoints remain static (no accordion) Authored by: Aaron Lippold<lippold@gmail.com> * fix: improve JSON syntax highlighting contrast in light mode Light mode colors now use darker, more saturated values: - Keys: #166534 (dark green) + bold - Strings: #b45309 (dark amber) - Numbers: #1d4ed8 (dark blue) - Booleans: #7c3aed (dark purple) - Null: #4b5563 (dark gray) + italic Authored by: Aaron Lippold<lippold@gmail.com> * feat: use Shiki for VS Code-quality JSON syntax highlighting - Replace regex-based highlighter with Shiki via CDN (esm.sh) - Use github-light/github-dark themes matching system theme - Lazy-load JSON grammar on demand - Re-highlight when theme toggles - Shiki provides inline styles, no custom CSS needed Authored by: Aaron Lippold<lippold@gmail.com> * fix: use Shiki for Quick Start curl example highlighting - Consistent with JSON endpoint highlighting - Uses bash language for curl syntax - Re-highlights when theme toggles Authored by: Aaron Lippold<lippold@gmail.com> * fix: increase code block font size and line height for readability * fix: make quickstart curl command single-line for easy copy-paste * feat: add copy button to quickstart command * fix: add fallback copy method for clipboard support * fix: properly escape quickstartText string for JavaScript * test: add tests for /version endpoint and landing page * chore: add pytest-cov for coverage reporting * test: add comprehensive unit tests for core modules Coverage improved from 19% to 57%: - parameter_validator: 98% - rate_limiter: 100% - session_manager: 93% - models: 94% - auth: 96% - message_adapter: 100% - claude_cli: 55% Added 308 total tests. Authored by: Aaron Lippold<lippold@gmail.com> * test: add comprehensive unit tests for tool_manager, mcp_client, claude_cli - test_tool_manager_unit.py: 48 tests covering ToolMetadata, ToolConfiguration, ToolManager classes - achieves 100% coverage - test_mcp_client_unit.py: 55 tests covering MCPClient async/sync operations, server management, connection lifecycle - achieves 96% coverage - test_claude_cli_unit.py: expanded to 44 tests covering __init__, verify_cli, run_completion methods - achieves 98% coverage Coverage improvements: - tool_manager.py: 50% -> 100% - mcp_client.py: 27% -> 96% - claude_cli.py: 55% -> 98% - Overall: 57% -> 71% Test count: 308 -> 430 tests Authored by: Aaron Lippold<lippold@gmail.com> * feat: migrate landing page from Tailwind CSS to PicoCSS - Replace Tailwind CDN (~300KB) with PicoCSS (~10KB) - Use semantic HTML: <article>, <details>/<summary> for accordions - Add light/dark theme support with data-theme attribute - Replace emoji icons with proper SVG icons - Add CSS variables for consistent theming across modes - Global code element reset to fix Pico defaults Authored by: Aaron Lippold<lippold@gmail.com> * ci: add GitHub Actions workflow for tests and linting - Run tests on Python 3.10, 3.11, 3.12 - Black linting check - Coverage reporting with Codecov - Caching for Poetry dependencies Authored by: Aaron Lippold<lippold@gmail.com> * style: apply black formatting Authored by: Aaron Lippold<lippold@gmail.com> * ci: remove Claude Code Review workflow (token issues) Authored by: Aaron Lippold<lippold@gmail.com> * Revert: restore claude-code-review.yml Authored by: Aaron Lippold<lippold@gmail.com> * feat: implement Claude Code review recommendations Security enhancements: - Add RequestSizeLimitMiddleware (10MB default, configurable) - Add RequestIDMiddleware for audit trail (X-Request-ID header) - Add request ID correlation in debug logs CI/CD improvements: - Add mypy type checking (non-blocking) - Add bandit security scanning - Add safety dependency vulnerability check - Add hypothesis for property-based testing Code fixes: - Add 'plan' to VALID_PERMISSION_MODES (was missing) Dependencies: - mypy ^1.14.0 - bandit ^1.8.0 - safety ^3.2.0 - hypothesis ^6.122.0 Authored by: Aaron Lippold<lippold@gmail.com> * fix: add nosec comments for intentional 0.0.0.0 binding - Make host configurable via CLAUDE_WRAPPER_HOST env var - Add nosec B104 comments to suppress bandit warnings - Binding to 0.0.0.0 is intentional for container/development use Authored by: Aaron Lippold<lippold@gmail.com> * docs: document CLAUDE_WRAPPER_HOST and MAX_REQUEST_SIZE env vars - Add CLAUDE_WRAPPER_HOST to .env.example and README - Add MAX_REQUEST_SIZE to .env.example and README - Document security settings for host binding Authored by: Aaron Lippold<lippold@gmail.com> * docs: add usage examples to constants.py docstring Addresses Claude Code review recommendation for inline documentation. Authored by: Aaron Lippold<lippold@gmail.com>
## New Features (from RichardAtCT#31 by @aaronlippold) - Interactive landing page with API explorer at root URL - Anthropic Messages API (`/v1/messages` endpoint) - `CLAUDE_AUTH_METHOD` env var for explicit auth selection - Tool execution fix - `enable_tools: true` now works correctly - `/version` endpoint ## Documentation - Condensed Docker documentation (~135 lines removed) - Added new features to Features and API Endpoints sections - Updated roadmap with v2.2.0 improvements - Fixed SDK version reference (v0.1.8 → v0.1.18) Thanks to @aaronlippold for the significant contributions in PR RichardAtCT#31!
Summary
This PR includes three major features:
enable_tools: true/v1/messagesendpoint for native Anthropic compatibilityFeatures
Tool Execution Fix
Fixes an issue where setting
enable_tools: truelogged "Tools enabled by user request" but tools would not actually execute.Anthropic Messages API (
/v1/messages)Interactive Landing Page
data-themeattribute<details>/<summary>elements (no JS needed)Auth Improvements
CLAUDE_AUTH_METHODenv var for explicit auth selection (cli,api_key,bedrock,vertex)ANTHROPIC_API_KEYis set but you want CLI authChanges
src/main.py:
/v1/messagesendpoint for Anthropic API compatibility/versionendpointsrc/claude_cli.py:
allowed_toolsandpermission_modefor tool executionpermission_modeparameter passthroughsrc/auth.py:
CLAUDE_AUTH_METHODexplicit auth selectionsrc/models.py:
tests/:
test_anthropic_messages.py- Anthropic API teststest_tool_execution.py- Tool execution testsconftest.pywithrequires_serverskip markerTest plan
poetry run pytest tests/ -venable_tools: true/v1/messagesAuthored by: Aaron Lippold lippold@gmail.com