MCPcopy Index your code
hub / github.com/cloudflare/agents / createStateToolProvider

Function createStateToolProvider

packages/shell/src/workers.ts:14–36  ·  view source on GitHub ↗

* Create state tools from a StateBackend.

(backend: StateBackend)

Source from the content-addressed store, hash-verified

12 * Create state tools from a StateBackend.
13 */
14function createStateToolProvider(backend: StateBackend): ToolProvider {
15 const tools: Record<
16 string,
17 { description: string; execute: (...args: unknown[]) => Promise<unknown> }
18 > = {};
19
20 for (const method of STATE_METHOD_NAMES) {
21 const fn = backend[method as StateMethodName];
22 if (typeof fn !== "function") continue;
23
24 tools[method] = {
25 description: `state.${method}`,
26 execute: (fn as (...args: unknown[]) => Promise<unknown>).bind(backend)
27 };
28 }
29
30 return {
31 name: "state",
32 tools,
33 types: STATE_TYPES,
34 positionalArgs: true
35 };
36}
37
38/**
39 * Creates a `ToolProvider` that exposes `state.*` inside any

Callers 2

stateToolsFunction · 0.85
stateToolsFromBackendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected