A chat model can ask for data that lives outside its conversation. A TypeScript plugin gives LM Studio a tool the model can call and sends the tool's result back to the chat.

A tools provider defines the arguments a model can send and the code that runs for each call. The market-hours provider uses a table of fictional closing times, so a lookup needs no external service.

Local development requires LM Studio desktop, its bundled lms command, and a chat with a tool-capable model such as Qwen2.5 1.5B Instruct. LM Studio provides the Node.js runtime for plugins.

Steps to create a plugin for LM Studio:

  1. Create manifest.json in a new project folder named market-hours.
    manifest.json
    {
      "type": "plugin",
      "runner": "node",
      "owner": "local",
      "name": "market-hours",
      "revision": 1
    }

    The manifest gives LM Studio the plugin's name and selects its Node.js runner.

  2. Create package.json beside manifest.json.
    package.json
    {
      "name": "lms-plugin-market-hours",
      "version": "1.0.0",
      "private": true,
      "dependencies": {
        "@lmstudio/sdk": "1.4.0",
        "zod": "3.24.1"
      }
    }

    The SDK supplies LM Studio's plugin and tool APIs. Zod limits the tool's input to the market names it can look up.

  3. Create src/toolsProvider.ts in the project folder.
    src/toolsProvider.ts
    import { tool } from "@lmstudio/sdk";
    import { z } from "zod";
     
    const hours = {
      harbor: "17:40 UTC",
      upland: "19:25 UTC",
    };
     
    export async function toolsProvider() {
      return [
        tool({
          name: "lookup_market_hours",
          description: "Return the closing time of a fictional market.",
          parameters: { market: z.enum(["harbor", "upland"]) },
          implementation: async ({ market }) => ({ market, closesAt: hours[market] }),
        }),
      ];
    }

    The market argument accepts harbor or upland. The implementation uses that argument as the lookup key and returns the market name with its closing time.

  4. Create src/index.ts to register the tools provider.
    src/index.ts
    import { type PluginContext } from "@lmstudio/sdk";
    import { toolsProvider } from "./toolsProvider";
     
    export async function main(context: PluginContext) {
      context.withToolsProvider(toolsProvider);
    }

    LM Studio calls main when the plugin starts. withToolsProvider makes the provider's tools available when the plugin is enabled in a chat.

  5. Run the development session from the market-hours folder with LM Studio open.
    lms dev

    lms dev installs dependencies, builds the plugin, and rebuilds it when files change. A completed build displays build finished and Register with LM Studio in the terminal. The plugin stays available while the command is running. LM Studio's CLI documentation labels the feature beta.

  6. Open Integrations with the hammer icon beside the chat message box.
  7. Enable local/market-hours with its switch in Integrations.

    The market-hours chip beside the model name shows that the development plugin is active for this chat.

  8. Enter Use lookup_market_hours for harbor. What is its closing time? in the message box.
  9. Send the message with the upward-arrow button.
  10. Check that the call requests lookup_market_hours from dev/local/market-hours with {"market":"harbor"} under Arguments.

    Proceed runs the plugin code for the displayed arguments. A different plugin, tool, or market is a reason to deny the request.

  11. Click Proceed once with both Always allow boxes clear.

    Future calls still require their own approval when both options stay clear.

  12. Expand the completed lookup_market_hours call in the chat.
  13. Expand Result beneath the call.
  14. Confirm that the model's reply reports the closing time displayed under Result.

    For harbor the tool returns "closesAt": "17:40 UTC". The reply can express that as 5:40 PM (UTC). A reply without the matching tool result does not show that the plugin ran.

Share this guide