@pairdraw/mcp 0.20.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { l as fail, n as startServer, o as MCP_AGENT_KINDS, s as registerTools, t as MCP_VERSION, u as ok } from "./server-DFcHV3WL.mjs";
1
+ import { l as fail, n as startServer, o as MCP_AGENT_KINDS, s as registerTools, t as MCP_VERSION, u as ok } from "./server-C2X4PLPJ.mjs";
2
2
  export { MCP_AGENT_KINDS, MCP_VERSION, fail, ok, registerTools, startServer };
package/dist/stdio.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import "./rolldown-runtime-ClRpJifh.mjs";
3
- import { c as registerSkill, r as createServerInstructions, s as registerTools, t as MCP_VERSION } from "./server-DFcHV3WL.mjs";
3
+ import { c as registerSkill, r as createServerInstructions, s as registerTools, t as MCP_VERSION } from "./server-C2X4PLPJ.mjs";
4
4
  import { a as getSocketPath, o as platformHasUnixSockets } from "./paths-BpcXnrbP.mjs";
5
5
  import { t as resolveMCPRoot } from "./root-BzmoiT2g.mjs";
6
- import { r as parseDisabledTools } from "./policy-CvOZJ5BB.mjs";
7
- import { a as narrowestScope, o as parseToolScope } from "./scope-CMRgfS0_.mjs";
8
- import { n as readDiscoveryFile } from "./discovery-7pdSXC8x.mjs";
6
+ import { r as parseDisabledTools } from "./policy-CVfvvMB7.mjs";
7
+ import { a as narrowestScope, o as parseToolScope } from "./scope-2c_X9Kl3.mjs";
8
+ import { n as readDiscoveryFile } from "./discovery-BIJ7923d.mjs";
9
9
  import { randomUUID } from "node:crypto";
10
10
  import { McpServer } from "@modelcontextprotocol/server";
11
11
  import { request } from "node:http";
package/dist/tools.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./rolldown-runtime-ClRpJifh.mjs";
2
- import { a as serializeDisabledTools, n as isToolEnabled, o as createToolDescriptors } from "./policy-CvOZJ5BB.mjs";
3
- import { a as narrowestScope, i as isSelectionScopeTool, n as SELECTION_SCOPE_FILE_OUTPUT_ERROR, o as parseToolScope, r as SELECTION_SCOPE_TOOLS, t as MCP_TOOL_SCOPES } from "./scope-CMRgfS0_.mjs";
2
+ import { a as serializeDisabledTools, n as isToolEnabled, o as createToolDescriptors } from "./policy-CVfvvMB7.mjs";
3
+ import { a as narrowestScope, i as isSelectionScopeTool, n as SELECTION_SCOPE_FILE_OUTPUT_ERROR, o as parseToolScope, r as SELECTION_SCOPE_TOOLS, t as MCP_TOOL_SCOPES } from "./scope-2c_X9Kl3.mjs";
4
4
  import * as v from "valibot";
5
5
  const toolDescriptorSchema = v.object({
6
6
  name: v.pipe(v.string(), v.minLength(1)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pairdraw/mcp",
3
- "version": "0.20.0",
3
+ "version": "0.21.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",
@@ -15,7 +15,7 @@
15
15
  "dependencies": {
16
16
  "@hono/node-server": "^1.19.17",
17
17
  "@modelcontextprotocol/server": "^2.0.0",
18
- "@pairdraw/core": "^0.20.0",
18
+ "@pairdraw/core": "^0.21.1",
19
19
  "@valibot/to-json-schema": "^1.8.0",
20
20
  "es-toolkit": "^1.52.0",
21
21
  "hono": "^4.13.13",
package/src/tool/scope.ts CHANGED
@@ -12,6 +12,7 @@ export type MCPToolScope = (typeof MCP_TOOL_SCOPES)[number]
12
12
  export const SELECTION_SCOPE_TOOLS: Readonly<Record<string, readonly string[]>> = {
13
13
  get_selection: [],
14
14
  get_node: ['id'],
15
+ get_css: ['id', 'ids'],
15
16
  get_page_tree: ['root_id'],
16
17
  describe: ['id', 'ids'],
17
18
  export_image: ['ids']
@@ -1 +0,0 @@
1
- {"version":3,"file":"scope-CMRgfS0_.mjs","names":[],"sources":["../src/tool/scope.ts"],"sourcesContent":["import type { RPCJSONObject } from '#mcp/json'\n\n/**\n * What MCP clients can reach: the whole document, or only the layers the user selected. In\n * selection scope the server exposes these read tools, stamps every call it sends to the app with\n * the scope, and the app rejects node IDs outside the selected layers and their descendants.\n */\nexport const MCP_TOOL_SCOPES = ['document', 'selection'] as const\nexport type MCPToolScope = (typeof MCP_TOOL_SCOPES)[number]\n\n/** The tools selection scope keeps, each with the arguments that name the nodes it reads. */\nexport const SELECTION_SCOPE_TOOLS: Readonly<Record<string, readonly string[]>> = {\n get_selection: [],\n get_node: ['id'],\n get_page_tree: ['root_id'],\n describe: ['id', 'ids'],\n export_image: ['ids']\n}\n\nexport function isSelectionScopeTool(name: string): boolean {\n return Object.hasOwn(SELECTION_SCOPE_TOOLS, name)\n}\n\nexport function parseToolScope(value: string | undefined): MCPToolScope {\n const scope = value?.trim() || 'document'\n if (scope === 'document' || scope === 'selection') return scope\n throw new Error('PAIRDRAW_MCP_SCOPE must be \"document\" or \"selection\"')\n}\n\n/** The narrower of the scopes, so a client never offers more than the server it talks to. */\nexport function narrowestScope(...scopes: MCPToolScope[]): MCPToolScope {\n return scopes.includes('selection') ? 'selection' : 'document'\n}\n\n/** Why a selection-scoped call cannot write files, such as an export with a `path`. */\nexport const SELECTION_SCOPE_FILE_OUTPUT_ERROR =\n 'Writing files is unavailable while Pairdraw shares only the selection; omit path'\n\n/** Commands the app may receive in selection scope besides calls of the tools above. */\nconst SELECTION_SCOPE_COMMANDS: ReadonlySet<string> = new Set(['agent_session_closed'])\n\ntype RPCSend = (msg: RPCJSONObject, signal?: AbortSignal) => Promise<unknown>\n\nfunction toolName(msg: RPCJSONObject): string | null {\n const args = msg.args\n if (!args || typeof args !== 'object' || Array.isArray(args)) return null\n const name = Reflect.get(args, 'name')\n return typeof name === 'string' ? name : null\n}\n\n/**\n * Sends to the app within the scope: in selection scope, only the selection tools and session\n * notices go through, each tool call carrying the scope however the client called it, so neither\n * `/rpc` nor a stale client can reach the rest of the document or the settings.\n */\nexport function scopeRPC(send: RPCSend, scope: MCPToolScope): RPCSend {\n if (scope === 'document') return send\n return async (msg, signal) => {\n const command = typeof msg.command === 'string' ? msg.command : ''\n if (SELECTION_SCOPE_COMMANDS.has(command)) return send(msg, signal)\n const name = command === 'tool' ? toolName(msg) : null\n if (!name || !isSelectionScopeTool(name)) {\n return {\n ok: false,\n error: `${name ?? command} is unavailable while Pairdraw shares only the selection with MCP clients`\n }\n }\n const args = msg.args as RPCJSONObject\n return send({ ...msg, args: { ...args, scope } }, signal)\n }\n}\n"],"mappings":";;;;;;AAOA,MAAa,kBAAkB,CAAC,YAAY,WAAW;;AAIvD,MAAa,wBAAqE;CAChF,eAAe,CAAC;CAChB,UAAU,CAAC,IAAI;CACf,eAAe,CAAC,SAAS;CACzB,UAAU,CAAC,MAAM,KAAK;CACtB,cAAc,CAAC,KAAK;AACtB;AAEA,SAAgB,qBAAqB,MAAuB;CAC1D,OAAO,OAAO,OAAO,uBAAuB,IAAI;AAClD;AAEA,SAAgB,eAAe,OAAyC;CACtE,MAAM,QAAQ,OAAO,KAAK,KAAK;CAC/B,IAAI,UAAU,cAAc,UAAU,aAAa,OAAO;CAC1D,MAAM,IAAI,MAAM,0DAAsD;AACxE;;AAGA,SAAgB,eAAe,GAAG,QAAsC;CACtE,OAAO,OAAO,SAAS,WAAW,IAAI,cAAc;AACtD;;AAGA,MAAa,oCACX;;AAGF,MAAM,2CAAgD,IAAI,IAAI,CAAC,sBAAsB,CAAC;AAItF,SAAS,SAAS,KAAmC;CACnD,MAAM,OAAO,IAAI;CACjB,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,GAAG,OAAO;CACrE,MAAM,OAAO,QAAQ,IAAI,MAAM,MAAM;CACrC,OAAO,OAAO,SAAS,WAAW,OAAO;AAC3C;;;;;;AAOA,SAAgB,SAAS,MAAe,OAA8B;CACpE,IAAI,UAAU,YAAY,OAAO;CACjC,OAAO,OAAO,KAAK,WAAW;EAC5B,MAAM,UAAU,OAAO,IAAI,YAAY,WAAW,IAAI,UAAU;EAChE,IAAI,yBAAyB,IAAI,OAAO,GAAG,OAAO,KAAK,KAAK,MAAM;EAClE,MAAM,OAAO,YAAY,SAAS,SAAS,GAAG,IAAI;EAClD,IAAI,CAAC,QAAQ,CAAC,qBAAqB,IAAI,GACrC,OAAO;GACL,IAAI;GACJ,OAAO,GAAG,QAAQ,QAAQ;EAC5B;EAEF,MAAM,OAAO,IAAI;EACjB,OAAO,KAAK;GAAE,GAAG;GAAK,MAAM;IAAE,GAAG;IAAM;GAAM;EAAE,GAAG,MAAM;CAC1D;AACF"}