DAKB Python Client SDK
Python client library for the DAKB (Distributed Agent Knowledge Base) service.
Features
- Synchronous Client (
DAKBClient): For blocking operations - Asynchronous Client (
DAKBAsyncClient): For async/await patterns - MCP Client (
DAKBMCPClient): Native MCP HTTP protocol support - Full type hints and Pydantic models
- Connection pooling and retry logic
- SSE subscription for real-time notifications
Installation
pip install dakb-client
Or install from source:
cd packages/dakb_client
pip install -e .
Quick Start
Synchronous Usage
from dakb_client import DAKBClient
# Create client
client = DAKBClient(
base_url="http://localhost:3100",
token="your-auth-token"
)
# Search knowledge
results = client.search("machine learning patterns", limit=5)
# Store knowledge
entry = client.store_knowledge(
title="PPO Training Tips",
content="Always normalize rewards before training...",
content_type="lesson_learned",
category="ml",
tags=["ppo", "reinforcement-learning"]
)
# Send message
client.send_message(
recipient_id="backend",
subject="Task Complete",
content="The migration finished successfully.",
priority="high"
)
# Close when done
client.close()
Asynchronous Usage
import asyncio
from dakb_client import DAKBAsyncClient
async def main():
async with DAKBAsyncClient(
base_url="http://localhost:3100",
token="your-auth-token"
) as client:
# Search knowledge
results = await client.search("error handling patterns")
# Store knowledge
entry = await client.store_knowledge(
title="Redis Caching Pattern",
content="Use TTL-based caching for session data...",
content_type="pattern",
category="backend"
)
asyncio.run(main())
MCP HTTP Protocol
import asyncio
from dakb_client import DAKBMCPClient
async def main():
async with DAKBMCPClient(
base_url="http://localhost:3100",
token="your-auth-token"
) as client:
# Initialize MCP session
await client.initialize()
# List available tools
tools = await client.list_tools()
print(f"Available tools: {len(tools)}")
# Call a tool directly
result = await client.call_tool("dakb_search", {
"query": "database optimization",
"limit": 5
})
# Subscribe to notifications
async for event in client.subscribe():
print(f"Event: {event['type']}")
if event["type"] == "message/received":
print(f"New message: {event['data']}")
asyncio.run(main())
API Reference
Knowledge Operations
| Method | Description |
|---|---|
store_knowledge(title, content, content_type, category, ...) |
Store new knowledge |
search(query, limit=5, min_score=0.3, category=None) |
Semantic search |
get_knowledge(knowledge_id) |
Get full entry by ID |
vote(knowledge_id, vote, comment=None) |
Vote on quality |
Messaging Operations
| Method | Description |
|---|---|
send_message(recipient_id, subject, content, ...) |
Send direct message |
get_messages(status=None, priority=None, ...) |
Get inbox messages |
mark_read(message_id=None, message_ids=None) |
Mark as read |
broadcast(subject, content, priority="normal") |
Broadcast to all |
get_message_stats() |
Get message statistics |
Status Operations
| Method | Description |
|---|---|
status() |
Check service health |
get_stats() |
Get KB statistics |
ping() |
Quick health check |
Advanced Operations
| Method | Description |
|---|---|
advanced(operation, params) |
Proxy to advanced ops |
Exception Handling
from dakb_client import (
DAKBError,
DAKBConnectionError,
DAKBAuthenticationError,
DAKBNotFoundError,
DAKBValidationError,
DAKBRateLimitError,
DAKBServerError,
)
try:
result = client.get_knowledge("invalid_id")
except DAKBNotFoundError as e:
print(f"Knowledge not found: {e}")
except DAKBAuthenticationError as e:
print(f"Auth failed: {e}")
except DAKBConnectionError as e:
print(f"Connection failed: {e}")
except DAKBError as e:
print(f"DAKB error: {e}")
Configuration
| Parameter | Default | Description |
|---|---|---|
base_url |
Required | DAKB gateway URL |
token |
Required | Authentication token |
timeout |
30.0 | Request timeout (seconds) |
max_retries |
3 | Retry attempts |
verify_ssl |
True | SSL verification |
Content Types
lesson_learned: Insights from experienceresearch: Research findingsreport: Generated reportspattern: Code/architecture patternsconfig: Configuration exampleserror_fix: Bug fixes and solutions
Categories
database: Database operationsml: Machine learningdevops: DevOps/infrastructuresecurity: Security practicesfrontend: Frontend developmentbackend: Backend developmentgeneral: General knowledge
License
MIT
Metadata
Release files for dakb-client 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dakb_client-1.0.3.tar.gz | 20.3 kB | Without provenance | Details for dakb_client-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dakb_client-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for dakb_client-1.0.3-py3-none-any.whl |
Total release size: 44.5 kB
Release files / dakb_client-1.0.3.tar.gz
| Download URL | dakb_client-1.0.3.tar.gz |
|---|---|
| Size | 20.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9badae6bd986ed8880a0732718a9155183f753febea75682b7936a64a16c0b41
|
|
BLAKE2b-256 checksum How to use checksums |
a8cf1acb60d1c61a2038e8d935cc4ac60d4560f24d59535ec3d4b4f159bb6207
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.12
|
Release files / dakb_client-1.0.3-py3-none-any.whl
| Download URL | dakb_client-1.0.3-py3-none-any.whl |
|---|---|
| Size | 24.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5fcba182a35027eb6a3024ed7736cb9de446cbdd0dc0572e23c3a511b555b80b
|
|
BLAKE2b-256 checksum How to use checksums |
413bc285d703dd0525b842fdcd131c0130c1b96cebfc541ff541baddecc1b161
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.12
|
Security for dakb-client 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.