Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk5 min

How to Design an AI Assistant Plugin System with ES Modules

ES modules can package assistant tools cleanly, but discovery, schemas, permissions and error handling remain host responsibilities. Learn when local modules fit and when to add a service boundary.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ES modules can make a clean foundation for an AI assistant’s tools, but importing a file is not a complete plugin system. The host still needs a contract for discovery, input validation, execution, permissions and errors. Keep tools as local modules when code and deployment are trusted and controlled together; use a service boundary when authentication, independent updates, controlled access or operational visibility matter.

What “every tool is an ES module” does—and does not—mean

Node.js describes ECMAScript modules as the official standard format for packaging JavaScript code for reuse. A host can use modules to separate tools into files and load their exported functions. Node supports ES modules through markers such as the .mjs extension or "type": "module" in a package configuration, and it also supports interoperability with CommonJS. Node.js documentation: ECMAScript modules

As an Amazon Associate I earn from qualifying purchases.

That solves code packaging and loading, not the assistant-specific questions. Node does not define how an assistant advertises tools to a model, checks arguments, supplies context, handles initialization failures or limits a tool’s permissions. Those are responsibilities of the host’s plugin contract and runtime.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Define a small, explicit tool contract

A practical starting design is for each module to export a description, an input schema and an execute function. This is a proposed contract, not a feature imposed by Node.js. A registry can associate each tool’s name with its validated metadata and callable function.

Before execution, the host should discover only modules it intends to load, check that each module exports the required fields, and reject malformed definitions. When a model requests a tool, validate its arguments against that tool’s schema before calling it. Pass only the context the tool needs, validate or normalize the result, and convert failures into a controlled response the assistant can handle. Keep initialization errors distinct from errors during a particular call so one broken module does not silently appear to be a successful tool.

Node’s module-resolution details matter when building such a loader: relative and absolute import specifiers require explicit file extensions, including directory index files. Node resolves and caches ES modules as URLs, so code that constructs file URLs from filesystem paths must convert them carefully. Dynamic import() works in both ESM and CommonJS contexts, but CommonJS named-export detection is heuristic; test interoperability against the actual packages the assistant supports. Node.js ECMAScript modules documentation

Choose local modules or a service boundary

Local modules are a good fit when the assistant’s team controls the code, tools ship with the assistant, and in-process execution matches the trust model. A server-backed tool is more suitable when an integration needs its own authentication, permission checks, deployment cadence or operational monitoring.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Design question Local ES modules Service-backed tools
Trust and isolation Appropriate for trusted code running under the host’s process and permission model. Creates a service boundary, but still requires careful authentication and authorization.
Deployment and updates Usually released with the assistant or its package. Behavior can be updated independently of the assistant.
Discovery The host can use a static registry or manifest. A service protocol can support runtime discovery, depending on the platform.
Input and output The host must define and enforce exported-function conventions and schemas. Protocols such as MCP define tools, input/output schemas and structured results.
Authentication and authorization The host decides what context and capabilities to pass. The service can define authentication and authorization requirements for external systems.
Operations Failures are handled within the host’s runtime and release process. The operator must account for network availability and service ownership; infrastructure requests can be observed.

These are trade-offs, not a rule that every tool belongs on a server. OpenAI’s plugin documentation describes packages that may contain skills, an MCP server exposing tools and connecting to external systems, both, and optional lifecycle hooks; it recommends starting with the smallest shape that serves the use case. An MCP server can define tool schemas, authentication and authorization requirements, and structured results, while allowing an operator to update behavior independently and observe requests to its infrastructure. OpenAI Developers: Plugin architecture

Make discovery and user consent explicit

Tool discovery can be fixed at startup or resolved dynamically. A fixed registry is easier to reason about when the host controls the available modules. Runtime discovery can help when tools change independently, but it makes the source of tool definitions and the timing of changes part of the design.

Microsoft documents both patterns in its Copilot platform: MCP plugins can resolve tool definitions dynamically at runtime, while developers can pin a fixed tool set in a manifest; REST API plugins use manifest-defined tools. Its described invocation flow includes data-sharing confirmation, credentials when required, a call to a service hosted outside Microsoft 365, and a response returned to the agent. These are Microsoft platform behaviors, not universal properties of MCP or all assistant systems. Microsoft Learn: MCP and API plugins for declarative agents

For any assistant, decide who may install or update a tool, when its definition becomes available to the model, and whether the user must approve access or data sharing. A module being present in a registry should not, by itself, mean every user or every conversation is authorized to invoke it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Do not treat module loading as a security sandbox

import() loads code; it does not isolate it. A plugin running in the host’s privileged process may be able to use the APIs available to that process. If tools are not equally trusted, the host needs an intentional permission and isolation strategy rather than relying on the module boundary.

  • Restrict which files can be installed or loaded, for example with an allowlist or a bundled registry.
  • Decide explicitly whether tools can access files, networks, credentials or process APIs.
  • Pass narrow capabilities rather than a broad host object when a tool needs only a specific operation.
  • For untrusted code, evaluate process, worker or container isolation appropriate to the threat model.
  • Review who can distribute updates and how those updates are approved.

A 2024 paper examining access-control vulnerabilities in plugin development discusses capability-based systems as one mitigation, while noting that managing and controlling capabilities becomes complex in larger ecosystems. Capability design can help constrain access, but it is not a substitute for deciding who receives capabilities and how they are governed. Evaluating the Language-Based Security for Plugin Development (2024)

A practical decision rule

Start with local ES modules when tools are trusted, shipped alongside the assistant and do not need independent operation. Add a service boundary when an integration needs separately managed credentials, explicit external-system authorization, independent updates or request observability. In either architecture, the assistant still needs a defined contract, validated arguments and results, deliberate user authorization, and a failure path the model can understand.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.