lietzsche;noether
Pages

updated 2026-11-26·4 min read

Model Context Protocol (MCP) Runtime

Architectural overview of Noether's standalone stdio MCP server, automatic local vault discovery, extension tool registration, script execution, and structured prompts.

Noether embeds a standalone stdio Model Context Protocol (MCP) server (bin/noether-mcp-server.cjs) so external AI clients can search notes, inspect backlinks, run sandboxed vm.Script snippets, and execute custom vault tools against your local vault without uploading files to a cloud proxy.

1. Local Stdio Server Architecture

bin/noether-mcp-server.cjs speaks JSON-RPC 2.0 over standard input/output (stdio):

┌─────────────────────────────────────────────────────────────┐
│                 AI Assistants / External Clients            │
│  Claude Desktop • Claude Code • Cursor • Codex • Antigravity│
└──────────────────────────────┬──────────────────────────────┘
                               │ JSON-RPC 2.0 over stdio
                               ▼
┌─────────────────────────────────────────────────────────────┐
│                 Noether MCP Server Runner                   │
│   • Auto-discovers local Vaults • Validates Parameters      │
│   • Routes Tool Invocations     • Runs vm.Script Snippets   │
│   • Dynamic Tools Notification  • Loads .noether/tools/*.js │
└──────────────────────────────┬──────────────────────────────┘
                               │ Local Disk & Config Reads
                               ▼
┌─────────────────────────────────────────────────────────────┐
│                       Target Vault                          │
│   • Plain text Markdown documents (*.md)                    │
│   • Dynamic custom tools (.noether/tools/*.js)              │
└─────────────────────────────────────────────────────────────┘

External AI agents can search notes, edit Markdown files, inspect tags and tasks, and switch vaults locally without a cloud relay.

2. Automatic Vault Auto-Discovery

Hardcoding absolute vault paths into every MCP client config gets annoying fast, so noether-mcp-server.cjs reads Noether’s config.json directly:

  1. On startup, the server checks the OS application config directory where Noether stores config.json.
  2. It reads the active vault path and recentVaults list automatically.
  3. If you keep multiple vaults, clients can call noether_list_vaults and noether_switch_vault over MCP without restarting the server.

3. Extension Tool Registration via SDK

Inside the running desktop app, every extension can expose structured tools to in-app AI features using this.registerTool() (validated via Zod or JSON Schema on app.tools):

import { Extension, z } from 'noether';

export default class TaskExtension extends Extension {
  async onload(): Promise<void> {
    this.registerTool({
      name: 'get_pending_tasks',
      description: 'Returns all pending tasks across the current vault.',
      schema: z.object({
        tag: z.string().optional().describe('Optional tag filter (e.g. #urgent)'),
      }),
      isDestructive: false,
      handler: async ({ tag }, app) => {
        const tasks = await this.queryTasks(tag);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(tasks),
            },
          ],
        };
      },
    });
  }
}
  • Prefixing: Tool names are automatically prefixed with the extension ID (e.g. tasks_get_pending_tasks) to prevent name collisions across extensions.
  • Safety Flags: Destructive actions (deleting notes, clearing tables) should set isDestructive: true to signal client-side confirmations.
  • In-Memory Execution: In-app NativeMcpTools and extension handlers query app.vault.documents and SQLite caches rather than blocking the UI thread with synchronous disk reads.

4. Script Execution & Custom Vault Tools

Agents can either run one-off JavaScript via noether_run_script or save reusable tools via noether_create_custom_tool:

  • Ad-Hoc Scripts (noether_run_script): Executes code inside a Node.js vm.Script context (vm.createContext) exposing vault, console, path, Buffer, args, context, and frontmatter helpers with a default 30-second timeout.
  • Persistent Custom Tools (.noether/tools/<name>.js): Saved on disk inside the vault. On creation, noether-mcp-server.cjs syntax-checks the generated module with new vm.Script(...) and writes it to .noether/tools/. At runtime, the server loads it via Node’s require() (clearing require.cache on reload) and invokes mod.handler(toolArgs, context) directly inside the MCP server process.
  • Dynamic Hot-Reloading: Creating or deleting a custom tool emits a notifications/tools/list_changed JSON-RPC notification so connected MCP clients refresh their tool list.

5. Structured MCP Prompts

The standalone stdio server (bin/noether-mcp-server.cjs) serves the noether_system_instructions prompt (prompts/list, prompts/get), emitting Noether’s domain conventions for Wikilinks, FSRS flashcards, checklist tasks, and Cascade frontmatter.

Inside the desktop app, NativeMcpTools additionally registers noether_daily_review (daily journal and workspace summary) and noether_synthesize_topic (matching notes and wikilinks for a given topic).

See the MCP Setup Guide for client configuration details and the full tool catalog.

Search wiki and portfolio

type to search across all entries.