@@ -4,7 +4,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
44import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" ;
55import * as z from "zod" ;
66import { loadDocument } from "../io.js" ;
7- import { RelationshipType } from "../schema.js" ;
7+ import { NodeType , RelationshipType } from "../schema.js" ;
88import {
99 validateOp ,
1010 statsOp ,
@@ -197,31 +197,11 @@ server.registerTool(
197197 } ,
198198 ( { path, type, id, name, description } ) => {
199199 const { doc } = loadDocument ( path ) ;
200- const nodeType = z
201- . enum ( [
202- "intent" ,
203- "concept" ,
204- "capability" ,
205- "element" ,
206- "realisation" ,
207- "invariant" ,
208- "principle" ,
209- "policy" ,
210- "protocol" ,
211- "stage" ,
212- "role" ,
213- "gate" ,
214- "mode" ,
215- "artefact" ,
216- "artefact_flow" ,
217- "decision" ,
218- "change" ,
219- "view" ,
220- "version" ,
221- ] )
222- . safeParse ( type ) ;
200+ const nodeType = NodeType . safeParse ( type ) ;
223201 if ( ! nodeType . success ) {
224- throw new Error ( `Invalid node type: ${ type } ` ) ;
202+ throw new Error (
203+ `Invalid node type: "${ type } ". Valid types: ${ NodeType . options . join ( ", " ) } ` ,
204+ ) ;
225205 }
226206 const nodeId = id ?? nextIdOp ( { doc, type : nodeType . data } ) ;
227207 const updated = addNodeOp ( {
@@ -360,7 +340,9 @@ server.registerTool(
360340 const { doc } = loadDocument ( path ) ;
361341 const relType = RelationshipType . safeParse ( type ) ;
362342 if ( ! relType . success ) {
363- throw new Error ( `Invalid relationship type: ${ type } ` ) ;
343+ throw new Error (
344+ `Invalid relationship type: "${ type } ". Valid types: ${ RelationshipType . options . join ( ", " ) } ` ,
345+ ) ;
364346 }
365347 const updated = addRelationshipOp ( {
366348 doc,
@@ -404,7 +386,9 @@ server.registerTool(
404386 const { doc } = loadDocument ( path ) ;
405387 const relType = RelationshipType . safeParse ( type ) ;
406388 if ( ! relType . success ) {
407- throw new Error ( `Invalid relationship type: ${ type } ` ) ;
389+ throw new Error (
390+ `Invalid relationship type: "${ type } ". Valid types: ${ RelationshipType . options . join ( ", " ) } ` ,
391+ ) ;
408392 }
409393 const result = removeRelationshipOp ( {
410394 doc,
0 commit comments