DreamLog Integrations¶
DreamLog provides multiple integration options to work with various tools and platforms.
Available Integrations¶
MCP Server¶
Model Context Protocol integration for AI assistants like Claude Desktop.
- Tool-based interaction with DreamLog
- Knowledge base management
- Query execution
- Dream cycle operations
REST API¶
HTTP API server for web applications and services.
- RESTful endpoints for all operations
- WebSocket support for real-time REPL
- JSON request/response format
- Authentication and rate limiting
Jupyter Integration (Coming Soon)¶
Magic commands for Jupyter notebooks.
%%dreamlogcell magic- Interactive knowledge exploration
- Visualization of query results
- Dream cycle analysis
TUI (Terminal User Interface)¶
Interactive terminal interface.
dreamlogorpython -m dreamlog.tui- Main TUI- Rich formatting and syntax highlighting
- LLM and dreaming commands
- Knowledge base management
Quick Start¶
MCP Server¶
REST API¶
# Start API server
python -m dreamlog.integrations.api --port 8000
# Make requests
curl -X POST http://localhost:8000/query \
-H "Content-Type: application/json" \
-d '{"query": "(parent john X)"}'
Jupyter¶
# Load extension
%load_ext dreamlog.integrations.jupyter
# Use magic command
%%dreamlog
(parent john mary)
(parent mary alice)
(grandparent X Z) :- (parent X Y), (parent Y Z)
query: (grandparent john X)
Integration Architecture¶
┌──────────────────────────────────────┐
│ Client Applications │
├────────┬────────┬────────┬──────────┤
│ MCP │ REST │Jupyter │ VS Code │
│ Server │ API │ Magic │Extension │
├────────┴────────┴────────┴──────────┤
│ DreamLog Core Engine │
├──────────────────────────────────────┤
│ Knowledge Base & LLM Providers │
└──────────────────────────────────────┘
Common Integration Patterns¶
1. Embedded Integration¶
Embed DreamLog directly in your Python application:
from dreamlog import DreamLog
dl = DreamLog()
dl.add_fact("(parent john mary)")
results = dl.query("(parent john X)")
2. Service Integration¶
Run DreamLog as a service and communicate via API:
import requests
response = requests.post(
"http://dreamlog-server:8000/query",
json={"query": "(parent john X)"}
)
results = response.json()
3. Tool Integration¶
Use DreamLog through MCP tools in AI assistants:
{
"tool": "dreamlog_query",
"parameters": {
"query": "(parent john X)",
"knowledge_base": "family.dl"
}
}
Configuration¶
Each integration can be configured via:
- Environment variables
- Configuration files (
dreamlog.yaml) - Command-line arguments
Example configuration:
# dreamlog.yaml
integrations:
api:
port: 8000
host: "0.0.0.0"
cors: true
mcp:
max_query_results: 100
enable_dreaming: true
jupyter:
auto_display: true
syntax_highlight: true
Security Considerations¶
When using integrations:
- Authentication: Use API keys for REST endpoints
- Rate limiting: Prevent abuse of LLM providers
- Input validation: Sanitize all user inputs
- Sandboxing: Run untrusted queries in isolation
- Audit logging: Track all operations
Performance Tips¶
- Connection pooling: Reuse connections for API calls
- Caching: Cache query results and LLM responses
- Async operations: Use async/await for I/O operations
- Batch processing: Group multiple operations
- Resource limits: Set memory and time limits
Troubleshooting¶
Common Issues¶
MCP Server not connecting - Check firewall settings - Verify port availability - Review MCP configuration
REST API timeout - Increase timeout settings - Optimize complex queries - Check LLM provider response times
Jupyter kernel crashes - Limit query result size - Check memory usage - Update Jupyter and dependencies
Contributing¶
To add a new integration:
- Create module in
dreamlog/integrations/ - Implement integration protocol
- Add documentation
- Write tests
- Submit pull request
See the GitHub repository for details.