kit library
What every flutter3d MCP server shares.
One arrangement, written once. The level editor's, the modeller's, the
renderer's and the simulation's servers each wrote the same forty lines —
a pair of a tool and its handler, a loop registering them, a function
turning an answer into a result — with four names for the pair, two shapes
of answer both called Answer, and a loopback transport only one of them
had. They differ in what their tools do; everything here is what they are.
Classes
- Answer
- What a tool call actually did, and the sentence to say about it.
-
AnsweredCall<
A> - One call a ToolTableServer answered, as a watcher is told of it: ToolTableServer.onCall with the server's own answer type, ToolTableServer.onProjectCall with a project tool's ToolResult.
- LoopbackMcpServer
-
A server listening on
127.0.0.1. - 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.
- OfferedPrompt
-
One prompt: what
prompts/listoffers, and the textprompts/gethands back —ux-44. -
OfferedTool<
S, A> - One tool: what an agent is offered, and what calling it does to the session.
- ProjectMcpServer
- A server offering a project's McpTools and nothing else.
- ProjectRoot
- The directory a server's file tools are held to, and the one place a path an agent sent becomes a path on the disk.
- ProjectTool
- One tool a plugin, or the application, added to a project's McpTools.
- ResolvedPath
- What ProjectRoot.tryResolve answers: the resolved path inside the root, or the sentence that refuses it. Exactly one of the two is set.
-
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.
- ToolName
-
The name a tool is published under,
area.verb, and what it does to the world it is called on. - 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).
- ToolResourceLink
- 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/listoffers it: a name, a sentence, the JSON Schema of its arguments, the JSON Schema of thestructuredContentit answers with when it answers one, and its ToolHints. -
ToolTableServer<
S, A> - A server offering tools over one session, every answer turned into a result by toResult.
- ToolText
- Words a tool answers with.
Constants
- projectMcpSchemaVersion → const String
- The version of ProjectMcpServer's own tools, of which there are none.
- projectMcpVersion → const String
- The version ProjectMcpServer tells a client it is: the pubspec's.
- schemaToolName → const String
- The name of the tool every server offers to say what schema versions it speaks.
- schemaVersionMetaKey → const String
-
The
_metakey a server's tools, and itsinitializeresult, carry their schema version under.
Functions
-
deleteMcpSessionFile(
File file) → void - Removes the session file writeMcpSessionFile wrote — called once the server it named is no longer listening, so nothing reads a port that has gone stale.
-
pictureResultOf(
Answer answer) → ToolResult -
answeras a tool result: the sentence, then the PNG when there is one. -
refuseArguments(
ToolSpec tool, Map< String, Object?> arguments) → String? -
Why
argumentsare not a call totool, or null when they are. -
resultOf(
Answer answer) → ToolResult -
answeras a tool result: the sentence, marked as an error when it is a refusal. -
writeMcpSessionFile(
File file, {required int port, required String token}) → void - Where an application's own running LoopbackMcpServer can be found, written beside the application's existing session state.
Typedefs
-
ProjectToolRun
= FutureOr<
ToolResult> Function(ToolCall call) - What calling a project tool does: one ToolCall in, a result out.
Exceptions / Errors
- PathOutsideRootException
- A path a file tool was handed that lies outside its ProjectRoot.