bee-sdk 0.3.2__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bee_sdk-0.3.2 → bee_sdk-0.4.0}/PKG-INFO +5 -4
- {bee_sdk-0.3.2 → bee_sdk-0.4.0}/README.md +4 -3
- {bee_sdk-0.3.2 → bee_sdk-0.4.0}/bee_sdk/__init__.py +1 -1
- {bee_sdk-0.3.2 → bee_sdk-0.4.0}/bee_sdk/client.py +1 -1
- {bee_sdk-0.3.2 → bee_sdk-0.4.0}/bee_sdk/mcp.py +213 -259
- {bee_sdk-0.3.2 → bee_sdk-0.4.0}/mcpb/pyproject.toml +2 -2
- {bee_sdk-0.3.2 → bee_sdk-0.4.0}/pyproject.toml +1 -1
- {bee_sdk-0.3.2 → bee_sdk-0.4.0}/.gitignore +0 -0
- {bee_sdk-0.3.2 → bee_sdk-0.4.0}/bee_sdk/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bee-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Official Python client + MCP server for the Bee Intelligence Engine — domain-specialized LoRA-routed LLM by CUI Labs.
|
|
5
5
|
Project-URL: Homepage, https://bee.cuilabs.io
|
|
6
6
|
Project-URL: Documentation, https://bee.cuilabs.io/docs/sdks
|
|
@@ -41,11 +41,12 @@ Official Python client + MCP server for the **Bee Intelligence Engine** — a do
|
|
|
41
41
|
|
|
42
42
|
<!-- mcp-name: io.github.cuilabs/bee -->
|
|
43
43
|
|
|
44
|
-
SDK version: `0.
|
|
44
|
+
SDK version: `0.4.0` — adds per-call/`BEE_MODEL` model-tier selection (bee-cell … bee-swarm; access follows your key's plan) and MCP tool annotations.
|
|
45
45
|
|
|
46
46
|
Includes a hosted **Model Context Protocol** server: `pip install bee-sdk` then
|
|
47
|
-
run `bee-mcp` (stdio) to expose Bee's
|
|
48
|
-
VS Code, Zed, and
|
|
47
|
+
run `bee-mcp` (stdio) to expose Bee's 4 tools — `bee_chat`, `bee_code`,
|
|
48
|
+
`bee_security`, `bee_research` — to Claude Desktop, Cursor, VS Code, Zed, and
|
|
49
|
+
Windsurf. See [bee.cuilabs.io/docs/mcp](https://bee.cuilabs.io/docs/mcp).
|
|
49
50
|
|
|
50
51
|
> **Status:** functional sync + async client (stdlib + optional `httpx`).
|
|
51
52
|
> The SDK targets the Bee `/chat/completions` API contract on
|
|
@@ -4,11 +4,12 @@ Official Python client + MCP server for the **Bee Intelligence Engine** — a do
|
|
|
4
4
|
|
|
5
5
|
<!-- mcp-name: io.github.cuilabs/bee -->
|
|
6
6
|
|
|
7
|
-
SDK version: `0.
|
|
7
|
+
SDK version: `0.4.0` — adds per-call/`BEE_MODEL` model-tier selection (bee-cell … bee-swarm; access follows your key's plan) and MCP tool annotations.
|
|
8
8
|
|
|
9
9
|
Includes a hosted **Model Context Protocol** server: `pip install bee-sdk` then
|
|
10
|
-
run `bee-mcp` (stdio) to expose Bee's
|
|
11
|
-
VS Code, Zed, and
|
|
10
|
+
run `bee-mcp` (stdio) to expose Bee's 4 tools — `bee_chat`, `bee_code`,
|
|
11
|
+
`bee_security`, `bee_research` — to Claude Desktop, Cursor, VS Code, Zed, and
|
|
12
|
+
Windsurf. See [bee.cuilabs.io/docs/mcp](https://bee.cuilabs.io/docs/mcp).
|
|
12
13
|
|
|
13
14
|
> **Status:** functional sync + async client (stdlib + optional `httpx`).
|
|
14
15
|
> The SDK targets the Bee `/chat/completions` API contract on
|
|
@@ -27,7 +27,7 @@ VS Code, …) this package ships a hosted MCP server — run ``bee-mcp``
|
|
|
27
27
|
from .client import AsyncBee, Bee, BeeAPIError, BeeError, RateLimitError
|
|
28
28
|
from .types import ChatMessage, ChatResponse, Domain, ModelTier
|
|
29
29
|
|
|
30
|
-
__version__ = "0.
|
|
30
|
+
__version__ = "0.4.0"
|
|
31
31
|
__all__ = [
|
|
32
32
|
"Bee",
|
|
33
33
|
"AsyncBee",
|
|
@@ -30,6 +30,7 @@ exits with a clear error rather than pretending to work.
|
|
|
30
30
|
The 11 tools and 2 resources mirror the local-core server exactly, so a
|
|
31
31
|
client sees the same surface regardless of which backend serves it.
|
|
32
32
|
"""
|
|
33
|
+
|
|
33
34
|
from __future__ import annotations
|
|
34
35
|
|
|
35
36
|
import json
|
|
@@ -83,14 +84,12 @@ DOMAINS = [
|
|
|
83
84
|
TOOLS = [
|
|
84
85
|
{
|
|
85
86
|
"name": "bee_chat",
|
|
87
|
+
"title": "Ask Bee",
|
|
86
88
|
"description": (
|
|
87
|
-
"Ask Bee
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"business operations. Optionally pick a model tier (bee-cell free "
|
|
92
|
-
"… bee-swarm premium); tier access follows the API key's plan. "
|
|
93
|
-
"Bee is honest about uncertainty rather than fabricating."
|
|
89
|
+
"Ask Bee anything. Bee — The Progressive Intelligence Engine — is a "
|
|
90
|
+
"tiered LLM platform with per-domain specialisation. Optionally pick a "
|
|
91
|
+
"domain and a model tier; both are limited to what your API key's plan "
|
|
92
|
+
"allows. Bee is honest about uncertainty rather than fabricating."
|
|
94
93
|
),
|
|
95
94
|
"inputSchema": {
|
|
96
95
|
"type": "object",
|
|
@@ -98,164 +97,118 @@ TOOLS = [
|
|
|
98
97
|
"message": {"type": "string", "description": "The question or request"},
|
|
99
98
|
"domain": {
|
|
100
99
|
"type": "string",
|
|
101
|
-
"description": "
|
|
100
|
+
"description": "Optional domain specialist (defaults to general).",
|
|
102
101
|
"enum": DOMAINS,
|
|
103
|
-
"default": "general",
|
|
104
102
|
},
|
|
105
103
|
"model": {
|
|
106
104
|
"type": "string",
|
|
107
|
-
"description":
|
|
108
|
-
"Bee model tier. Access is governed by the API key's plan "
|
|
109
|
-
"(403 if the plan doesn't include it). Default: BEE_MODEL "
|
|
110
|
-
"env or bee-cell (free tier)."
|
|
111
|
-
),
|
|
105
|
+
"description": "Optional Bee model tier. Limited to your plan. Default: bee-cell.",
|
|
112
106
|
"enum": MODELS,
|
|
113
107
|
},
|
|
114
|
-
"max_tokens": {
|
|
108
|
+
"max_tokens": {
|
|
109
|
+
"type": "integer",
|
|
110
|
+
"description": "Max response tokens",
|
|
111
|
+
"default": 512,
|
|
112
|
+
},
|
|
113
|
+
"temperature": {"type": "number", "description": "Sampling temperature (optional)"},
|
|
115
114
|
},
|
|
116
115
|
"required": ["message"],
|
|
117
116
|
},
|
|
118
117
|
},
|
|
119
118
|
{
|
|
120
|
-
"name": "
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"type": "object",
|
|
124
|
-
"properties": {
|
|
125
|
-
"code": {"type": "string", "description": "The code to explain"},
|
|
126
|
-
"language": {"type": "string", "description": "Programming language", "default": "python"},
|
|
127
|
-
},
|
|
128
|
-
"required": ["code"],
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"name": "bee_fix_code",
|
|
133
|
-
"description": "Find and fix bugs in code. Bee identifies the root cause and provides a corrected version.",
|
|
134
|
-
"inputSchema": {
|
|
135
|
-
"type": "object",
|
|
136
|
-
"properties": {
|
|
137
|
-
"code": {"type": "string", "description": "The buggy code"},
|
|
138
|
-
"error": {"type": "string", "description": "Error message or description of the bug"},
|
|
139
|
-
"language": {"type": "string", "description": "Programming language", "default": "python"},
|
|
140
|
-
},
|
|
141
|
-
"required": ["code"],
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"name": "bee_refactor",
|
|
146
|
-
"description": "Refactor code for better readability, performance, and best practices.",
|
|
147
|
-
"inputSchema": {
|
|
148
|
-
"type": "object",
|
|
149
|
-
"properties": {
|
|
150
|
-
"code": {"type": "string", "description": "The code to refactor"},
|
|
151
|
-
"language": {"type": "string", "description": "Programming language", "default": "python"},
|
|
152
|
-
"focus": {"type": "string", "description": "What to focus on: performance, readability, security, types"},
|
|
153
|
-
},
|
|
154
|
-
"required": ["code"],
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"name": "bee_write_tests",
|
|
159
|
-
"description": "Generate comprehensive unit tests for code.",
|
|
160
|
-
"inputSchema": {
|
|
161
|
-
"type": "object",
|
|
162
|
-
"properties": {
|
|
163
|
-
"code": {"type": "string", "description": "The code to test"},
|
|
164
|
-
"language": {"type": "string", "description": "Programming language", "default": "python"},
|
|
165
|
-
"framework": {"type": "string", "description": "Test framework: pytest, jest, vitest, etc."},
|
|
166
|
-
},
|
|
167
|
-
"required": ["code"],
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
"name": "bee_security_audit",
|
|
172
|
-
"description": "Perform a security audit on code. Identifies vulnerabilities, suggests mitigations.",
|
|
119
|
+
"name": "bee_code",
|
|
120
|
+
"title": "Code Assistant",
|
|
121
|
+
"description": "Programming help from Bee's code specialist: explain code, fix a bug, refactor, or write tests — pick via `action`.",
|
|
173
122
|
"inputSchema": {
|
|
174
123
|
"type": "object",
|
|
175
124
|
"properties": {
|
|
176
|
-
"
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
"name": "bee_pentest_assist",
|
|
200
|
-
"description": (
|
|
201
|
-
"Assist with authorised penetration testing — analyse findings, "
|
|
202
|
-
"suggest next-step probes, draft remediation. Refuses unauthorised "
|
|
203
|
-
"/ malicious requests."
|
|
204
|
-
),
|
|
205
|
-
"inputSchema": {
|
|
206
|
-
"type": "object",
|
|
207
|
-
"properties": {
|
|
208
|
-
"context": {"type": "string", "description": "Engagement context (in-scope target, prior findings)"},
|
|
209
|
-
"question": {"type": "string", "description": "What you want help with"},
|
|
210
|
-
},
|
|
211
|
-
"required": ["context", "question"],
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
"name": "bee_quantum_circuit",
|
|
216
|
-
"description": (
|
|
217
|
-
"Help with quantum-circuit design (Qiskit), algorithm choice "
|
|
218
|
-
"(Shor / Grover / VQE / QAOA), error correction, NISQ-era "
|
|
219
|
-
"limitations."
|
|
220
|
-
),
|
|
221
|
-
"inputSchema": {
|
|
222
|
-
"type": "object",
|
|
223
|
-
"properties": {
|
|
224
|
-
"task": {"type": "string", "description": "What to design / explain"},
|
|
225
|
-
"framework": {"type": "string", "description": "Qiskit, Cirq, PennyLane, or natural-language", "default": "Qiskit"},
|
|
125
|
+
"action": {
|
|
126
|
+
"type": "string",
|
|
127
|
+
"description": "What to do with the code",
|
|
128
|
+
"enum": ["explain", "fix", "refactor", "write_tests"],
|
|
129
|
+
},
|
|
130
|
+
"code": {"type": "string", "description": "The code"},
|
|
131
|
+
"language": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"description": "Programming language",
|
|
134
|
+
"default": "python",
|
|
135
|
+
},
|
|
136
|
+
"error": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"description": "Error message / bug description (for action=fix)",
|
|
139
|
+
},
|
|
140
|
+
"focus": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"description": "What to optimise for (for action=refactor)",
|
|
143
|
+
},
|
|
144
|
+
"framework": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"description": "Test framework (for action=write_tests)",
|
|
147
|
+
},
|
|
226
148
|
},
|
|
227
|
-
"required": ["
|
|
149
|
+
"required": ["action", "code"],
|
|
228
150
|
},
|
|
229
151
|
},
|
|
230
152
|
{
|
|
231
|
-
"name": "
|
|
232
|
-
"
|
|
233
|
-
|
|
234
|
-
"vulnerabilities (reentrancy, access control, integer overflow, "
|
|
235
|
-
"front-running, oracle manipulation)."
|
|
236
|
-
),
|
|
153
|
+
"name": "bee_security",
|
|
154
|
+
"title": "Security Assistant",
|
|
155
|
+
"description": "Bee's security specialist: audit code, build a threat model, assist authorised penetration testing, or review a smart contract — pick via `task`. Refuses weaponisation / unauthorised targets.",
|
|
237
156
|
"inputSchema": {
|
|
238
157
|
"type": "object",
|
|
239
158
|
"properties": {
|
|
240
|
-
"
|
|
241
|
-
|
|
159
|
+
"task": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"description": "Security task",
|
|
162
|
+
"enum": [
|
|
163
|
+
"code_audit",
|
|
164
|
+
"threat_model",
|
|
165
|
+
"pentest_assist",
|
|
166
|
+
"smart_contract_review",
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
"input": {
|
|
170
|
+
"type": "string",
|
|
171
|
+
"description": "Code, system description, contract source, or finding",
|
|
172
|
+
},
|
|
173
|
+
"context": {
|
|
174
|
+
"type": "string",
|
|
175
|
+
"description": "Authorised-engagement scope (for task=pentest_assist)",
|
|
176
|
+
},
|
|
177
|
+
"framework": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"description": "Framework (for task=threat_model): STRIDE, PASTA, LINDDUN",
|
|
180
|
+
},
|
|
181
|
+
"language": {
|
|
182
|
+
"type": "string",
|
|
183
|
+
"description": "Language (for code_audit / smart_contract_review)",
|
|
184
|
+
},
|
|
242
185
|
},
|
|
243
|
-
"required": ["
|
|
186
|
+
"required": ["task", "input"],
|
|
244
187
|
},
|
|
245
188
|
},
|
|
246
189
|
{
|
|
247
|
-
"name": "
|
|
248
|
-
"
|
|
249
|
-
|
|
250
|
-
"supported by the experiments, missing ablations, statistical issues."
|
|
251
|
-
),
|
|
190
|
+
"name": "bee_research",
|
|
191
|
+
"title": "Research Assistant",
|
|
192
|
+
"description": "Bee's research specialist: design a quantum circuit (NISQ-honest, Qiskit) or critique an ML/CS paper — pick via `task`.",
|
|
252
193
|
"inputSchema": {
|
|
253
194
|
"type": "object",
|
|
254
195
|
"properties": {
|
|
255
|
-
"
|
|
256
|
-
|
|
196
|
+
"task": {
|
|
197
|
+
"type": "string",
|
|
198
|
+
"description": "Research task",
|
|
199
|
+
"enum": ["quantum_design", "paper_critique"],
|
|
200
|
+
},
|
|
201
|
+
"input": {
|
|
202
|
+
"type": "string",
|
|
203
|
+
"description": "The task to design, or the abstract to critique",
|
|
204
|
+
},
|
|
205
|
+
"framework": {
|
|
206
|
+
"type": "string",
|
|
207
|
+
"description": "Quantum framework (for quantum_design)",
|
|
208
|
+
},
|
|
209
|
+
"focus": {"type": "string", "description": "Critique focus (for paper_critique)"},
|
|
257
210
|
},
|
|
258
|
-
"required": ["
|
|
211
|
+
"required": ["task", "input"],
|
|
259
212
|
},
|
|
260
213
|
},
|
|
261
214
|
]
|
|
@@ -265,7 +218,13 @@ TOOLS = [
|
|
|
265
218
|
# to the hosted gateway and modifies nothing on the user's machine) and
|
|
266
219
|
# open-world (it talks to an external service).
|
|
267
220
|
for _tool in TOOLS:
|
|
268
|
-
|
|
221
|
+
# annotations.title mirrors the top-level title: clients (e.g. claude.ai)
|
|
222
|
+
# that display annotations.title then show "Ask Bee" etc., not bee_chat.
|
|
223
|
+
_tool["annotations"] = {
|
|
224
|
+
"readOnlyHint": True,
|
|
225
|
+
"openWorldHint": True,
|
|
226
|
+
"title": _tool["title"],
|
|
227
|
+
}
|
|
269
228
|
|
|
270
229
|
RESOURCES = [
|
|
271
230
|
{
|
|
@@ -287,15 +246,15 @@ RESOURCES = [
|
|
|
287
246
|
|
|
288
247
|
|
|
289
248
|
def handle_tool_call(client: Bee, name: str, arguments: dict[str, Any]) -> str:
|
|
290
|
-
"""Execute
|
|
291
|
-
mirror the local-core
|
|
249
|
+
"""Execute one of the 4 consolidated tools by forwarding to the hosted Bee
|
|
250
|
+
gateway. System prompts mirror apps/api/src/lib/mcp-tools.ts + the local-core
|
|
251
|
+
server so behaviour is identical across all three surfaces."""
|
|
292
252
|
if name == "bee_chat":
|
|
293
253
|
domain = arguments.get("domain", "general")
|
|
294
254
|
return client.chat(
|
|
295
255
|
message=arguments["message"],
|
|
296
|
-
domain=domain,
|
|
256
|
+
domain=domain if domain and domain != "general" else None,
|
|
297
257
|
max_tokens=arguments.get("max_tokens", 512),
|
|
298
|
-
# None falls through to BEE_MODEL env / bee-cell in the client.
|
|
299
258
|
model=arguments.get("model"),
|
|
300
259
|
system=(
|
|
301
260
|
f"You are Bee, a domain-specialized AI expert in {domain}. "
|
|
@@ -303,133 +262,105 @@ def handle_tool_call(client: Bee, name: str, arguments: dict[str, Any]) -> str:
|
|
|
303
262
|
),
|
|
304
263
|
)
|
|
305
264
|
|
|
306
|
-
if name == "
|
|
265
|
+
if name == "bee_code":
|
|
307
266
|
lang = arguments.get("language", "python")
|
|
267
|
+
code = arguments.get("code", "")
|
|
268
|
+
action = arguments.get("action", "explain")
|
|
269
|
+
block = f"```{lang}\n{code}\n```"
|
|
270
|
+
if action == "fix":
|
|
271
|
+
err = arguments.get("error", "")
|
|
272
|
+
prompt = f"Fix the bug in this {lang} code:\n\n{block}"
|
|
273
|
+
if err:
|
|
274
|
+
prompt += f"\n\nError: {err}"
|
|
275
|
+
return client.chat(
|
|
276
|
+
message=prompt,
|
|
277
|
+
domain="programming",
|
|
278
|
+
max_tokens=1024,
|
|
279
|
+
system="You are Bee, an expert debugger. Identify the root cause and provide the corrected version.",
|
|
280
|
+
)
|
|
281
|
+
if action == "refactor":
|
|
282
|
+
focus = arguments.get("focus", "readability and best practices")
|
|
283
|
+
return client.chat(
|
|
284
|
+
message=f"Refactor this {lang} code:\n\n{block}",
|
|
285
|
+
domain="programming",
|
|
286
|
+
max_tokens=1024,
|
|
287
|
+
system=f"You are Bee, an expert code reviewer. Refactor for {focus}.",
|
|
288
|
+
)
|
|
289
|
+
if action == "write_tests":
|
|
290
|
+
fw = arguments.get("framework", "pytest" if lang == "python" else "jest")
|
|
291
|
+
return client.chat(
|
|
292
|
+
message=f"Write tests for this {lang} code:\n\n{block}",
|
|
293
|
+
domain="programming",
|
|
294
|
+
max_tokens=1024,
|
|
295
|
+
system=f"You are Bee, a testing expert. Write comprehensive {fw} tests with edge cases.",
|
|
296
|
+
)
|
|
308
297
|
return client.chat(
|
|
309
|
-
message=f"Explain this {lang} code:\n\n
|
|
298
|
+
message=f"Explain this {lang} code:\n\n{block}",
|
|
310
299
|
domain="programming",
|
|
311
300
|
max_tokens=1024,
|
|
312
301
|
system="You are Bee, an expert code analyzer. Explain code clearly and concisely.",
|
|
313
302
|
)
|
|
314
303
|
|
|
315
|
-
if name == "
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
prompt = f"Fix the bug in this {lang} code:\n\n```{lang}\n{arguments['code']}\n```"
|
|
319
|
-
if error:
|
|
320
|
-
prompt += f"\n\nError: {error}"
|
|
321
|
-
return client.chat(
|
|
322
|
-
message=prompt,
|
|
323
|
-
domain="programming",
|
|
324
|
-
max_tokens=1024,
|
|
325
|
-
system="You are Bee, an expert debugger. Identify root cause and provide the fix.",
|
|
326
|
-
)
|
|
327
|
-
|
|
328
|
-
if name == "bee_refactor":
|
|
329
|
-
lang = arguments.get("language", "python")
|
|
330
|
-
focus = arguments.get("focus", "readability and best practices")
|
|
331
|
-
return client.chat(
|
|
332
|
-
message=f"Refactor this {lang} code:\n\n```{lang}\n{arguments['code']}\n```",
|
|
333
|
-
domain="programming",
|
|
334
|
-
max_tokens=1024,
|
|
335
|
-
system=f"You are Bee, an expert code reviewer. Refactor for {focus}.",
|
|
336
|
-
)
|
|
337
|
-
|
|
338
|
-
if name == "bee_write_tests":
|
|
339
|
-
lang = arguments.get("language", "python")
|
|
340
|
-
fw = arguments.get("framework", "pytest" if lang == "python" else "jest")
|
|
341
|
-
return client.chat(
|
|
342
|
-
message=f"Write tests for this {lang} code:\n\n```{lang}\n{arguments['code']}\n```",
|
|
343
|
-
domain="programming",
|
|
344
|
-
max_tokens=1024,
|
|
345
|
-
system=f"You are Bee, a testing expert. Write comprehensive {fw} tests with edge cases.",
|
|
346
|
-
)
|
|
347
|
-
|
|
348
|
-
if name == "bee_security_audit":
|
|
304
|
+
if name == "bee_security":
|
|
305
|
+
task = arguments.get("task", "code_audit")
|
|
306
|
+
inp = arguments.get("input", "")
|
|
349
307
|
lang = arguments.get("language", "python")
|
|
308
|
+
if task == "threat_model":
|
|
309
|
+
fw = arguments.get("framework", "STRIDE")
|
|
310
|
+
return client.chat(
|
|
311
|
+
message=f"Threat-model this:\n\n{inp}",
|
|
312
|
+
domain="cybersecurity",
|
|
313
|
+
max_tokens=1500,
|
|
314
|
+
temperature=0.1,
|
|
315
|
+
system=f"You are Bee, a security architect. Build a {fw} threat model: assets, trust boundaries, attacker capabilities, attack paths, mitigations. Defensive only.",
|
|
316
|
+
)
|
|
317
|
+
if task == "pentest_assist":
|
|
318
|
+
ctx = arguments.get("context", "")
|
|
319
|
+
return client.chat(
|
|
320
|
+
message=f"Engagement context: {ctx}\n\nRequest: {inp}",
|
|
321
|
+
domain="cybersecurity",
|
|
322
|
+
max_tokens=1500,
|
|
323
|
+
temperature=0.2,
|
|
324
|
+
system="You are Bee, assisting an authorised penetration tester. If the request is not clearly within an authorised engagement (written scope / signed agreement / CTF / your own system), REFUSE and recommend obtaining authorisation first. Otherwise help with attack-graph reasoning, exploitability triage, proof artifacts, and remediation drafting. Do not produce deployable malware or instructions against unfamiliar third-party systems.",
|
|
325
|
+
)
|
|
326
|
+
if task == "smart_contract_review":
|
|
327
|
+
return client.chat(
|
|
328
|
+
message=f"Review this contract:\n\n```\n{inp}\n```",
|
|
329
|
+
domain="blockchain",
|
|
330
|
+
max_tokens=1500,
|
|
331
|
+
temperature=0.1,
|
|
332
|
+
system="You are Bee, a smart-contract auditor. Check for: reentrancy, access-control gaps, integer over/underflow, front-running / MEV exposure, oracle manipulation, gas optimisation. Cite SWC-Registry IDs where applicable.",
|
|
333
|
+
)
|
|
350
334
|
return client.chat(
|
|
351
|
-
message=f"Security audit this {lang} code:\n\n```{lang}\n{
|
|
335
|
+
message=f"Security audit this {lang} code:\n\n```{lang}\n{inp}\n```",
|
|
352
336
|
domain="cybersecurity",
|
|
353
337
|
max_tokens=1024,
|
|
354
338
|
temperature=0.1,
|
|
355
|
-
system=
|
|
356
|
-
"You are Bee, a cybersecurity expert. Audit code for vulnerabilities using OWASP and CWE references. "
|
|
357
|
-
"For user-owned or authorized lab code, include exploitability reasoning, proof strategy, impact, and concrete fix guidance. "
|
|
358
|
-
"Refuse only requests to weaponize against real third-party targets or to produce deployable malware."
|
|
359
|
-
),
|
|
360
|
-
)
|
|
361
|
-
|
|
362
|
-
if name == "bee_threat_model":
|
|
363
|
-
framework = arguments.get("framework", "STRIDE")
|
|
364
|
-
return client.chat(
|
|
365
|
-
message=f"Threat-model this:\n\n{arguments['description']}",
|
|
366
|
-
domain="cybersecurity",
|
|
367
|
-
max_tokens=1500,
|
|
368
|
-
temperature=0.1,
|
|
369
|
-
system=(
|
|
370
|
-
f"You are Bee, a security architect. Build a {framework} threat model: assets, trust "
|
|
371
|
-
"boundaries, attacker capabilities, attack paths, mitigations. Defensive only."
|
|
372
|
-
),
|
|
339
|
+
system="You are Bee, a cybersecurity expert. Audit code for vulnerabilities using OWASP and CWE references. For user-owned or authorized lab code, include exploitability reasoning, proof strategy, impact, and concrete fix guidance. Refuse only requests to weaponize against real third-party targets or to produce deployable malware.",
|
|
373
340
|
)
|
|
374
341
|
|
|
375
|
-
if name == "
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
"
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
"
|
|
386
|
-
|
|
387
|
-
"deployable malware or instructions against unfamiliar third-party systems."
|
|
388
|
-
),
|
|
389
|
-
)
|
|
390
|
-
|
|
391
|
-
if name == "bee_quantum_circuit":
|
|
392
|
-
framework = arguments.get("framework", "Qiskit")
|
|
393
|
-
return client.chat(
|
|
394
|
-
message=arguments["task"],
|
|
395
|
-
domain="quantum",
|
|
396
|
-
max_tokens=1500,
|
|
397
|
-
temperature=0.2,
|
|
398
|
-
system=(
|
|
399
|
-
f"You are Bee, a quantum-computing expert. Use {framework}. When discussing algorithms "
|
|
400
|
-
"(Shor / Grover / VQE / QAOA), be honest about NISQ-era limitations: small qubit counts, "
|
|
401
|
-
"decoherence, gate error. No magical-quantum-speedup claims."
|
|
402
|
-
),
|
|
403
|
-
)
|
|
404
|
-
|
|
405
|
-
if name == "bee_smart_contract_review":
|
|
406
|
-
lang = arguments.get("language", "solidity")
|
|
407
|
-
return client.chat(
|
|
408
|
-
message=f"Review this {lang} contract:\n\n```{lang}\n{arguments['code']}\n```",
|
|
409
|
-
domain="blockchain",
|
|
410
|
-
max_tokens=1500,
|
|
411
|
-
temperature=0.1,
|
|
412
|
-
system=(
|
|
413
|
-
"You are Bee, a smart-contract auditor. Check for: reentrancy, access-control gaps, "
|
|
414
|
-
"integer over/underflow, front-running / MEV exposure, oracle manipulation, gas "
|
|
415
|
-
"optimisation. Cite SWC-Registry IDs where applicable."
|
|
416
|
-
),
|
|
417
|
-
)
|
|
418
|
-
|
|
419
|
-
if name == "bee_paper_critique":
|
|
342
|
+
if name == "bee_research":
|
|
343
|
+
task = arguments.get("task", "paper_critique")
|
|
344
|
+
inp = arguments.get("input", "")
|
|
345
|
+
if task == "quantum_design":
|
|
346
|
+
fw = arguments.get("framework", "Qiskit")
|
|
347
|
+
return client.chat(
|
|
348
|
+
message=inp,
|
|
349
|
+
domain="quantum",
|
|
350
|
+
max_tokens=1500,
|
|
351
|
+
temperature=0.2,
|
|
352
|
+
system=f"You are Bee, a quantum-computing expert. Use {fw}. Be honest about NISQ-era limitations: small qubit counts, decoherence, gate error. No magical-quantum-speedup claims.",
|
|
353
|
+
)
|
|
420
354
|
focus = arguments.get("focus", "methodology and claim-evidence alignment")
|
|
421
355
|
return client.chat(
|
|
422
|
-
message=f"Critique:\n\n{
|
|
356
|
+
message=f"Critique:\n\n{inp}",
|
|
423
357
|
domain="research",
|
|
424
358
|
max_tokens=1500,
|
|
425
359
|
temperature=0.3,
|
|
426
|
-
system=
|
|
427
|
-
f"You are Bee, an ML research critic. Focus on {focus}. Identify: claims unsupported by "
|
|
428
|
-
"experiments, missing ablations, p-hacking risks, reproducibility gaps."
|
|
429
|
-
),
|
|
360
|
+
system=f"You are Bee, an ML research critic. Focus on {focus}. Identify: claims unsupported by experiments, missing ablations, p-hacking risks, reproducibility gaps.",
|
|
430
361
|
)
|
|
431
362
|
|
|
432
|
-
|
|
363
|
+
raise ValueError(f"Unknown tool: {name}")
|
|
433
364
|
|
|
434
365
|
|
|
435
366
|
def handle_resource_read(client: Bee, uri: str) -> dict[str, Any]:
|
|
@@ -446,20 +377,32 @@ def handle_resource_read(client: Bee, uri: str) -> dict[str, Any]:
|
|
|
446
377
|
except BeeError as e: # network / auth — report, don't crash
|
|
447
378
|
status["gateway_health"] = {"error": str(e)}
|
|
448
379
|
return {
|
|
449
|
-
"contents": [
|
|
450
|
-
{"uri": uri, "mimeType": "application/json", "text": json.dumps(status)}
|
|
451
|
-
]
|
|
380
|
+
"contents": [{"uri": uri, "mimeType": "application/json", "text": json.dumps(status)}]
|
|
452
381
|
}
|
|
453
382
|
if uri == "bee://domains":
|
|
454
383
|
return {
|
|
455
|
-
"contents": [
|
|
456
|
-
{"uri": uri, "mimeType": "application/json", "text": json.dumps(DOMAINS)}
|
|
457
|
-
]
|
|
384
|
+
"contents": [{"uri": uri, "mimeType": "application/json", "text": json.dumps(DOMAINS)}]
|
|
458
385
|
}
|
|
459
386
|
return {"contents": []}
|
|
460
387
|
|
|
461
388
|
|
|
462
|
-
SERVER_INFO = {
|
|
389
|
+
SERVER_INFO = {
|
|
390
|
+
"name": "bee",
|
|
391
|
+
"title": "Bee",
|
|
392
|
+
"version": SERVER_VERSION,
|
|
393
|
+
"description": (
|
|
394
|
+
"Bee — The Progressive Intelligence Engine: a tiered LLM platform with "
|
|
395
|
+
"per-domain specialisation."
|
|
396
|
+
),
|
|
397
|
+
"websiteUrl": "https://bee.cuilabs.io",
|
|
398
|
+
"icons": [
|
|
399
|
+
{
|
|
400
|
+
"src": "https://api.bee.cuilabs.io/icon.png",
|
|
401
|
+
"mimeType": "image/png",
|
|
402
|
+
"sizes": ["512x512"],
|
|
403
|
+
}
|
|
404
|
+
],
|
|
405
|
+
}
|
|
463
406
|
SERVER_CAPABILITIES = {"tools": {}, "resources": {}}
|
|
464
407
|
|
|
465
408
|
|
|
@@ -495,7 +438,9 @@ def dispatch(client: Bee, msg: dict) -> dict | None:
|
|
|
495
438
|
return {"jsonrpc": "2.0", "id": msg_id, "result": {"tools": TOOLS}}
|
|
496
439
|
if method == "tools/call":
|
|
497
440
|
try:
|
|
498
|
-
result_text = handle_tool_call(
|
|
441
|
+
result_text = handle_tool_call(
|
|
442
|
+
client, params.get("name", ""), params.get("arguments", {})
|
|
443
|
+
)
|
|
499
444
|
is_error = False
|
|
500
445
|
except BeeAPIError as e:
|
|
501
446
|
# Surface API errors as tool errors (honest), not crashes.
|
|
@@ -589,8 +534,14 @@ def run_http(default_client: Bee, port: int) -> None:
|
|
|
589
534
|
body = self.rfile.read(length) if length else b""
|
|
590
535
|
msg = json.loads(body) if body else {}
|
|
591
536
|
except (ValueError, json.JSONDecodeError):
|
|
592
|
-
self._json(
|
|
593
|
-
|
|
537
|
+
self._json(
|
|
538
|
+
400,
|
|
539
|
+
{
|
|
540
|
+
"jsonrpc": "2.0",
|
|
541
|
+
"id": None,
|
|
542
|
+
"error": {"code": -32700, "message": "Parse error"},
|
|
543
|
+
},
|
|
544
|
+
)
|
|
594
545
|
return
|
|
595
546
|
resp = dispatch(self._client_for_request(), msg)
|
|
596
547
|
if resp is None:
|
|
@@ -624,9 +575,12 @@ def main() -> None:
|
|
|
624
575
|
description="Bee MCP Server — forwards tool calls to the hosted Bee gateway.",
|
|
625
576
|
)
|
|
626
577
|
parser.add_argument(
|
|
627
|
-
"--http",
|
|
578
|
+
"--http",
|
|
579
|
+
type=int,
|
|
580
|
+
default=0,
|
|
581
|
+
metavar="PORT",
|
|
628
582
|
help="Serve Streamable HTTP on PORT (default: stdio). Binds 127.0.0.1; "
|
|
629
|
-
|
|
583
|
+
"set BEE_MCP_HTTP_HOST to change.",
|
|
630
584
|
)
|
|
631
585
|
args = parser.parse_args()
|
|
632
586
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "bee-sdk"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "Official Python client + MCP server for the Bee Intelligence Engine — domain-specialized LoRA-routed LLM by CUI Labs."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
File without changes
|
|
File without changes
|