mirror of
https://github.com/hanzoai/mcp.git
synced 2026-10-15 12:30:12 +00:00
- Implement 8 native purpose-built Kai tools in src/tools/kai.ts: - kai_tool_select: shortlist tools & resolve client casing/aliases (bash -> Bash) - kai_next_action: emit executable action with zero-inference fast paths - kai_command_guard: monotonic security policy lattice (allow < ask < deny) - kai_injection_screen: prompt-injection & override screening - kai_log_triage: compiler/test failure categorization & span pinpointing - kai_recover: failure loop breaker & recovery strategy selection - kai_extract: typed discrete dimension extraction - kai_decide: multi-question joint forward pass decisions - Add 15 runnable cookbook recipes in cookbook/ with helper & index runners - Add test suites: test/tools/kai-purpose-built.test.ts (18/18) & test/cookbook.test.ts (15/15) - Support Claude Code CLI transport flags (--allow-path, allowUnknownOption) - Add comprehensive cookbook documentation and client configuration guides
27 lines
1.2 KiB
TypeScript
27 lines
1.2 KiB
TypeScript
// Starts @hanzo/mcp over stdio as an MCP client does, lists its kai tools and calls kai_choice once.
|
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
|
|
const [command, ...args] = (process.env.MCP_SERVER ?? "npx -y @hanzo/mcp serve").split(" ");
|
|
const transport = new StdioClientTransport({ command, args, env: { ...process.env, HANZO_API_KEY: process.env.HANZO_API_KEY ?? "" } as Record<string, string> });
|
|
const client = new Client({ name: "kai-docs", version: "1.0.0" });
|
|
await client.connect(transport);
|
|
|
|
const { tools } = await client.listTools();
|
|
console.log(tools.map((tool) => tool.name).filter((name) => name.startsWith("kai_")).join(", "));
|
|
|
|
const result = await client.callTool({
|
|
name: "kai_choice",
|
|
arguments: {
|
|
state: "I was charged twice for my March invoice and the second charge is still pending.",
|
|
instructions: "Which team should handle this ticket?",
|
|
criteria: {
|
|
billing: "charges, invoices and refunds",
|
|
technical: "bugs, errors and outages",
|
|
account: "logins and profiles",
|
|
},
|
|
},
|
|
});
|
|
console.log((result.content as { type: string; text: string }[])[0].text);
|
|
await client.close();
|