Skip to content

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.

ParameterPurpose
tools=Expose tools the AI can call — JavaScript functions or MCP servers
@blockNameInject the content of a named block into the prompt
@file://Attach a local file (text or image)
websearch=trueForce 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:

md
```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:

md
```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:

md
```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:

md
```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:

md
```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:

md
```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:

md
```ai
Generate acceptance criteria based on this specification: @file:///Users/tony/Documents/feature-spec.md
```

Attach an image:

md
```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.

Add websearch=true to force a web fetch, or let Znote auto-detect search intent from your prompt keywords.

md
```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:

KeywordExample
search forSearch for the latest JS frameworks
find informationFind information about WebAssembly
look upLook up WWDC 2025 announcements
visitVisit the official React docs
what is the latestWhat is the latest version of Node.js?
who isWho is the creator of Linux?
what isWhat is a zero-knowledge proof?
how toHow to center a div in CSS
explainExplain the CAP theorem
tell me aboutTell me about the new Claude models
rechercheRecherche les dernières nouveautés Swift
chercheCherche des exemples de Rust async
trouveTrouve des alternatives à Figma
dernières nouvellesDernières nouvelles sur l'IA générative

Znote — your notes, your files, your machine.