tools library

What a plugin hands an agent, without depending on a server: the tools it adds to a project's MCP servers, and what calling one is.

A game's plugin should not need the agent servers to bring tools. A plugin is a dependency of a game, and the servers (flutter3d_mcp, with the editor, the modeller and a pre-1.0 MCP library under it) are not. So the slot a plugin fills, McpTools, and the values a tool is made of, ToolSpec, ToolCall and ToolResult, live here over the plugin API alone, as the editor's hints do in editor.dart:

void install(PluginHost host) {
  host.maybeRegistry<McpTools>()?.addTool(
    const ToolSpec(
      name: 'gust',
      description: 'Blow once, as hard as asked.',
      inputSchema: {'type': 'object'},
    ),
    (ToolCall call) => ToolResult.text('blew'),
  );
}

An engine with no server simply has no McpTools among its registries. The servers hand theirs to the plugin host and offer what the plugins added; flutter3d_mcp's kit.dart and project_tools.dart re-export this library, so a type is the same whichever import named it.

Classes

McpToolRegistry
MCP tools, merged into the project's servers as <namespace>.<tool>: the slot McpTools fills, host.registry<McpTools>().
McpTools
The McpToolRegistry a project fills: the MCP tools its plugins bring, each under the plugin's namespace.
ProjectTool
One tool a plugin, or the application, added to a project's McpTools.
SessionToolCall<S>
One call of a server's own tool: a ToolCall with the session the server runs it against.
ToolAudio
A sound a tool answers with: the encoded bytes and their media type (audio/wav, audio/ogg).
ToolCall
One call of a project tool: what an agent passed, under the name it called.
ToolContent
One piece of what a tool answers: words, a picture, a sound, a resource or a link to one, as the protocol's content objects say them.
ToolHints
What a tool does to the world it is called on, as the protocol's annotations say it to a host — which may ask a person before a destructive call, and may call a read-only one without asking.
ToolImage
A picture a tool answers with: the encoded bytes and their media type.
ToolOtherContent
Content of a kind this build has no class for, kept as the JSON it came as and written back unchanged.
ToolResource
A resource carried inside the answer: its uri, and its contents as text or as bytes (blob).
A link to a resource the client may read, rather than its contents.
ToolResult
What a tool call answers: content for a model to read, and the machine-readable structuredContent when the tool declares an outputSchema.
ToolSpec
One tool, as tools/list offers it: a name, a sentence, the JSON Schema of its arguments, the JSON Schema of the structuredContent it answers with when it answers one, and its ToolHints.
ToolText
Words a tool answers with.

Typedefs

ProjectToolRun = FutureOr<ToolResult> Function(ToolCall call)
What calling a project tool does: one ToolCall in, a result out.