obsidian_eval
Executes custom JavaScript in Obsidian with full API access to handle complex queries and automation workflows beyond built-in tools.
Instructions
Execute JavaScript code in Obsidian with full API access.
WHEN TO USE:
Operations not covered by other tools
Complex queries combining multiple APIs
Custom automation workflows
COMMON PATTERNS:
Get active file: app.workspace.getActiveFile()
Read file: await app.vault.read(file)
Modify file: await app.vault.modify(file, content)
Get metadata: app.metadataCache.getFileCache(file)
Execute command: app.commands.executeCommandById('cmd-id')
Access plugin: app.plugins.plugins['plugin-id']
NOTE: Code runs in Obsidian's context. Use 'return' for values. Promises are auto-awaited.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "obsidian_eval"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript code to execute. Use `app` to access Obsidian API. | |
| await_promise | No | Wait for promise to resolve if code returns a promise (default: true) |