@directive-run/mcp 0.1.0 → 0.2.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/README.md CHANGED
@@ -41,27 +41,80 @@ npx @modelcontextprotocol/inspector npx -y @directive-run/mcp
41
41
  ## SSE transport (hosted)
42
42
 
43
43
  ```bash
44
- directive-mcp --sse --port 3000 --host 0.0.0.0
44
+ # Loopback (local dev) no token required
45
+ directive-mcp --sse --port 3000
46
+
47
+ # Public host — token is mandatory
48
+ directive-mcp --sse --port 3000 --host 0.0.0.0 \
49
+ --token "$DIRECTIVE_MCP_TOKEN" \
50
+ --allow-origin https://app.example.com
45
51
  ```
46
52
 
53
+ The SSE server **refuses to start** on a non-loopback host without `--token` (or `DIRECTIVE_MCP_TOKEN`). When a token is set, every request to `/sse` and `/messages` must carry `Authorization: Bearer <token>`. Body size is capped at 1 MB; concurrent sessions at 64; idle sessions are pruned at 5 minutes.
54
+
47
55
  Endpoints:
48
56
 
49
57
  - `GET /sse` — establish the SSE stream.
50
58
  - `POST /messages?sessionId=…` — client→server JSON-RPC messages.
51
59
  - `GET /healthz` — liveness probe.
52
60
 
53
- ## Tools
61
+ ## Tools (20)
62
+
63
+ ### Knowledge
54
64
 
55
65
  | Tool | Purpose |
56
66
  |---|---|
57
67
  | `list_knowledge` | Every knowledge file name (core + AI + skeleton). |
58
68
  | `get_knowledge` | Read one knowledge file by name. |
69
+ | `search_knowledge` | Case-insensitive substring search across every knowledge file. |
59
70
  | `list_examples` | Every code example name. |
60
71
  | `get_example` | Read one example by name (returned as a TypeScript code block). |
61
- | `search_knowledge` | Case-insensitive substring search across every knowledge file. |
72
+ | `search_examples` | Case-insensitive substring search across the 37 bundled example .ts files. |
73
+
74
+ ### Packages
75
+
76
+ | Tool | Purpose |
77
+ |---|---|
78
+ | `list_packages` | Every `@directive-run/*` package with one-line description. |
79
+ | `get_package_info` | Single-package detail (baked metadata + live npm version, 1 h cache). |
80
+ | `get_composable_packages` | Outgoing and incoming composition edges for one package. |
81
+
82
+ ### Generate
83
+
84
+ | Tool | Purpose |
85
+ |---|---|
86
+ | `generate_module` | Generate NEW Directive module or AI orchestrator source. Returns the source string; never writes to disk. |
87
+ | `list_module_sections` | Enumerate the valid `sections` values for `generate_module`. |
88
+
89
+ ### Review
90
+
91
+ | Tool | Purpose |
92
+ |---|---|
93
+ | `list_review_rules` | Directive anti-patterns and ts-morph rules as structured data. |
94
+ | `get_review_rule` | One rule's full detail: WRONG/CORRECT example pair + explanation. |
95
+ | `review_source` | Run the rule registry against a TypeScript source string. Returns structured findings. |
96
+ | `fix_code` | Apply a rule's mechanical fix; returns diff + fixed source. |
97
+
98
+ ### Migration
99
+
100
+ | Tool | Purpose |
101
+ |---|---|
102
+ | `list_migration_sources` | Source libraries `get_migration_pattern` accepts. |
103
+ | `get_migration_pattern` | Concept map + steps + before/after for migrating from Redux / Zustand / XState / MobX / Jotai / Recoil. |
104
+
105
+ ### Skills
106
+
107
+ | Tool | Purpose |
108
+ |---|---|
62
109
  | `list_skills` | Every Claude Code skill bundled in `@directive-run/claude-plugin`. |
63
110
  | `get_skill` | One skill's `SKILL.md` + supporting knowledge files as a single document. |
64
111
 
112
+ ### Server
113
+
114
+ | Tool | Purpose |
115
+ |---|---|
116
+ | `get_server_info` | Version + transport + auth state + bundled-knowledge hash + session count. |
117
+
65
118
  ## Programmatic embedding
66
119
 
67
120
  For tool authors who want to mount the server inside their own host process:
package/dist/cli.js CHANGED
@@ -1,41 +1,72 @@
1
1
  #!/usr/bin/env node
2
- import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {getAllSkills,getSkill}from'@directive-run/claude-plugin';import {getAllKnowledge,getKnowledge,getAllExamples,getExample}from'@directive-run/knowledge';import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {z}from'zod';import {createServer}from'http';import {SSEServerTransport}from'@modelcontextprotocol/sdk/server/sse.js';var $="0.1.0",g=50,m=200;function b(n){return n.length>m?`${n.slice(0,m)}\u2026`:n}function T(n,e){let t=n.toLowerCase(),s=[];for(let[r,o]of e){let a=o.split(`
3
- `);for(let i=0;i<a.length;i++){let c=a[i];if(c.toLowerCase().includes(t)&&(s.push(`${r}.md:${i+1}: ${b(c)}`),s.length>=g))return s}}return s}function p(){let n=new McpServer({name:"directive",version:$});return n.registerTool("list_knowledge",{title:"List Directive knowledge files",description:"List every knowledge file shipped in @directive-run/knowledge. Returns the file names (without .md) that can be passed to get_knowledge. Covers core docs (engine, facts, constraints, resolvers, derivations, effects, plugins, modules, systems, testing) and AI docs (orchestrator, agents, adapters, guardrails, memory, MCP, RAG, security, evals, budget, multi-agent).",inputSchema:{}},async()=>{let e=getAllKnowledge(),t=Array.from(e.keys()).sort();return {content:[{type:"text",text:`${t.length} knowledge files:
2
+ import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {createHash}from'crypto';import {getAllSkills,getSkill}from'@directive-run/claude-plugin';import {getAllKnowledge,getKnowledge,getAllExamples,getExample,getCompositionsFor,getReverseCompositionsFor,getAntiPatterns,getAntiPatternById,MIGRATION_SOURCES,getMigrationPattern}from'@directive-run/knowledge';import {MODULE_SECTIONS,validateModuleName,generateOrchestrator,generateModule,suggestFileNames,requiredPackages}from'@directive-run/scaffold';import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {z as z$1}from'zod';import {fileURLToPath}from'url';import {Worker}from'worker_threads';import {runRules,applyFix}from'@directive-run/lint';import {createServer}from'http';import {SSEServerTransport}from'@modelcontextprotocol/sdk/server/sse.js';var k=[{name:"@directive-run/ai",version:"1.17.0",description:"AI guardrails and orchestration for Directive. Prompt injection, PII detection, cost tracking, multi-agent patterns.",homepage:"https://directive.run",keywords:["directive","ai","agents","guardrails","orchestration","llm","constraint-driven","ai-safety","prompt-injection","pii-detection","cost-tracking","multi-agent","openai","anthropic","ollama","gemini"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:[".","./anthropic","./devtools","./evals","./gemini","./guardrails","./mcp","./multi-agent","./ollama","./openai","./predicate","./testing"],directory:"ai",published:true},{name:"@directive-run/claude-plugin",version:"1.17.0",description:"Claude Code plugin for Directive \u2014 12 skills covering modules, constraints, resolvers, derivations, AI orchestration, and adapters. Installable via Claude Code's plugin marketplace or consumable programmatically as an npm package.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","claude","claude-code","skills","ai-rules","plugin","agents","knowledge"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:["."],directory:"claude-plugin",published:true},{name:"@directive-run/cli",version:"1.17.0",description:"CLI tools for Directive \u2014 AI coding rules, scaffolding, and more.",homepage:"https://directive.run",keywords:["directive","cli","ai-rules","cursor","copilot","claude","windsurf","cline","llms-txt"],dependencies:["@clack/prompts","@directive-run/knowledge","@directive-run/scaffold","picocolors"],peerDependencies:["@directive-run/timeline"],optionalDependencies:[],exports:[".","./llms.txt"],directory:"cli",published:true},{name:"@directive-run/core",version:"1.17.0",description:"The constraint-driven runtime for TypeScript. Declare what must be true \u2014 the runtime makes it happen.",homepage:"https://directive.run",keywords:["directive","constraint-driven","state-management","constraints","reactive","runtime","typescript","ai-guardrails","zero-dependencies","auto-tracking","framework-agnostic","declarative"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:[".","./adapter-utils","./internals","./migration","./plugins","./testing","./worker"],directory:"core",published:true},{name:"@directive-run/el",version:"1.1.0",description:"Vanilla DOM adapter for Directive. Typed element creation + reactive bindings + JSX runtime.",homepage:"https://directive.run",keywords:["directive","vanilla","dom","elements","jsx","htm","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","htm"],optionalDependencies:[],exports:[".","./htm","./jsx-dev-runtime","./jsx-runtime"],directory:"el",published:true},{name:"@directive-run/knowledge",version:"1.17.0",description:"Knowledge files, examples, and validation for Directive \u2014 the constraint-driven TypeScript runtime.",homepage:"https://directive.run",keywords:["directive","knowledge","ai-rules","examples"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:["."],directory:"knowledge",published:true},{name:"@directive-run/lint",version:"0.1.1",description:"ts-morph-based static analysis for Directive code. Rule registry + executable checks + autofixes. Consumed by @directive-run/mcp (review_source, fix_code tools) and the future `directive doctor lint` CLI command. Anti-pattern data sourced from @directive-run/knowledge so rule IDs stay in lock-step.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","lint","ast","ts-morph","review","anti-patterns"],dependencies:[],peerDependencies:[],optionalDependencies:["ts-morph"],exports:[".","./worker"],directory:"lint",published:true},{name:"@directive-run/lit",version:"1.17.0",description:"Lit web components adapter for Directive.",homepage:"https://directive.run",keywords:["directive","lit","web-components","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","lit"],optionalDependencies:[],exports:["."],directory:"lit",published:true},{name:"@directive-run/mcp",version:"0.2.1",description:"Model Context Protocol server that exposes Directive to AI clients \u2014 knowledge files, code examples, and Claude Code skill bundles today, with room to grow into runtime introspection and tooling. stdio for local clients (Claude Desktop, Cursor, MCP Inspector), SSE for hosted deployments at mcp.directive.run.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","mcp","model-context-protocol","knowledge","ai-rules","sse","stdio"],dependencies:["@directive-run/claude-plugin","@directive-run/knowledge","@directive-run/lint","@directive-run/scaffold","@modelcontextprotocol/sdk","zod"],peerDependencies:[],optionalDependencies:["ts-morph"],exports:["."],directory:"mcp",published:true},{name:"@directive-run/mutator",version:"0.3.1",description:"Discriminated mutation helper for Directive \u2014 collapse the pendingAction ceremony to a typed handler map.",homepage:"https://directive.run",keywords:["directive","mutator","state-management","discriminated-union","optimistic-update"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:["."],directory:"mutator",published:true},{name:"@directive-run/optimistic",version:"0.2.0",description:"Resolver-scope optimistic update + automatic rollback for Directive.",homepage:"https://directive.run",keywords:["directive","optimistic","rollback","snapshot","state-management"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:["."],directory:"optimistic",published:true},{name:"@directive-run/query",version:"1.2.0",description:"Declarative data fetching for Directive. Constraint-driven queries with causal cache invalidation.",homepage:"https://directive.run",keywords:["directive","data-fetching","query","cache","stale-while-revalidate","constraint-driven","reactive","typescript"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:["."],directory:"query",published:true},{name:"@directive-run/react",version:"1.17.0",description:"React hooks and components for Directive.",homepage:"https://directive.run",keywords:["directive","react","hooks","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","react"],optionalDependencies:[],exports:["."],directory:"react",published:true},{name:"@directive-run/scaffold",version:"0.1.0",description:"Pure source-string generators for Directive modules and orchestrators. Shared substrate consumed by @directive-run/cli (its `directive new` command) and @directive-run/mcp (its `generate_module` tool). Zero runtime dependencies.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","scaffold","codegen","module-generator"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:["."],directory:"scaffold",published:true},{name:"@directive-run/solid",version:"1.17.0",description:"Solid.js signals adapter for Directive.",homepage:"https://directive.run",keywords:["directive","solid","solidjs","signals","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","solid-js"],optionalDependencies:[],exports:["."],directory:"solid",published:true},{name:"@directive-run/svelte",version:"1.17.0",description:"Svelte stores adapter for Directive.",homepage:"https://directive.run",keywords:["directive","svelte","stores","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","svelte"],optionalDependencies:[],exports:["."],directory:"svelte",published:true},{name:"@directive-run/timeline",version:"0.3.1",description:"Time-travel test REPL for Directive. Auto-renders the causal-graph timeline of any failing test.",homepage:"https://directive.run",keywords:["directive","time-travel","test-debugging","vitest","causal-graph","state-management"],dependencies:[],peerDependencies:["@directive-run/core","vitest"],optionalDependencies:[],exports:[".","./matchers","./reporter"],directory:"timeline",published:true},{name:"@directive-run/vite-plugin-api-proxy",version:"0.1.1",description:"",keywords:[],dependencies:[],peerDependencies:["vite"],optionalDependencies:[],exports:["."],directory:"vite-plugin-api-proxy",published:false},{name:"@directive-run/vue",version:"1.17.0",description:"Vue composition API adapter for Directive.",homepage:"https://directive.run",keywords:["directive","vue","composition-api","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","vue"],optionalDependencies:[],exports:["."],directory:"vue",published:true}],E="2026-06-04T00:02:07.900Z";var T=2e5,D=5e3,ee=/^[\w./-]{1,128}$/,l=class extends Error{constructor(r,i){super(r);this.code=i;}};function $(e){let t=Buffer.byteLength(e.source,"utf8");if(t>T)throw new l(`source is ${t} bytes (max ${T})`,"source-too-large");let r="fileName"in e?e.fileName:void 0;if(r!==void 0&&!ee.test(r))throw new l("invalid fileName","bad-filename")}async function te(){let e=await import.meta.resolve("@directive-run/lint/worker");return fileURLToPath(e)}async function R(e){let t=await te(),r=new Worker(t,{stderr:false}),i=null;try{return await new Promise((n,s)=>{let c=!1;r.once("message",a=>{c=!0,a.ok&&a.result!==void 0?n(a.result):s(new l(a.error??"worker returned without result","worker-error"));}),r.once("error",a=>{c=!0,s(new l(a.message,"worker-error"));}),r.once("exit",a=>{!c&&a!==0&&a!==null&&s(new l(`worker exited with code ${a} before responding`,"worker-error"));}),i=setTimeout(()=>{r.terminate(),s(new l(`parse exceeded ${D}ms budget`,"timeout"));},D),r.postMessage(e);})}finally{i&&clearTimeout(i),await r.terminate().catch(()=>{});}}function I(){return process.env.DIRECTIVE_MCP_USE_LINT_WORKER==="1"}async function C(e){return $(e),I()?R({kind:"run",source:e.source,options:{fileName:e.fileName,ruleFilter:e.ruleFilter}}):runRules(e.source,{fileName:e.fileName,ruleFilter:e.ruleFilter})}async function P(e){return $(e),I()?R({kind:"fix",source:e.source,finding:e.finding}):applyFix(e.source,e.finding)}var re=3600*1e3,ie=3e3,A=new Map;function O(){return k.map(e=>({name:e.name,summary:e.description,published:e.published}))}async function L(e){let t=k.find(n=>n.name===e);if(!t)return;let{liveVersion:r,stale:i}=await se(t);return ne(t,r,i)}function ne(e,t,r){return {name:e.name,description:e.description,homepage:e.homepage,keywords:e.keywords,dependencies:e.dependencies,peerDependencies:e.peerDependencies,optionalDependencies:e.optionalDependencies,exports:e.exports,published:e.published,npmUrl:e.published?`https://www.npmjs.com/package/${e.name}`:void 0,bakedVersion:e.version,liveVersion:t,stale:r}}async function se(e){if(!e.published)return {stale:true};let t=A.get(e.name);if(t&&Date.now()-t.fetchedAt<re)return {liveVersion:t.liveVersion,stale:t.liveVersion===void 0};let r=await oe(e.name);return A.set(e.name,{fetchedAt:Date.now(),liveVersion:r.liveVersion,latest:r.liveVersion,error:r.error}),{liveVersion:r.liveVersion,stale:r.liveVersion===void 0}}async function oe(e){let t=`https://registry.npmjs.org/${encodeURIComponent(e).replace(/%2F/g,"/")}/latest`,r=new AbortController,i=setTimeout(()=>r.abort(),ie);try{let n=await fetch(t,{signal:r.signal});if(!n.ok)return {error:`HTTP ${n.status}`};let s=await n.json();return typeof s.version=="string"?{liveVersion:s.version}:{error:"no version field"}}catch(n){return {error:n.message}}finally{clearTimeout(i);}}var N="0.2.0",j=50,V=200,F=512;function Se(e){return e.length>V?`${e.slice(0,V)}\u2026`:e}function U(e,t,r){let i=e.toLowerCase(),n=[];for(let[s,c]of t){let a=c.split(`
3
+ `);for(let d=0;d<a.length;d++){let u=a[d];if(u.toLowerCase().includes(i)&&(n.push(`${s}${r}:${d+1}: ${Se(u)}`),n.length>=j))return n}}return n}function G(e,t){return t.length===0?`No matches for '${e}'.`:`${t.length===j?`${t.length}+ matches (truncated):`:`${t.length} matches:`}
4
4
  ${t.join(`
5
- `)}`}]}}),n.registerTool("get_knowledge",{title:"Get a Directive knowledge file",description:"Fetch the full Markdown contents of one Directive knowledge file by name. Use list_knowledge first to discover available names. Names match the file stem (e.g. 'constraints', 'ai-orchestrator', 'api-skeleton').",inputSchema:{name:z.string().min(1).describe("The knowledge file name (no .md suffix). Example: 'constraints', 'ai-orchestrator', 'api-skeleton'.")}},async({name:e})=>{let t=getKnowledge(e);return t?{content:[{type:"text",text:t}]}:{isError:true,content:[{type:"text",text:`Knowledge file not found: '${e}'. Call list_knowledge to see available names.`}]}}),n.registerTool("list_examples",{title:"List Directive code examples",description:"List every code example shipped in @directive-run/knowledge. Examples are minimal, working TypeScript files demonstrating one concept each. Pass the returned names to get_example.",inputSchema:{}},async()=>{let e=getAllExamples(),t=Array.from(e.keys()).sort();return {content:[{type:"text",text:`${t.length} examples:
6
- ${t.join(`
7
- `)}`}]}}),n.registerTool("get_example",{title:"Get a Directive code example",description:"Fetch the source of one Directive code example by name. Use list_examples first to discover available names. Returns raw TypeScript.",inputSchema:{name:z.string().min(1).describe("The example file name (no .ts suffix). Example: 'basic-module', 'ai-orchestrator'.")}},async({name:e})=>{let t=getExample(e);return t?{content:[{type:"text",text:`\`\`\`typescript
8
- ${t}
9
- \`\`\``}]}:{isError:true,content:[{type:"text",text:`Example not found: '${e}'. Call list_examples to see available names.`}]}}),n.registerTool("search_knowledge",{title:"Search Directive knowledge files",description:"Case-insensitive substring search across every knowledge file. Returns up to 50 matching lines with the file name and line context. Useful for discovering which knowledge file covers a topic before calling get_knowledge for the full document.",inputSchema:{query:z.string().min(1).describe("The search string. Matched case-insensitively against every line of every knowledge file.")}},async({query:e})=>{let t=T(e,getAllKnowledge());return t.length===0?{content:[{type:"text",text:`No matches for '${e}'.`}]}:{content:[{type:"text",text:`${t.length===g?`${t.length}+ matches (truncated):`:`${t.length} matches:`}
10
- ${t.join(`
11
- `)}`}]}}),n.registerTool("list_skills",{title:"List Directive Claude Code skills",description:"List every skill bundled in @directive-run/claude-plugin. Each skill is a gerund-named bundle of one SKILL.md plus supporting knowledge files. Pass a returned name to get_skill.",inputSchema:{}},async()=>{let e=getAllSkills(),t=Array.from(e.keys()).sort();return {content:[{type:"text",text:`${t.length} skills:
12
- ${t.join(`
13
- `)}`}]}}),n.registerTool("get_skill",{title:"Get a Directive Claude Code skill",description:"Fetch one skill bundle: the SKILL.md manifest plus every supporting knowledge file concatenated into a single document. Use list_skills to discover names.",inputSchema:{name:z.string().min(1).describe("The skill name (e.g. 'building-ai-orchestrators', 'writing-directive-constraints').")}},async({name:e})=>{let t=getSkill(e);if(!t)return {isError:true,content:[{type:"text",text:`Skill not found: '${e}'. Call list_skills to see available names.`}]};let s=[`# Skill: ${t.name}
5
+ `)}`}var v=null;function _e(){if(v)return v;let e=createHash("sha256");for(let[t,r]of Array.from(getAllKnowledge()).sort(([i],[n])=>i.localeCompare(n)))e.update(t),e.update("\0"),e.update(r),e.update("\0");return v=e.digest("hex").slice(0,16),v}var g={transport:"stdio",authEnabled:false};function f(e){g=e;}function h(e,t,r){r.length!==0&&e.push("",`**${t}:**`,...r.map(i=>`- ${i}`));}function Ee(e){let t=[`# ${e.name}`,e.description,"",`**Version (live):** ${e.liveVersion??"unknown"}`,`**Version (baked):** ${e.bakedVersion}${e.stale?" (live fetch failed; using baked)":""}`,`**Published to npm:** ${e.published?"yes":"no (private workspace package)"}`];return e.homepage&&t.push(`**Homepage:** ${e.homepage}`),e.npmUrl&&t.push(`**npm:** ${e.npmUrl}`),h(t,"Dependencies",e.dependencies),h(t,"Peer dependencies",e.peerDependencies),h(t,"Optional dependencies",e.optionalDependencies),h(t,"Exports",e.exports),t.join(`
6
+ `)}function y(){let e=new McpServer({name:"directive",version:N});return e.registerTool("list_knowledge",{title:"List Directive knowledge files",description:"List every knowledge file shipped in @directive-run/knowledge. Returns the file names (without .md) that can be passed to get_knowledge. Covers core docs (engine, facts, constraints, resolvers, derivations, effects, plugins, modules, systems, testing) and AI docs (orchestrator, agents, adapters, guardrails, memory, MCP, RAG, security, evals, budget, multi-agent).",inputSchema:{}},async()=>{let t=getAllKnowledge(),r=Array.from(t.keys()).sort();return {content:[{type:"text",text:`${r.length} knowledge files:
7
+ ${r.join(`
8
+ `)}`}]}}),e.registerTool("get_knowledge",{title:"Get a Directive knowledge file",description:"Fetch the full Markdown contents of one Directive knowledge file by name. Use list_knowledge first to discover available names. Names match the file stem (e.g. 'constraints', 'ai-orchestrator', 'api-skeleton').",inputSchema:{name:z$1.string().min(1).describe("The knowledge file name (no .md suffix). Example: 'constraints', 'ai-orchestrator', 'api-skeleton'.")}},async({name:t})=>{let r=getKnowledge(t);return r?{content:[{type:"text",text:r}]}:{isError:true,content:[{type:"text",text:`Knowledge file not found: '${t}'. Call list_knowledge to see available names.`}]}}),e.registerTool("list_examples",{title:"List Directive code examples",description:"List every code example shipped in @directive-run/knowledge. Examples are minimal, working TypeScript files demonstrating one concept each. Pass the returned names to get_example.",inputSchema:{}},async()=>{let t=getAllExamples(),r=Array.from(t.keys()).sort();return {content:[{type:"text",text:`${r.length} examples:
9
+ ${r.join(`
10
+ `)}`}]}}),e.registerTool("get_example",{title:"Get a Directive code example",description:"Fetch the source of one Directive code example by name. Use list_examples first to discover available names. Returns raw TypeScript.",inputSchema:{name:z$1.string().min(1).describe("The example file name (no .ts suffix). Example: 'basic-module', 'ai-orchestrator'.")}},async({name:t})=>{let r=getExample(t);return r?{content:[{type:"text",text:`\`\`\`typescript
11
+ ${r}
12
+ \`\`\``}]}:{isError:true,content:[{type:"text",text:`Example not found: '${t}'. Call list_examples to see available names.`}]}}),e.registerTool("search_knowledge",{title:"Search Directive knowledge files",description:"Case-insensitive substring search across every knowledge file. Returns existing reference material; does NOT generate code. Use this to find which knowledge file covers a topic before calling get_knowledge for the full document.",inputSchema:{query:z$1.string().min(1).max(F).describe("The search string. Matched case-insensitively against every line of every knowledge file.")}},async({query:t})=>{let r=U(t,getAllKnowledge(),".md");return {content:[{type:"text",text:G(t,r)}]}}),e.registerTool("search_examples",{title:"Search Directive code examples",description:"Case-insensitive substring search across every bundled code example (.ts files in @directive-run/knowledge). Returns existing reference material; does NOT generate code. Use this to find which example demonstrates a concept before calling get_example for the full source.",inputSchema:{query:z$1.string().min(1).max(F).describe("The search string. Matched case-insensitively against every line of every example file.")}},async({query:t})=>{let r=U(t,getAllExamples(),".ts");return {content:[{type:"text",text:G(t,r)}]}}),e.registerTool("list_packages",{title:"List @directive-run/* packages",description:"Enumerate every @directive-run/* package known to this MCP server. Returns name + one-line description. Use this to answer 'what should I install for X?' and to discover names to pass to get_package_info or get_composable_packages. Returns existing reference material; does NOT generate code.",inputSchema:{}},async()=>{let t=O(),r=t.map(i=>`${i.name}${i.published?"":" (private)"} \u2014 ${i.summary}`);return {content:[{type:"text",text:`${t.length} packages:
13
+ ${r.join(`
14
+ `)}`}]}}),e.registerTool("get_package_info",{title:"Get @directive-run/* package detail",description:"Fetch detailed info for one @directive-run/* package: description, dependencies, peerDependencies, exports, npm URL. Returns the version baked into this MCP build AND the live-from-npm version when available (1-hour cache, 3-second timeout, falls back to baked version on network failure). Returns existing reference material; does NOT generate code.",inputSchema:{name:z$1.string().min(1).max(128).describe("Package name (e.g. '@directive-run/core'). Call list_packages first to discover valid names.")}},async({name:t})=>{let r=await L(t);return r?{content:[{type:"text",text:Ee(r)}]}:{isError:true,content:[{type:"text",text:`Package not found: '${t}'. Call list_packages to see available names.`}]}}),e.registerTool("get_composable_packages",{title:"Get composition siblings for a package",description:"Given a @directive-run/* package name, return the sibling packages it composes with (outgoing edges) AND the packages that compose with IT (incoming edges). Each edge carries a one-line reason. Returns existing reference material; does NOT generate code. Use this to answer 'what should I pair @directive-run/X with?' or 'who else uses @directive-run/Y?'.",inputSchema:{name:z$1.string().min(1).max(128).describe("Package name (e.g. '@directive-run/query'). Call list_packages first to discover valid names.")}},async({name:t})=>{let r=getCompositionsFor(t),i=getReverseCompositionsFor(t);if(r.length===0&&i.length===0)return {content:[{type:"text",text:`No composition data for '${t}'. Call list_packages to see available names.`}]};let n=[`# ${t}`,""];if(r.length>0){n.push("## Composes with:");for(let s of r)n.push(`- ${s.to} \u2014 ${s.reason}`);n.push("");}if(i.length>0){n.push("## Composed by:");for(let s of i)n.push(`- ${s.from} \u2014 ${s.reason}`);}return {content:[{type:"text",text:`<directive-data>
15
+ ${n.join(`
16
+ `)}
17
+ </directive-data>`}]}}),e.registerTool("get_server_info",{title:"Get directive MCP server info",description:"Return version manifest for this MCP server build \u2014 package version, transport (stdio or SSE), whether auth is enabled, bundled-knowledge hash, package-registry build timestamp, and (for SSE) the current session count. Returns existing reference material; does NOT generate code. Use this to verify the client is talking to the expected build.",inputSchema:{}},async()=>{let t=[`# @directive-run/mcp@${N}`,`**Transport:** ${g.transport}`,`**Auth enabled:** ${g.authEnabled?"yes":"no"}`,`**Bundled knowledge hash:** ${_e()}`,`**Package registry built at:** ${E}`];return g.sessionCount!==void 0&&t.push(`**Active SSE sessions:** ${g.sessionCount}`),{content:[{type:"text",text:t.join(`
18
+ `)}]}}),e.registerTool("list_module_sections",{title:"List valid module sections for generate_module",description:"Enumerate the valid `sections` values that `generate_module` accepts: derive, events, constraints, resolvers, effects. Call this before generate_module so the section list comes from the server (no hallucination risk). Returns existing reference material; does NOT generate code.",inputSchema:{}},async()=>({content:[{type:"text",text:`${MODULE_SECTIONS.length} module sections:
19
+ ${MODULE_SECTIONS.join(`
20
+ `)}`}]})),e.registerTool("generate_module",{title:"Generate NEW Directive module source code",description:'Generate the source string for a new Directive module or AI orchestrator. Use this when the user wants to CREATE a module, not learn about one. Returns the source as text; never writes to disk \u2014 the caller decides where to put it. Strict regex on `name` (kebab-case, \u226464 chars). For `kind: "module"`, optionally pass `sections` to pick which blocks to include (default: every section). Discover valid section values via list_module_sections.',inputSchema:{name:z$1.string().min(1).max(64).describe("Kebab-case identifier (e.g. 'traffic-light'). Must start with a lowercase letter and contain only lowercase letters, digits, and hyphens."),kind:z$1.enum(["module","orchestrator"]).default("module").describe("What to generate. 'module' for a plain Directive module; 'orchestrator' for an AI agent orchestrator module with memory + guardrails scaffolding."),sections:z$1.array(z$1.enum(MODULE_SECTIONS)).optional().describe("Which module sections to include. Defaults to every section. Only honored when kind === 'module'. Discover valid values via list_module_sections.")}},async({name:t,kind:r,sections:i})=>{let n=validateModuleName(t);if(n!==true)return {isError:true,content:[{type:"text",text:`Invalid name '${t}': ${n}`}]};try{let s=r==="orchestrator"?generateOrchestrator(t):generateModule(t,i??MODULE_SECTIONS),{sourceFileName:c,testFileName:a}=suggestFileNames(t,r),d=requiredPackages(r);return {content:[{type:"text",text:[`// Suggested file: src/${c}`,`// Suggested test: src/${a}`,`// Required packages: ${d.join(", ")}`,`// Run: pnpm add ${d.join(" ")}`,"",s].join(`
21
+ `)}]}}catch(s){return {isError:true,content:[{type:"text",text:s.message}]}}}),e.registerTool("list_review_rules",{title:"List Directive code-review rules",description:"Enumerate every anti-pattern Directive code can violate, parsed from @directive-run/knowledge. Each entry carries an id, severity, category, title, badExample, goodExample, and explanation. Use this to discover rule ids before calling get_review_rule or before passing ruleFilter to review_source. Returns existing reference material; does NOT generate code.",inputSchema:{}},async()=>{let t=getAntiPatterns(),r=t.map(i=>({id:i.id,severity:i.severity,category:i.category,title:i.title}));return {content:[{type:"text",text:`<directive-data>
22
+ ${t.length} review rules:
23
+ ${JSON.stringify(r,null,2)}
24
+ </directive-data>`}]}}),e.registerTool("get_review_rule",{title:"Get a Directive code-review rule",description:"Fetch one anti-pattern's full detail: title, severity, category, explanation, and the WRONG/CORRECT code-example pair. Use list_review_rules first to discover valid ids. Returns existing reference material; does NOT generate code.",inputSchema:{id:z$1.string().min(1).max(128).describe("Rule id (a kebab-case slug \u2014 e.g. 'flat-schema-missing-facts-wrapper'). Call list_review_rules first to discover valid ids.")}},async({id:t})=>{let r=getAntiPatternById(t);if(!r)return {isError:true,content:[{type:"text",text:`Rule not found: '${t}'. Call list_review_rules to see available ids.`}]};let i=[`# ${r.title}`,`**id:** ${r.id}`,`**severity:** ${r.severity}`,`**category:** ${r.category}`];return r.explanation&&i.push("",r.explanation),r.badExample&&i.push("","## Wrong","```typescript",r.badExample,"```"),r.goodExample&&i.push("","## Correct","```typescript",r.goodExample,"```"),{content:[{type:"text",text:`<directive-data>
25
+ ${i.join(`
26
+ `)}
27
+ </directive-data>`}]}}),e.registerTool("list_migration_sources",{title:"List supported migration source libraries",description:"Enumerate the source libraries get_migration_pattern accepts: redux, zustand, xstate, mobx, jotai, recoil. Call this before get_migration_pattern so the source list comes from the server (no hallucination risk). Returns existing reference material; does NOT generate code.",inputSchema:{}},async()=>({content:[{type:"text",text:`${MIGRATION_SOURCES.length} sources:
28
+ ${MIGRATION_SOURCES.join(`
29
+ `)}`}]})),e.registerTool("get_migration_pattern",{title:"Get migration pattern from a state-management library",description:"Fetch the concept-mapping table + step list + before/after exemplars for migrating from a popular state-management library to Directive. Use this when a user asks 'how do I migrate from Redux / Zustand / XState / MobX / Jotai / Recoil'. Returns existing reference material; does NOT generate code.",inputSchema:{source:z$1.enum(MIGRATION_SOURCES).describe("Source library. Discover valid values via list_migration_sources.")}},async({source:t})=>{let r=getMigrationPattern(t);return r?{content:[{type:"text",text:`<directive-data>
30
+ ${[`# Migrating from ${r.name} to Directive`,"","## Concept map","","| From | To | Note |","|---|---|---|",...r.conceptMap.map(n=>`| ${n.from} | ${n.to} | ${n.note} |`),"","## Steps",...r.steps.map((n,s)=>`${s+1}. ${n}`),"","## Before","```typescript",r.before,"```","","## After","```typescript",r.after,"```"].join(`
31
+ `)}
32
+ </directive-data>`}]}:{isError:true,content:[{type:"text",text:`Migration pattern not found: '${t}'. Call list_migration_sources to see valid values.`}]}}),e.registerTool("review_source",{title:"Review Directive code with ts-morph rules",description:"Run the @directive-run/lint rule registry against a TypeScript source string. Returns structured findings (line, column, severity, message, fixable) for every match. Use this when the user asks 'review this Directive code' or 'lint this'. Source is parsed in a worker thread with a 5-second budget and 200 KB cap.",inputSchema:{source:z$1.string().min(1).max(2e5).describe("TypeScript source to review. Max 200,000 bytes; longer inputs are rejected pre-parse."),fileName:z$1.string().regex(/^[\w./-]{1,128}$/).optional().describe("Optional file name shown in findings. Must match /^[\\w./-]{1,128}$/."),ruleFilter:z$1.array(z$1.string().max(64)).max(32).optional().describe("Optional whitelist of rule ids to run. Discover valid ids via list_review_rules.")}},async({source:t,fileName:r,ruleFilter:i})=>{try{let n=await C({source:t,fileName:r,ruleFilter:i});return {content:[{type:"text",text:`<directive-data>
33
+ ${JSON.stringify(n,null,2)}
34
+ </directive-data>`}]}}catch(n){return {isError:true,content:[{type:"text",text:`review_source failed \u2014 ${n instanceof l?`${n.code}: ${n.message}`:n.message}`}]}}}),e.registerTool("fix_code",{title:"Apply a mechanical fix for a Directive review finding",description:"Given a source string and a Finding returned by review_source, run the rule's mechanical fix and return { ok, diff, fixedSource, explanation } \u2014 or { ok: false, reason } when the rule has no fix. Useful for closing the loop: review_source \u2192 user picks \u2192 fix_code. The fixed source is NOT written to disk \u2014 the caller decides.",inputSchema:{source:z$1.string().min(1).max(2e5).describe("The same source you passed to review_source."),finding:z$1.object({ruleId:z$1.string().min(1).max(64),severity:z$1.enum(["error","warning","info"]),line:z$1.number().int().nonnegative(),column:z$1.number().int().nonnegative(),message:z$1.string(),findingId:z$1.string(),suggestion:z$1.string().optional()}).describe("The Finding returned by review_source. Pass the WHOLE object \u2014 the worker uses ruleId + line + column to locate the AST node.")}},async({source:t,finding:r})=>{try{let i=await P({source:t,finding:r});return {content:[{type:"text",text:`<directive-data>
35
+ ${JSON.stringify(i,null,2)}
36
+ </directive-data>`}]}}catch(i){return {isError:true,content:[{type:"text",text:`fix_code failed \u2014 ${i instanceof l?`${i.code}: ${i.message}`:i.message}`}]}}}),e.registerTool("list_skills",{title:"List Directive Claude Code skills",description:"List every skill bundled in @directive-run/claude-plugin. Each skill is a gerund-named bundle of one SKILL.md plus supporting knowledge files. Pass a returned name to get_skill.",inputSchema:{}},async()=>{let t=getAllSkills(),r=Array.from(t.keys()).sort();return {content:[{type:"text",text:`${r.length} skills:
37
+ ${r.join(`
38
+ `)}`}]}}),e.registerTool("get_skill",{title:"Get a Directive Claude Code skill",description:"Fetch one skill bundle: the SKILL.md manifest plus every supporting knowledge file concatenated into a single document. Use list_skills to discover names.",inputSchema:{name:z$1.string().min(1).describe("The skill name (e.g. 'building-ai-orchestrators', 'writing-directive-constraints').")}},async({name:t})=>{let r=getSkill(t);if(!r)return {isError:true,content:[{type:"text",text:`Skill not found: '${t}'. Call list_skills to see available names.`}]};let i=[`# Skill: ${r.name}
14
39
 
15
- ${t.manifest}`];for(let[r,o]of t.files)s.push(`---
40
+ ${r.manifest}`];for(let[n,s]of r.files)i.push(`---
16
41
 
17
- ## ${r}.md
42
+ ## ${n}.md
18
43
 
19
- ${o}`);return {content:[{type:"text",text:s.join(`
44
+ ${s}`);return {content:[{type:"text",text:i.join(`
20
45
 
21
- `)}]}}),n}var u="/messages",h="/sse",_="/healthz";async function C(n,e,t){let s=new SSEServerTransport(u,n),r=p();e.set(s.sessionId,{transport:s});let o=()=>{e.delete(s.sessionId);};n.on("close",o),s.onclose=o,await r.connect(s),t.log(`[directive-mcp] sse session opened: ${s.sessionId}`);}async function I(n,e,t,s){let r=t.searchParams.get("sessionId");if(!r){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("missing sessionId query parameter");return}let o=s.get(r);if(!o){e.writeHead(404,{"Content-Type":"text/plain"}),e.end(`unknown session: ${r}`);return}await o.transport.handlePostMessage(n,e);}async function L(n,e,t,s,r){let o=new URL(n.url??"/",`http://${n.headers.host??r}`);if(n.method==="GET"&&o.pathname===_){e.writeHead(200,{"Content-Type":"text/plain"}),e.end("ok");return}if(n.method==="GET"&&o.pathname===h){await C(e,t,s);return}if(n.method==="POST"&&o.pathname===u){await I(n,e,o,t);return}e.writeHead(404,{"Content-Type":"text/plain"}),e.end("not found");}async function f(n={}){let e=n.port??3e3,t=n.host??"127.0.0.1",s=n.logger??console,r=new Map,o=createServer(async(a,i)=>{try{await L(a,i,r,s,t);}catch(c){s.error("[directive-mcp] request error:",c),i.headersSent||i.writeHead(500,{"Content-Type":"text/plain"}),i.end("internal server error");}});return await new Promise(a=>{o.listen(e,t,()=>{s.log(`[directive-mcp] sse server listening at http://${t}:${e}${h}`),a();});}),o}var M="0.1.0",v=`directive-mcp \u2014 MCP server exposing Directive to AI clients
46
+ `)}]}}),e}var B="/messages",H="/sse",$e="/healthz",Re=1e6,Ie=64,Ce=300*1e3,Pe=3e4,Ae=new Set(["127.0.0.1","localhost","::1","0:0:0:0:0:0:0:1"]),S=class extends Error{};function Oe(e){return Ae.has(e.toLowerCase())}function Le(e){let t=e.port??3e3,r=e.host??"127.0.0.1",i=e.logger??console,n=e.token??process.env.DIRECTIVE_MCP_TOKEN??void 0;if(!Oe(r)&&!n)throw new S("Public hosts require a token. Pass --token <value> or set DIRECTIVE_MCP_TOKEN, or bind to 127.0.0.1 for local dev.");return {port:t,host:r,logger:i,token:n,allowOrigins:e.allowOrigins??[],bodyLimitBytes:e.bodyLimitBytes??Re,maxSessions:e.maxSessions??Ie,idleTimeoutMs:e.idleTimeoutMs??Ce}}function K(e,t){if(!t)return true;let r=e.headers.authorization;return typeof r!="string"?false:/^Bearer\s+(.+)$/i.exec(r)?.[1]?.trim()===t}function W(e,t){if(t.length===0)return true;let r=e.headers.origin;return typeof r!="string"?false:t.includes(r)}function p(e,t,r,i={}){e.writeHead(t,{"Content-Type":"text/plain",...i}),e.end(r);}function _(e,t){f({transport:"sse",authEnabled:t,sessionCount:e.size});}async function Me(e,t,r,i){if(!K(e,i.token)){p(t,401,"unauthorized");return}if(!W(e,i.allowOrigins)){p(t,403,"origin not allowed");return}if(r.size>=i.maxSessions){p(t,429,"session cap reached",{"Retry-After":"60"});return}let n=new SSEServerTransport(B,t),s=y();r.set(n.sessionId,{transport:n,lastActivity:Date.now()}),_(r,!!i.token);let c=()=>{r.delete(n.sessionId),_(r,!!i.token);};t.on("close",c),n.onclose=c,await s.connect(n),i.logger.log(`[directive-mcp] sse session opened: ${n.sessionId}`);}async function Ne(e,t,r,i,n){if(!K(e,n.token)){p(t,401,"unauthorized");return}if(!W(e,n.allowOrigins)){p(t,403,"origin not allowed");return}let s=Number(e.headers["content-length"]??"0");if(Number.isFinite(s)&&s>n.bodyLimitBytes){p(t,413,`body exceeds ${n.bodyLimitBytes} bytes`);return}let c=r.searchParams.get("sessionId");if(!c){p(t,400,"missing sessionId query parameter");return}let a=i.get(c);if(!a){p(t,404,`unknown session: ${c}`);return}a.lastActivity=Date.now();let d=0,u=false;e.on("data",Y=>{d+=Buffer.byteLength(Y),d>n.bodyLimitBytes&&!u&&(u=true,p(t,413,`body exceeds ${n.bodyLimitBytes} bytes`),e.destroy());}),!u&&await a.transport.handlePostMessage(e,t);}async function Ve(e,t,r,i){let n=new URL(e.url??"/",`http://${e.headers.host??i.host}`);if(e.method==="GET"&&n.pathname===$e){t.writeHead(200,{"Content-Type":"text/plain"}),t.end("ok");return}if(e.method==="GET"&&n.pathname===H){await Me(e,t,r,i);return}if(e.method==="POST"&&n.pathname===B){await Ne(e,t,n,r,i);return}p(t,404,"not found");}function Fe(e,t){return setInterval(()=>{let r=Date.now();for(let[i,n]of e)r-n.lastActivity>t.idleTimeoutMs&&(e.delete(i),n.transport.close().catch(()=>{}),_(e,!!t.token),t.logger.log(`[directive-mcp] pruned idle session: ${i}`));},Pe).unref()}async function z(e={}){let t=Le(e),r=new Map,i=createServer(async(s,c)=>{try{await Ve(s,c,r,t);}catch(a){t.logger.error("[directive-mcp] request error:",a),c.headersSent||c.writeHead(500,{"Content-Type":"text/plain"}),c.end("internal server error");}}),n=Fe(r,t);return i.on("close",()=>{clearInterval(n);}),await new Promise(s=>{i.listen(t.port,t.host,()=>{t.logger.log(`[directive-mcp] sse server listening at http://${t.host}:${t.port}${H}${t.token?" (auth: bearer-token)":" (auth: none, loopback only)"}`),s();});}),i}var Ge="0.2.0",X=`directive-mcp \u2014 MCP server exposing Directive to AI clients
22
47
 
23
48
  Usage:
24
- directive-mcp Run stdio transport (default)
25
- directive-mcp --sse Run SSE transport on 127.0.0.1:3000
26
- directive-mcp --sse --port 8080 --host 0.0.0.0
49
+ directive-mcp Run stdio transport (default)
50
+ directive-mcp --sse Run SSE transport on 127.0.0.1:3000
51
+ directive-mcp --sse --port 8080 --host 0.0.0.0 \\
52
+ --token <secret> --allow-origin https://app.example.com
27
53
 
28
54
  Options:
29
- --sse Use HTTP SSE transport instead of stdio
30
- --port <port> SSE port (default: 3000)
31
- --host <host> SSE bind host (default: 127.0.0.1)
32
- --help, -h Show this help
33
- --version, -v Show package version
55
+ --sse Use HTTP SSE transport instead of stdio
56
+ --port <port> SSE port (default: 3000)
57
+ --host <host> SSE bind host (default: 127.0.0.1)
58
+ --token <value> Bearer token required on /sse and /messages requests.
59
+ MANDATORY when --host is not loopback. Can also be
60
+ passed via the DIRECTIVE_MCP_TOKEN env var.
61
+ --allow-origin <origin> Permitted Origin header value. Repeatable. When
62
+ omitted, no Origin check is performed.
63
+ --help, -h Show this help
64
+ --version, -v Show package version
34
65
 
35
66
  Docs: https://directive.run/docs/ide-integration
36
- `;function D(n){let e={sse:false,port:3e3,host:"127.0.0.1",help:false,version:false};for(let t=0;t<n.length;t++){let s=n[t];switch(s){case "--sse":e.sse=true;break;case "--port":{let r=n[++t];if(!r)throw new Error("--port requires a value");let o=Number(r);if(!Number.isInteger(o)||o<=0||o>65535)throw new Error(`invalid --port: ${r}`);e.port=o;break}case "--host":{let r=n[++t];if(!r)throw new Error("--host requires a value");e.host=r;break}case "--help":case "-h":e.help=true;break;case "--version":case "-v":e.version=true;break;default:throw new Error(`unknown argument: ${s}`)}}return e}async function H(){let n;try{n=D(process.argv.slice(2));}catch(s){process.stderr.write(`${s.message}
67
+ `;function w(e,t,r){let i=e[t];if(!i)throw new Error(`${r} requires a value`);return i}function je(e){let t=Number(e);if(!Number.isInteger(t)||t<=0||t>65535)throw new Error(`invalid --port: ${e}`);return t}function Be(e){let t={sse:false,port:3e3,host:"127.0.0.1",help:false,version:false,allowOrigins:[]};for(let r=0;r<e.length;r++){let i=e[r];switch(i){case "--sse":t.sse=true;break;case "--port":t.port=je(w(e,++r,"--port"));break;case "--host":t.host=w(e,++r,"--host");break;case "--token":t.token=w(e,++r,"--token");break;case "--allow-origin":t.allowOrigins.push(w(e,++r,"--allow-origin"));break;case "--help":case "-h":t.help=true;break;case "--version":case "-v":t.version=true;break;default:throw new Error(`unknown argument: ${i}`)}}return t}async function He(){let e;try{e=Be(process.argv.slice(2));}catch(i){process.stderr.write(`${i.message}
37
68
 
38
- ${v}`),process.exit(2);}if(n.help){process.stdout.write(v);return}if(n.version){process.stdout.write(`${M}
39
- `);return}if(n.sse){let s=await f({port:n.port,host:n.host}),r=()=>{s.close(()=>process.exit(0));};process.on("SIGINT",r),process.on("SIGTERM",r);return}let e=p(),t=new StdioServerTransport;await e.connect(t);}H().catch(n=>{process.stderr.write(`[directive-mcp] fatal: ${n.stack??String(n)}
69
+ ${X}`),process.exit(2);}if(e.help){process.stdout.write(X);return}if(e.version){process.stdout.write(`${Ge}
70
+ `);return}if(e.sse){let i=await z({port:e.port,host:e.host,token:e.token,allowOrigins:e.allowOrigins}),n=()=>{i.close(()=>process.exit(0));};process.on("SIGINT",n),process.on("SIGTERM",n);return}f({transport:"stdio",authEnabled:false});let t=y(),r=new StdioServerTransport;await t.connect(r);}He().catch(e=>{process.stderr.write(`[directive-mcp] fatal: ${e.stack??String(e)}
40
71
  `),process.exit(1);});//# sourceMappingURL=cli.js.map
41
72
  //# sourceMappingURL=cli.js.map