|
| 1 | +# Reasoning Tools - Open Source (`reasoning_mcp_server_os.py`) |
| 2 | + |
| 3 | +The Reasoning MCP Server (Open Source) provides a **pure text-based reasoning engine** using open-source models. It supports logical analysis, problem solving, and planning, with robust retry mechanisms and exponential backoff for reliability. |
| 4 | + |
| 5 | +!!! info "Available Functions" |
| 6 | + This MCP server provides the following functions that agents can call: |
| 7 | + |
| 8 | + - **Pure Text Reasoning**: Logical analysis and problem solving using open-source LLM backends |
| 9 | + - **Step-by-Step Analysis**: Structured reasoning with detailed explanations |
| 10 | + - **Open-Source Model Support**: Qwen3-235B-A22B-Thinking-2507 with automatic fallback |
| 11 | + - **Robust Error Handling**: Exponential backoff retry logic (up to 10 attempts) |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Environment Variables |
| 16 | + |
| 17 | +!!! warning "Configuration Location" |
| 18 | + The `reasoning_mcp_server_os.py` reads environment variables that are passed through the `tool-reasoning-os.yaml` configuration file, not directly from `.env` file. |
| 19 | + |
| 20 | +**Open-Source Model Configuration:** |
| 21 | + |
| 22 | +- `REASONING_API_KEY`: Required API key for the open-source reasoning service |
| 23 | +- `REASONING_BASE_URL`: Base URL for the reasoning service API endpoint |
| 24 | +- `REASONING_MODEL_NAME`: Model name (default: `Qwen/Qwen3-235B-A22B-Thinking-2507`) |
| 25 | + |
| 26 | +**Example Configuration:** |
| 27 | +```bash |
| 28 | +# API for Open-Source Reasoning Tool (for benchmark testing) |
| 29 | +REASONING_MODEL_NAME="Qwen/Qwen3-235B-A22B-Thinking-2507" |
| 30 | +REASONING_API_KEY=your_reasoning_key |
| 31 | +REASONING_BASE_URL="https://your_reasoning_base_url/v1/chat/completions" |
| 32 | +``` |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## Local Deployment |
| 37 | + |
| 38 | +### Using SGLang Server |
| 39 | + |
| 40 | +For optimal performance with the Qwen3-235B-A22B-Thinking model, deploy using SGLang: |
| 41 | + |
| 42 | +```bash |
| 43 | +python3 -m sglang.launch_server \ |
| 44 | + --model-path /path/to/Qwen3-235B-A22B-Thinking-2507 \ |
| 45 | + --tp 8 --host 0.0.0.0 --port 1234 \ |
| 46 | + --trust-remote-code --enable-metrics \ |
| 47 | + --log-level debug --log-level-http debug \ |
| 48 | + --log-requests --log-requests-level 2 \ |
| 49 | + --show-time-cost --context-length 131072 |
| 50 | +``` |
| 51 | + |
| 52 | +### Configuration for Local Deployment |
| 53 | + |
| 54 | +When using local deployment, configure your environment variables: |
| 55 | + |
| 56 | +```bash |
| 57 | +REASONING_MODEL_NAME="Qwen/Qwen3-235B-A22B-Thinking-2507" |
| 58 | +REASONING_API_KEY="dummy_key" # Not required for local deployment |
| 59 | +REASONING_BASE_URL="http://localhost:1234/v1/chat/completions" |
| 60 | +``` |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## Function Reference |
| 65 | + |
| 66 | +The following function is provided by the `reasoning_mcp_server_os.py` MCP tool and can be called by agents: |
| 67 | + |
| 68 | +### `reasoning(question: str)` |
| 69 | + |
| 70 | +Perform step-by-step reasoning, analysis, and planning over a **text-only input**. This tool is specialized for **complex thinking tasks** that require deep analytical reasoning. |
| 71 | + |
| 72 | +!!! note "Text-Only Processing" |
| 73 | + This tool processes only the provided text input and will not fetch external data or context. Ensure all necessary information is included in the question. |
| 74 | + |
| 75 | +**Parameters:** |
| 76 | + |
| 77 | +- `question`: A detailed, complex question or problem statement that includes all necessary information |
| 78 | + |
| 79 | +**Returns:** |
| 80 | + |
| 81 | +- `str`: A structured, step-by-step reasoned answer |
| 82 | + |
| 83 | +**Features:** |
| 84 | + |
| 85 | +- **Open-Source Model**: Uses Qwen3-235B-A22B-Thinking-2507 for advanced reasoning |
| 86 | +- **Robust Retry Logic**: Exponential backoff retry mechanism (up to 10 attempts) |
| 87 | +- **Thinking Mode Support**: Automatically extracts reasoning content from thinking blocks |
| 88 | +- **Error Handling**: Graceful fallback with informative error messages |
| 89 | +- **Timeout Protection**: 600-second timeout for long-running reasoning tasks |
| 90 | +- **Jittered Backoff**: Prevents thundering herd problems with randomized retry delays |
| 91 | + |
| 92 | +**Retry Configuration:** |
| 93 | +- Maximum retries: 10 attempts |
| 94 | +- Initial backoff: 1.0 seconds |
| 95 | +- Maximum backoff: 30.0 seconds |
| 96 | +- Exponential backoff with jitter (0.8-1.2x multiplier) |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Usage Examples |
| 101 | + |
| 102 | +### Complex Mathematical Problems |
| 103 | +```python |
| 104 | +question = """ |
| 105 | +Solve this complex optimization problem: |
| 106 | +A company wants to minimize costs while maximizing production. |
| 107 | +Given constraints: 2x + 3y ≤ 100, x + y ≤ 50, x ≥ 0, y ≥ 0 |
| 108 | +Cost function: C = 5x + 8y |
| 109 | +Production function: P = 3x + 4y |
| 110 | +Find the optimal values of x and y. |
| 111 | +""" |
| 112 | +``` |
| 113 | + |
| 114 | +### Logical Puzzles |
| 115 | +```python |
| 116 | +question = """ |
| 117 | +Three people are in a room: Alice, Bob, and Charlie. |
| 118 | +- Alice says: "Bob is lying" |
| 119 | +- Bob says: "Charlie is lying" |
| 120 | +- Charlie says: "Alice is lying" |
| 121 | +If exactly one person is telling the truth, who is it? |
| 122 | +""" |
| 123 | +``` |
| 124 | + |
| 125 | +### Strategic Planning |
| 126 | +```python |
| 127 | +question = """ |
| 128 | +Design a strategy for a startup to enter a competitive market |
| 129 | +with limited resources. Consider market analysis, competitive |
| 130 | +positioning, resource allocation, and risk mitigation. |
| 131 | +""" |
| 132 | +``` |
| 133 | + |
| 134 | +!!! info "Documentation Info" |
| 135 | + **Last Updated:** January 2025 · **Doc Contributor:** Team @ MiroMind AI |
0 commit comments