Skip to content

Latest commit

 

History

History
320 lines (240 loc) · 7.5 KB

File metadata and controls

320 lines (240 loc) · 7.5 KB

ThinkChain Integration with CCDK i124q

Overview

ThinkChain is an advanced Python project that showcases Claude's streaming capabilities with interleaved thinking, fine-grained tool streaming, and dynamic tool discovery. CCDK i124q provides seamless integration with ThinkChain, allowing you to leverage these powerful features within your Claude Code environment.

Key Features

1. Interleaved Thinking

  • Step-by-step problem solving with visible thought process
  • Real-time streaming of Claude's reasoning
  • Early interception of tool_use blocks

2. Fine-Grained Tool Streaming

  • Live progress updates during tool execution
  • Multiple tool calls per turn
  • Pydantic-validated inputs for robustness

3. Dynamic Tool Discovery

  • Automatic discovery of local Python tools
  • MCP server integration
  • Custom tool creation on-the-fly

4. Bridge Mode (No API Key Required)

CCDK i124q introduces a unique Bridge Mode that allows you to use many ThinkChain features without an Anthropic API key:

  • Local tool execution
  • MCP server management
  • Tool discovery and listing
  • Simulated thinking streams

Installation Methods

Method 1: Through Ultimate Installer

# Run the ultimate installer
bash install-ultimate.sh

# Navigate to ThinkChain configuration
# Type: tc or thinkchain
# Select option 1 to install

Method 2: Manual Installation

# Clone ThinkChain
git clone https://github.com/martinbowling/ThinkChain.git /c/Users/wtyle/thinkchain

# Run integration script
bash integrations/thinkchain-integration.sh

Configuration Options

API Key Configuration

ThinkChain requires an Anthropic API key for full functionality. This is different from your Claude.ai subscription.

  1. Get an API key from Anthropic Console
  2. Configure through installer or manually:
echo "ANTHROPIC_API_KEY=your_api_key_here" > /c/Users/wtyle/thinkchain/.env

Bridge Mode Setup

Bridge Mode allows using ThinkChain tools without an API key:

# From ultimate installer
tc → 3 (Set Up Bridge Mode)

# Or manually
python3 integrations/thinkchain-bridge.py init

Usage in Claude Code

Commands

Once integrated, you can use these commands in Claude Code:

/think [prompt]

Trigger ThinkChain's advanced thinking mode:

/think Create a web scraper that monitors price changes

/tools

Manage ThinkChain tools:

/tools list              - List all available tools
/tools refresh           - Refresh tool discovery
/tools enable [name]     - Enable a specific tool
/tools disable [name]    - Disable a specific tool

Available Tools

Local Python Tools

  • FileCreator - Create new files
  • FileEditor - Edit existing files
  • FileContentReader - Read file contents
  • DiffEditor - Apply diffs to files
  • WebScraper - Scrape web content
  • DuckDuckGo - Search the web
  • Weather - Get weather information
  • UVPackageManager - Manage Python packages
  • Linting - Check code quality
  • ToolCreator - Create new tools dynamically

MCP Server Tools

  • SQLite - Database operations
  • Filesystem - Advanced file operations
  • GitHub - Repository management
  • Memory - Knowledge graph storage
  • Puppeteer - Browser automation
  • Brave Search - Web search

Project Integration

Enable for a Specific Project

  1. Create a CLAUDE.PROJECT marker file in your project
  2. Run the installer and select your project
  3. Choose ThinkChain integration

This creates .claude/thinkchain/config.json:

{
  "enabled": true,
  "version": "1.0.0",
  "thinkchain_path": "/c/Users/wtyle/thinkchain",
  "features": {
    "interleaved_thinking": true,
    "tool_streaming": true,
    "mcp_integration": true,
    "bridge_mode": true
  },
  "settings": {
    "model": "claude-sonnet-4-20250514",
    "thinking_budget": 1024,
    "max_tokens": 1024
  }
}

Advanced Configuration

Thinking Settings

Configure Claude's thinking parameters:

CONFIG = {
    "model": "claude-sonnet-4-20250514",  # or claude-opus-4
    "thinking_budget": 1024,  # 1024-16000 tokens
    "max_tokens": 1024  # Output limit
}

MCP Server Configuration

Edit mcp_config_enhanced.json:

{
  "mcpServers": {
    "your_server": {
      "command": "command_to_run",
      "args": ["arg1", "arg2"],
      "env": {
        "API_KEY": "your_key"
      },
      "enabled": true
    }
  }
}

Bridge Mode API

The ThinkChain Bridge provides a Python API for Claude Code integration:

from thinkchain_bridge import ThinkChainBridge

bridge = ThinkChainBridge()
bridge.initialize()

# List tools without API key
tools = bridge.list_available_tools()

# Execute local tool
result = bridge.execute_local_tool("FileCreator", 
    path="/path/to/file.txt",
    content="Hello World"
)

# Simulate thinking (no API needed)
thinking = bridge.simulate_thinking_stream("Your prompt here")

Troubleshooting

ThinkChain Not Found

git clone https://github.com/martinbowling/ThinkChain.git /c/Users/wtyle/thinkchain

Python Dependencies Missing

cd /c/Users/wtyle/thinkchain
uv pip install -r requirements.txt
# or
pip3 install -r requirements.txt

API Key Issues

  • Ensure you have an Anthropic API key (not Claude.ai account)
  • Check .env file exists in ThinkChain directory
  • Use Bridge Mode for operations without API

MCP Servers Not Working

  • Ensure Node.js is installed for npm-based servers
  • Check server configuration in mcp_config.json
  • Verify required environment variables are set

Important Notes

API Key vs Claude Max Account

  • Claude Max/Claude.ai: Web interface subscription, no API access
  • Anthropic API: Separate service requiring API key and payment
  • Bridge Mode: CCDK feature allowing tool use without API

When You Need an API Key

  • Full thinking streams with actual Claude responses
  • Complex multi-step reasoning
  • Production use of ThinkChain

When Bridge Mode is Sufficient

  • Local tool execution
  • File operations
  • MCP server management
  • Development and testing

Examples

Example 1: File Operations without API

# Using Bridge Mode
from thinkchain_bridge import ThinkChainBridge

bridge = ThinkChainBridge()
bridge.initialize()

# Create a file
bridge.execute_local_tool("FileCreator",
    path="test.py",
    content="print('Hello from ThinkChain!')"
)

Example 2: Web Scraping

# Scrape a website
result = bridge.execute_local_tool("WebScraper",
    url="https://example.com",
    selector="h1"
)

Example 3: Custom Tool Creation

# Create a new tool dynamically
spec = {
    "name": "MyCustomTool",
    "code": '''
from tools.base import Tool
from pydantic import BaseModel, Field

class MyCustomToolInput(BaseModel):
    message: str = Field(description="Message to process")

class MyCustomTool(Tool):
    """Custom tool for demonstration"""
    
    input_model = MyCustomToolInput
    
    def execute(self, message: str) -> str:
        return f"Processed: {message}"
'''
}

bridge.create_tool_from_spec(spec)

Future Enhancements

  • Direct Claude Code integration without API key requirement
  • Visual thinking stream renderer
  • Tool marketplace integration
  • Collaborative tool sharing
  • Performance optimizations for Bridge Mode

For more information: