Lines 1-30javascript
5 * Filesystem-style tools for agents to read/write/edit frames on the canvas.
6 * Calls the Drafted HTTP API directly (no CLI subprocess).
9import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
10import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
11import { execFile } from 'child_process';
12import { createHash } from 'node:crypto';
HighChild Process
Package source references child process execution.
mcp/server.mjsView on unpkg · L10 13import { readFileSync, existsSync, realpathSync, writeFileSync, mkdirSync, unlinkSync, appendFileSync, readdirSync, statSync } from 'fs';
14import { join, dirname, basename, extname, resolve } from 'path';
15import { homedir, platform, release as osRelease, arch as osArch } from 'os';
16import { fileURLToPath } from 'url';
17import { AsyncLocalStorage } from 'node:async_hooks';
18import { z } from 'zod';
19import { registerAppResource, RESOURCE_MIME_TYPE } from '@modelcontextprotocol/ext-apps/server';
20import WebSocket from 'ws';
21import { LAYERS } from '../src/shared/constants.mjs';
22import { emptyExcalidrawScene, excalidrawSceneFromMermaid, stringifyExcalidrawScene } from '../src/shared/excalidraw.mjs';
23import { createGateState, markSearched, g1Block, g2Block, g3Block, selectWithinBudget, wouldExceedBudget, budgetError, formatWikiIndex, PROJECT_CONTEXT_BUDGET_CHARS } from './gates.mjs';
24import { loadPersistedProject, savePersistedProject } from './active-project-store.mjs';
26// Frame actions that mutate content — gated by G1 (wiki search before editing).
27// Read-style actions (read, search, versions, get_*/read_*) are exempt.
28const G1_MUTATING_FRAME_ACTIONS = new Set([
29 'write', 'write_excalidraw', 'edit', 'mv', 'anchor', 'restore_version',
30 'write_sheet_values', 'append_sheet_rows', 'clear_sheet_range', 'update_sheet',