AI code blocks
AI code blocks let you write natural-language prompts directly in your note. Use ```ai as the block language to send a prompt to the AI — you explicitly control what context it receives by referencing named blocks, local files, or calling tools.
| Parameter | Purpose |
|---|---|
tools= | Expose tools the AI can call — JavaScript functions or MCP servers |
@blockName | Inject the content of a named block into the prompt |
@file:// | Attach a local file (text or image) |
websearch=true | Force a web fetch |
Call tools
The tools= parameter exposes one or more JavaScript functions to the AI, allowing it to call them to answer your prompt.
Call a custom function defined in the note:
```js global;
function getWeather(location) {
return fetch(`https://wttr.in/${location}?format=3`).then(r => r.text());
}
```
```ai tools=getWeather;
What is the weather in Paris and in New York?
```The AI calls getWeather with the appropriate arguments and formats the results.
Call multiple tools at once:
```ai tools=getJiraIssue,searchJiraIssuesUsingJql,getVisibleJiraProjects;
Show me the details of ticket PROJ-83 and list all open issues created this week in the same project
```You can also use dedicated blocks per intent:
```ai tools=searchJiraIssuesUsingJql;
List all open issues assigned to me in the PROJ project
```INFO
Functions must be defined in a global block within the same note, or provided by a Znote integration.
Call MCP server tools:
The same tools= parameter accepts MCP servers declared in your vault — tools=github exposes all the server's tools, tools=github.search_issues a single one, and you can mix servers with your own functions:
```ai tools=github,getWeather;
List my open PRs on acme/webapp and tell me if the weather in Paris allows a rooftop review session.
```The AI's answer is persisted below the block as rendered markdown.
Reference a named block
Name any block using blockName=, then inject its content into a prompt with @blockName.
Step 1 — Name the block:
```txt blockName=story;
#### Summary
User profile page — display format update
#### Description
Update the user profile page to reflect the new display rules:
- First name / Last name formatting
- Required supporting documents
```Step 2 — Reference it in an AI block:
```ai
Create this user story in the PROJ Jira project: @story
```The full content of story is injected into the prompt automatically.
Attach a local file
Use @file:// to include the content of a local file — works with text documents and images.
Attach a text document:
```ai
Generate acceptance criteria based on this specification: @file:///Users/tony/Documents/feature-spec.md
```Attach an image:
```ai
Describe what you see in this screenshot and identify any UI issues:
@file:///Users/tony/Desktop/app-screenshot.png
```TIP
Copy a file path from Finder with Right-click → Copy as Pathname and paste it directly into the block.
Web search
Add websearch=true to force a web fetch, or let Znote auto-detect search intent from your prompt keywords.
Explicit search
```ai websearch=true;
Visit https://znote.io and extract all page titles
```Auto-detected search intent
The AI block automatically detects search intent when the prompt contains one of the following keywords:
| Keyword | Example |
|---|---|
search for | Search for the latest JS frameworks |
find information | Find information about WebAssembly |
look up | Look up WWDC 2025 announcements |
visit | Visit the official React docs |
what is the latest | What is the latest version of Node.js? |
who is | Who is the creator of Linux? |
what is | What is a zero-knowledge proof? |
how to | How to center a div in CSS |
explain | Explain the CAP theorem |
tell me about | Tell me about the new Claude models |
recherche | Recherche les dernières nouveautés Swift |
cherche | Cherche des exemples de Rust async |
trouve | Trouve des alternatives à Figma |
dernières nouvelles | Dernières nouvelles sur l'IA générative |
