Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
kodegen-tools-reasoner
Memory-efficient, Blazing-Fast MCP tools for code generation agents with advanced reasoning capabilities.
Overview
kodegen-tools-reasoner is a high-performance MCP (Model Context Protocol) server that provides sophisticated reasoning strategies for AI agents. It implements multiple search algorithms including Beam Search, Monte Carlo Tree Search (MCTS), and experimental variants designed for complex problem-solving with branching and revision support.
Key Features
- 🚀 Multiple Reasoning Strategies: Beam Search, MCTS, and experimental variants (MCTS 002 Alpha, MCTS 002 Alt Alpha)
- 🧠 Local Semantic Scoring: Uses Stella 400M embeddings via Candle for semantic coherence analysis
- 🔄 Branching & Revision Support: Explore multiple solution paths from a common parent
- ⚡ High Performance: LRU caching with memory pressure detection and lock-free atomic telemetry
- 🌐 MCP Protocol: Standard Model Context Protocol for seamless agent integration
- 📊 Comprehensive Statistics: Real-time metrics for all reasoning strategies
Installation
Prerequisites
- Rust nightly toolchain
- Cargo
Build from Source
# Clone the repository
# Build the project
# Run the server
The server will start on the default port (30453) and expose the MCP tool interface.
Usage
Running the Server
# Run in development mode
# Run in release mode
# Run with logging
RUST_LOG=info
Running Examples
# Run the comprehensive reasoner demo
Reasoning Strategies
1. Beam Search (Default)
Breadth-first exploration that maintains the top N paths simultaneously.
Best for: Balanced exploration, general problem-solving
Parameters:
beamWidth: Number of paths to maintain (default: 3)
2. MCTS (Monte Carlo Tree Search)
Standard MCTS with UCB1/PUCT selection for exploration-exploitation balance.
Best for: Decision trees, game-like problems, optimization
Parameters:
numSimulations: Number of rollouts per thought (default: 50)
3. MCTS 002 Alpha
MCTS with 10% higher exploration bonus for creative problem-solving.
Best for: Creative solutions, exploring novel approaches
4. MCTS 002 Alt Alpha
MCTS variant that rewards longer, more detailed reasoning paths.
Best for: Detailed analysis, thorough explanations
MCP Tool API
Tool: reasoner
Process thoughts step-by-step with advanced reasoning strategies.
Input Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
thought |
string | Yes | Current reasoning step text |
thoughtNumber |
integer | Yes | Current thought index (1-based) |
totalThoughts |
integer | Yes | Estimated total thoughts needed |
nextThoughtNeeded |
boolean | Yes | Whether more reasoning is required |
strategyType |
string | No | Reasoning strategy (default: "beam_search") |
beamWidth |
integer | No | Paths to maintain for beam search (default: 3) |
numSimulations |
integer | No | MCTS rollouts per thought (default: 50) |
parentId |
string | No | Parent node ID for branching thoughts |
Output Response
Architecture
Component Overview
┌─────────────────────────────────────────┐
│ MCP Tool Interface │
│ (reasoner) │
└──────────────┬──────────────────────────┘
│
┌──────────────▼──────────────────────────┐
│ Reasoner │
│ (Route requests to strategies) │
└──────────────┬──────────────────────────┘
│
┌─────┴─────────────┬──────────────┐
│ │ │
┌────────▼────────┐ ┌──────▼──────┐ ┌───▼──────────┐
│ BeamSearch │ │ MCTS │ │ MCTS Variants│
│ │ │ │ │ │
└────────┬────────┘ └──────┬──────┘ └───┬──────────┘
│ │ │
└──────────────────┴──────────────┘
│
┌────────▼────────┐
│ BaseStrategy │
│ (Stella 400M │
│ Embeddings) │
└────────┬────────┘
│
┌────────▼────────┐
│ StateManager │
│ (LRU Cache + │
│ HashMap) │
└─────────────────┘
Key Components
- Reasoner: Orchestrates strategy selection and result aggregation
- StateManager: Thread-safe dual-layer caching (LRU + HashMap) with strict lock ordering
- Strategies: Pluggable reasoning algorithms (Beam Search, MCTS, variants)
- BaseStrategy: Shared embedding-based semantic scoring using local Stella 400M model
Configuration
Key configuration constants in src/types.rs:
pub const CONFIG: Config = Config ;
Development
Running Tests
# Run all tests
# Run tests with output
# Run specific test
Code Quality
# Format code
# Check formatting
# Run linter
# Run linter with all warnings
Building for Different Targets
# Build for native target
# Build for WASM
Performance
The reasoner is optimized for high-performance operation:
- LRU Caching: Hot-path optimization with configurable cache size
- Atomic Telemetry: Lock-free cache statistics tracking
- Memory Pressure Detection: Automatic cache adjustment using
sysinfo - Concurrent Access: Thread-safe StateManager with deadlock-preventing lock ordering
- Local Embeddings: No network latency - Stella 400M runs locally via Candle
Cache Statistics
Monitor embedding cache performance:
let stats = reasoner.get_cache_stats;
println!;
println!;
println!;
Contributing
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run
cargo fmtandcargo clippy - Submit a pull request
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Links
- Homepage: https://kodegen.ai
- Repository: https://github.com/cyrup-ai/kodegen-tools-reasoner
- MCP Protocol: Model Context Protocol
Acknowledgments
Built by KODEGEN.ᴀɪ for high-performance AI agent reasoning.