Repository navigation
Description
Problem
Tool is already rich enough to express an arbitrary tool: four required members and about fifteen optional ones with defaults, including output_schema(), default_exposure(), is_readonly(), permission_intents(), validate_input(), the three render_* methods and dynamic_tool_info() (src/crates/assembly/core/src/agentic/tools/framework.rs:19-227).
There is exactly one way to add a tool from outside the binary: MCP. register_mcp_tools() (tools/registry.rs:102) is the only bulk registration path besides a ToolRef from Rust. The bridge is written as if MCP were the whole problem rather than one case of it, since mcp_tool_bridge.rs hardcodes the prefix mcp__ (:5), the provider kind (:88), the description template (:70-80) and the rejection messages (:156-168). The data model below it is already generic: DynamicToolInfo keeps provider_kind as a plain String (tool-contracts/src/framework.rs:31-38), and dynamic_provider_id() documents keeping provider identity as metadata so that future registries can change naming without breaking provider routing.
The architecture anticipated other providers. What is missing is the provider. Users are left with #3822 point 8: 定义里没法声明自定义工具, 挂不了脚本 / HTTP / 组合工具, so an agent that needs something no tool does gets told to build it with ExecCommand, which is powerful, untyped, unaudited, and every call is a free-form shell string the model invented.
MCP is the wrong shape for most of these. It is a process protocol: a long-lived server, a JSON-RPC handshake, capability negotiation and a lifecycle somebody supervises. That fits sharing a service and it is disproportionate for "run this script and give me JSON". Concretely, a server is a process to supervise with its own restart story and status UI. It cannot travel with the workspace, so validate_mcp_tool_bridge_input (mcp_tool_bridge.rs:125-130) must reject the call with "MCP server '{}' runs locally and is unavailable in remote workspace sessions". And agentToolVisibility.ts:5 filters MCP tools out of per-agent selection, so a subagent can never be given one. A skill is not a substitute, since a skill injects instructions and cannot be typed, validated or tested without a model in the loop.
What I want
A declarative tool is the serializable projection of the Tool trait, not a second tool system. That framing is why this is cheap: every field maps onto a method that exists.
A toolset is a directory, because it carries its own scripts. Two locations, mirroring how agents are discovered: <appData>/openbitfun/tools/<toolset-id>/ for user level, and <workspace>/.openbitfun/tools/<toolset-id>/ for project level, which travels with the workspace and is therefore present in a remote workspace, a peer session and a dispatch job with no extra plumbing.
{
"schema": "openbitfun.toolset.v1",
"id": "todos",
"tools": [{
"name": "count_todos",
"description": "Count TODO comments under a directory. Returns the total and up to 20 locations.",
"input_schema": { "type": "object", "properties": { "path": { "type": "string" } }, "required": ["path"] },
"behavior": { "read_only": true, "exposure": "direct", "timeout_ms": 30000 },
"execution": { "kind": "process", "scope": "workspace",
"command": ["python", "${toolset_dir}/count_todos.py"], "stdin": "json",
"result_field": "result_for_assistant" }
}]
}Two execution backends, deliberately not three. process runs one process per call with JSON on stdin and JSON on stdout, no handshake and no lifecycle, and that absence is the entire reason to have this instead of MCP. http makes one request with a method, URL, headers and a choice of body or query.
Exit codes keep trivial scripts trivial. Exit 0 with JSON means success and that JSON is data. Exit 0 without JSON means success with data set to { "stdout": "<raw text>" }. A non-zero exit is failure and stderr becomes the error the model reads. A timeout is a failure reported with the exceeded timeout_ms. A one-line echo '{"count": 3}' is a valid tool.
I am not proposing a composite backend that chains tools. It would let a declaration express control flow, which is the brittle workflow engine AGENTS.md warns about. Composition belongs in the binary where it can be reviewed.
Every field lands on an existing member: names on name() and description(), schemas on input_schema() and output_schema(), read_only on is_readonly() and therefore on the default is_concurrency_safe(), exposure on default_exposure() where deferred keeps a large toolset out of the prompt until GetToolSpec asks, timeout_ms on manages_own_execution_timeout(), and the toolset id on dynamic_provider_id() with provider_kind: Some("declarative"). ToolResult::Result { data, result_for_assistant, image_attachments } (mcp_tool_bridge.rs:170-176) is already the output shape. result_field is optional sugar: when the JSON has that key the model reads that string and the rest is data, otherwise the whole JSON is rendered.
The namespace is tool__<toolset_id>__<tool_name>, reusing the normalization rules of build_mcp_tool_bridge_name (:21-29). It must not reuse mcp__, for two reasons. The UI branches on isMcpToolName in at least four places (tool-cards/index.ts:204, toolCardMetadata.ts:585, activity grouping, genUIMcpProvider) and a declarative tool has different provenance and a different failure surface. And declarative tools must stay selectable per agent, which MCP tools are not. Rendering falls back to the existing generic card with the toolset name in the label. A declaration may carry render.result as a template over data and may not carry code.
Remote scenarios must not be deferred, because the obvious implementation gets them wrong. A declaration states where it runs. "scope": "workspace" executes on the host that owns the workspace, so the remote host, the peer or the dispatch target, with the workspace root as working directory and ${toolset_dir} resolved there. "scope": "controller" executes on the client machine and is valid only for a local session. A controller-scoped tool called from a remote workspace session must be refused with a message naming the tool and the reason, following validate_mcp_tool_bridge_input, never a silent local fallback that runs the wrong command against the wrong filesystem. Workspace scope being achievable at all is the specific thing MCP cannot do.
Acceptance
- A toolset directory with
toolset.jsonand one script yields a callable tool with typed input and output. - A toolset in the workspace runs in a remote workspace session with its own scripts.
- A controller-scoped tool called from a remote workspace session fails loudly and names the tool.
- A toolset that fails to parse stays registered as broken with the error visible and its tools unadvertised. Deleting a declaration because one field is wrong would violate the upgrade-compatibility rule.
- Unknown fields are ignored, and an unrecognized major
schemaversion yields the broken state instead of a best-effort load. - Editing a declaration reloads at the next turn boundary, so a tool cannot change schema between the moment the model was told about it and the moment it is called.
Sources
tools/framework.rs:19-227, tools/registry.rs:102,475, mcp_tool_bridge.rs:5,21-29,70-88,125-130,156-176, tool-contracts/src/framework.rs:31-38, agentToolVisibility.ts:5, tool-cards/index.ts:204, toolCardMetadata.ts:585, and #3822 point 8. Reference: 0xfe-project/eta treats tools as registry entries rather than protocol servers and advertises the mounted set in its hello frame, which covers registration and not the declaration format. The in-repo precedent is #3947, since built-in capabilities that become disableable plugins need the same manifest shape.
Nothing here is implemented. The Tool members were read from source and no prototype bridge has been written or run.
Activity