Skip to main content
Glama
adding-imports.md675 B
## Adding Imports If your macro generates code that requires imports, use the `add_import` method on `TsStream`: Rust ``` // Add an import to be inserted at the top of the file let mut output = body! {     validate(): ValidationResult {         return validateFields(this);     } }; // This will add: import { validateFields, ValidationResult } from "my-validation-lib"; output.add_import("validateFields", "my-validation-lib"); output.add_import("ValidationResult", "my-validation-lib"); Ok(output) ``` Note Imports are automatically deduplicated. If the same import already exists in the file, it won't be added again.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/macroforge-ts/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server