A tiny Mirror extension that gives the
agent a callable word_count tool. No MCP server, API keys, network requests,
or changes to Mirror itself. The implementation is entirely in
extension.py.
Tested with the public reflection-mirror==0.1.0 package and Python 3.12.
Install Mirror using uv:
uv tool install reflection-mirror
mirrorReview this repository's code, then enter this command inside Mirror:
/extensions-add https://github.com/reflection-oss/mirror-example-tool-extension
Mirror downloads the repository and asks for consent. Select Enable.
Use /extensions to check or toggle enablement, /extensions-update to update,
and /extensions-remove to remove the source. Git must be installed. Updates
are explicit; Mirror does not install extension dependencies automatically.
Trust boundary: extensions execute unsandboxed Python locally with your account's filesystem, network, and credential access. Only enable reviewed code you trust. This particular tool only processes the supplied text.
Ask Mirror:
Use the word_count tool to count "Hello, Mirror!".
The model-facing tool is mirror-example-tool-extension__word_count:
{"text": "Hello, Mirror!"}Result:
{"words": 2, "characters": 14}Words are separated by whitespace; characters are Unicode code points, not bytes or displayed grapheme clusters. Input is limited to 10,000 characters.
ToolExtension.tools(context)returns objects implementingHostTool.ToolDefinitionsupplies the local name, description, and JSON Schema.async execute(arguments, context)receives JSON text and returns aToolResult(content=..., success=...). Validate arguments in the handler too.- Mirror prefixes tool names with
<extension-id>__; do not add that prefix yourself. Keepextension.pyat the repository root andid()equal to the lowercase repository name. Change the ID when copying this example to a new repo. - This pure computation sets
needs_approval=False. Keep the defaultTruefor tools that need per-call approval; extension consent is separate.
To wrap your preferred external service, replace the counting logic with an
async request and adapt the schema/result. Use bounded timeouts, preserve
asyncio.CancelledError, and keep secrets out of arguments, descriptions,
results, and logs. Any data sent to the service leaves your machine. No external
service integration or automatic fallback is implemented here.
See Mirror's extension guide.
Copyright 2026 Reflection AI. Apache-2.0, like Mirror.