Skip to content

Adding a Tool

Memet Zx edited this page Nov 14, 2026 · 1 revision

Adding a Tool

Adding a tool takes four small steps. Most tools are under 40 lines.

1. Register it

Add an entry to src/lib/tools.js:

{
    category: 'string',          // one of the ids in `categories`
    slug: 'my-tool',             // the URL: /string/my-tool/
    title: 'My Tool',
    sidebarName: 'My Tool',
    description: 'One sentence about what it does',
    icon: 'magic'                // a Bootstrap Icons name, without the "bi-" prefix
}

The sidebar, search, home page, llms.txt, tools.json and the sitemap pick it up automatically.

2. Put the logic in src/lib

Write a pure function and export it. Throw an Error with a friendly message for bad input.

export const reverseWords = (text) => text.split(/\s+/).reverse().join(' ');

3. Create the page

src/routes/string/my-tool/+page.svelte. For text in, text out, use ToolPage:

<script>
    import ToolPage from "../../../components/ToolPage.svelte";
    import { reverseWords } from "#lib/textUtils.js";

    let text = $state("");
    const actions = [{ label: "Reverse words", transform: reverseWords }];
</script>

<ToolPage title="My Tool" description="Reverse the order of words." bind:value={text} {actions} />

For a live preview on the right, use ConvertPage with a convert(text) function. For anything custom, write a normal page and reuse OutputCard, StatRows and ResultList.

4. Test it

Add a test next to the logic, for example in src/lib/textUtils.test.js, and run:

bun run test
bun run build

Optional: make it available to agents

Add an entry to src/lib/agentTools.js with a name, description, JSON Schema and run function. It is then exposed through WebMCP and the MCP server. See Agent Support.

Conventions

  • Tools must work without a server and never upload user input.
  • Keep secrets out of examples and outputs.
  • Support light and dark mode and phone-sized screens.
  • Commit messages are imperative ("Add CSS minifier tool") and signed off with git commit -s.

Clone this wiki locally