KODEGEN Claude Agent Tools
Memory-efficient, blazing-fast MCP tools for Claude Code agent delegation.
Build powerful multi-agent systems by spawning and orchestrating Claude agent sub-sessions. This Rust SDK and MCP server enables sophisticated delegation patterns where Claude instances can spawn, manage, and communicate with other Claude agents.
Features
- 🚀 Agent Delegation - Spawn Claude sub-sessions with full control over configuration
- 💬 Bidirectional Communication - Send prompts and read responses from agent sessions
- 🔄 Session Management - Track active/completed sessions with automatic cleanup
- 📊 Circular Message Buffering - Efficient memory usage with 1000-message circular buffers
- 🎯 Type-Safe API - Strongly-typed Rust SDK with zero-cost abstractions
- ⚡ Lock-Free Concurrency - Non-blocking reader/writer architecture
- 🔐 Security First - Multiple layers of protection (env filtering, timeouts, buffer limits)
- 🪝 Hook System - Intercept and modify tool execution
- 🛡️ Permission Control - Fine-grained control over tool access
Architecture
This project provides both:
- Rust SDK - Direct programmatic access to Claude agent functionality
- MCP Server - HTTP/HTTPS server exposing 5 MCP tools for agent delegation
MCP Tools
| Tool | Description |
|---|---|
spawn_claude_agent |
Create a new Claude agent sub-session with configurable options |
send_claude_agent_prompt |
Send a prompt to an existing agent session |
read_claude_agent_output |
Read messages and responses from an agent session |
list_claude_agents |
List all active and completed agent sessions |
terminate_claude_agent_session |
Gracefully terminate an agent session |
Installation
Prerequisites
- Rust nightly toolchain (specified in
rust-toolchain.toml) - Claude Code CLI:
npm install -g @anthropic-ai/claude-code - Node.js (for Claude Code CLI)
Building from Source
# Clone the repository
# Build the project
# Run tests
# Build the HTTP server
Quick Start
Using the MCP Tools (via HTTP Server)
The HTTP server is typically managed by the kodegend daemon and runs on port 30460:
# Start the server
Using the Rust SDK
Add to your Cargo.toml:
[]
= "0.1"
Simple Query
use query;
use StreamExt;
async
Interactive Client
use ;
async
Agent Session Management
use ;
use Arc;
async
Examples
Run the comprehensive demo:
The demo showcases:
- Spawning Claude agent sub-sessions
- Multi-turn conversations with context persistence
- Multiple concurrent agents
- Session management and cleanup
- Message parsing and display
Documentation
- CLAUDE.md - Technical guidance for AI assistants working on this codebase
- API Docs - Run
cargo doc --openfor full API documentation - Examples - See
examples/directory for working code samples - Tests - See
tests/directory for integration test patterns
Development
Running Tests
# All tests
# Specific test suite
# With debug output
RUST_LOG=debug
Code Quality
# Lint with clippy
# Format code
# Check formatting
Project Structure
kodegen-claude-agent/
├── src/
│ ├── client/ # Interactive bidirectional client
│ ├── manager/ # Agent session management
│ ├── tools/ # MCP tool implementations
│ ├── transport/ # Communication layer (subprocess)
│ ├── control/ # Control protocol handler
│ ├── types/ # Type-safe abstractions
│ ├── hooks/ # Hook system
│ ├── permissions/ # Permission control
│ ├── message/ # Message parsing
│ ├── query.rs # Simple query function
│ ├── error.rs # Error types
│ ├── lib.rs # SDK library
│ └── main.rs # HTTP server binary
├── tests/ # Integration tests
├── examples/ # Usage examples
└── Cargo.toml
Security
This SDK includes multiple security layers:
- Environment Filtering - Blocks dangerous variables (
LD_PRELOAD,PATH,NODE_OPTIONS) - Argument Validation - CLI flags validated against allowlist
- Timeout Protection - 30-second timeouts on all I/O operations
- Buffer Limits - Default 1MB max buffer size prevents memory exhaustion
- Bounds Checking - Limits on configurable values (e.g.,
max_turns≤ 1000)
For complete security details, see SECURITY_FIXES_APPLIED.md in the repository.
Performance
- Zero-copy message streaming with circular buffers
- Lock-free concurrency - No reader/writer contention
- Efficient memory usage - Fixed-size buffers per session
- Async I/O - Built on tokio for high concurrency
Requirements
- Rust Edition: 2024
- Toolchain: nightly (see
rust-toolchain.toml) - Runtime: tokio async runtime
- Claude Code: Must be installed globally via npm
Contributing
Contributions are welcome! Please ensure:
- Code passes
cargo clippy - Code is formatted with
cargo fmt - All tests pass with
cargo test - New features include tests and documentation
License
Dual-licensed under Apache 2.0 OR MIT.
See LICENSE.md for details.
Acknowledgments
Part of the KODEGEN.ᴀɪ ecosystem for AI-powered development tools.
Authors: David Maple / KODEGEN.ᴀɪ
Built with ❤️ using Rust 🦀