@donotdev/mcp-server 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/dist/index.js +7 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import{Server as v}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as y}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as k,ListToolsRequestSchema as S}from"@modelcontextprotocol/sdk/types.js";import{readFileSync as f,existsSync as m}from"fs";import{join as a}from"path";const g=["@donotdev/components","@donotdev/adv-comps","@donotdev/core","@donotdev/crud","@donotdev/firebase","@donotdev/auth","@donotdev/billing","@donotdev/oauth","@donotdev/ui","@donotdev/templates","@donotdev/functions","@donotdev/providers"];function w(){let e=process.cwd();for(;e!=="/";){const o=a(e,"node_modules");if(m(o))return o;e=a(e,"..")}return null}function $(e,o){const c=new RegExp(`export\\s+interface\\s+${o}\\s*(?:<[^>]+>)?\\s*(?:extends[^{]+)?\\{[^}]+\\}`,"gs");let n=e.match(c);if(n)return n[0];const s=new RegExp(`export\\s+type\\s+${o}\\s*(?:<[^>]+>)?\\s*=[^;]+;`,"gs");if(n=e.match(s),n)return n[0];const r=new RegExp(`export\\s+const\\s+${o}\\s*[=:][^;]+;`,"gs");return n=e.match(r),n?n[0]:null}function R(e){const o=[],c=e.matchAll(/export\s*\{([^}]+)\}/g);for(const t of c)if(t[1]){const d=t[1].split(",").map(p=>p.trim().split(" ")[0]).filter(p=>!!p);o.push(...d)}const n=e.matchAll(/export\s+interface\s+(\w+)/g);for(const t of n)t[1]&&o.push(t[1]);const s=e.matchAll(/export\s+type\s+(\w+)/g);for(const t of s)t[1]&&o.push(t[1]);const r=e.matchAll(/export\s+const\s+(\w+)/g);for(const t of r)t[1]&&o.push(t[1]);const i=e.matchAll(/export\s+default\s+(\w+)/g);for(const t of i)t[1]&&o.push(t[1]);return[...new Set(o)].filter(t=>t&&t!=="default")}const l=new v({name:"donotdev-mcp",version:"0.0.1"},{capabilities:{tools:{}}});l.setRequestHandler(S,async()=>({tools:[{name:"lookup_component",description:"Get TypeScript props/types for a DoNotDev component. Returns the actual interface from .d.ts files.",inputSchema:{type:"object",properties:{component:{type:"string",description:'Component name (e.g., "Button", "ButtonProps", "Stack", "EntityFormRenderer")'},package:{type:"string",description:'Package name (e.g., "@donotdev/components"). If omitted, searches all packages.'}},required:["component"]}},{name:"list_components",description:"List all exported components/types from a DoNotDev package",inputSchema:{type:"object",properties:{package:{type:"string",description:'Package name (e.g., "@donotdev/components")'}},required:["package"]}},{name:"list_packages",description:"List all DoNotDev packages",inputSchema:{type:"object",properties:{}}}]})),l.setRequestHandler(k,async e=>{const{name:o,arguments:c}=e.params,n=w();if(!n)return{content:[{type:"text",text:"Error: node_modules not found. Run from project directory."}]};if(o==="list_packages")return{content:[{type:"text",text:`Available packages:
3
- ${g.filter(r=>m(a(n,r,"dist","index.d.ts"))).join(`
4
- `)}`}]};if(o==="list_components"){const s=c?.package,r=a(n,s,"dist","index.d.ts");if(!m(r))return{content:[{type:"text",text:`Error: ${s} not found at ${r}`}]};const i=f(r,"utf-8"),t=R(i);return{content:[{type:"text",text:`Exports from ${s}:
5
- ${t.join(`
6
- `)}`}]}}if(o==="lookup_component"){const s=c?.component,r=c?.package,i=[s,`${s}Props`,`${s.replace(/Props$/,"")}Props`],t=r?[r]:g;for(const d of t){const p=a(n,d,"dist","index.d.ts");if(!m(p))continue;const x=f(p,"utf-8");for(const h of i){const u=$(x,h);if(u)return{content:[{type:"text",text:`Found in ${d}:
2
+ import{Server as $}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as w}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as P,ListToolsRequestSchema as E}from"@modelcontextprotocol/sdk/types.js";import{readFileSync as y,existsSync as l,readdirSync as R,statSync as b}from"fs";import{join as i}from"path";const v=["@donotdev/components","@donotdev/adv-comps","@donotdev/core","@donotdev/crud","@donotdev/firebase","@donotdev/auth","@donotdev/billing","@donotdev/oauth","@donotdev/ui","@donotdev/templates","@donotdev/functions","@donotdev/providers"];function D(){let e=process.cwd();for(;e!=="/";){const t=i(e,"node_modules");if(l(t))return t;e=i(e,"..")}return null}function g(e){const t=[];if(!l(e))return t;const c=R(e);for(const n of c){const s=i(e,n);try{b(s).isDirectory()?t.push(...g(s)):n.endsWith(".d.ts")&&t.push(s)}catch{}}return t}function _(e,t){const c=new RegExp(`export\\s+interface\\s+${t}\\s*(?:<[^>]+>)?\\s*(?:extends[^{]+)?\\{[^}]+\\}`,"gs");let n=e.match(c);if(n)return n[0];const s=new RegExp(`export\\s+type\\s+${t}\\s*(?:<[^>]+>)?\\s*=[^;]+;`,"gs");if(n=e.match(s),n)return n[0];const r=new RegExp(`export\\s+const\\s+${t}\\s*[=:][^;]+;`,"gs");return n=e.match(r),n?n[0]:null}function N(e){const t=[],c=e.matchAll(/export\s*\{([^}]+)\}/g);for(const o of c)if(o[1]){const a=o[1].split(",").map(p=>p.trim().split(" ")[0]).filter(p=>!!p);t.push(...a)}const n=e.matchAll(/export\s+interface\s+(\w+)/g);for(const o of n)o[1]&&t.push(o[1]);const s=e.matchAll(/export\s+type\s+(\w+)/g);for(const o of s)o[1]&&t.push(o[1]);const r=e.matchAll(/export\s+const\s+(\w+)/g);for(const o of r)o[1]&&t.push(o[1]);const d=e.matchAll(/export\s+default\s+(\w+)/g);for(const o of d)o[1]&&t.push(o[1]);return[...new Set(t)].filter(o=>o&&o!=="default")}const h=new $({name:"donotdev-mcp",version:"0.0.1"},{capabilities:{tools:{}}});h.setRequestHandler(E,async()=>({tools:[{name:"lookup_component",description:"Get TypeScript props/types for a DoNotDev component. Returns the actual interface from .d.ts files.",inputSchema:{type:"object",properties:{component:{type:"string",description:'Component name (e.g., "Button", "ButtonProps", "Stack", "EntityFormRenderer")'},package:{type:"string",description:'Package name (e.g., "@donotdev/components"). If omitted, searches all packages.'}},required:["component"]}},{name:"list_components",description:"List all exported components/types from a DoNotDev package",inputSchema:{type:"object",properties:{package:{type:"string",description:'Package name (e.g., "@donotdev/components")'}},required:["package"]}},{name:"list_packages",description:"List all DoNotDev packages",inputSchema:{type:"object",properties:{}}}]})),h.setRequestHandler(P,async e=>{const{name:t,arguments:c}=e.params,n=D();if(!n)return{content:[{type:"text",text:"Error: node_modules not found. Run from project directory."}]};if(t==="list_packages")return{content:[{type:"text",text:`Available packages:
3
+ ${v.filter(r=>l(i(n,r,"dist"))).join(`
4
+ `)}`}]};if(t==="list_components"){const s=c?.package,r=i(n,s,"dist");if(!l(r))return{content:[{type:"text",text:`Error: ${s} not found at ${r}`}]};const d=g(r),o=new Set;for(const p of d){const f=y(p,"utf-8");N(f).forEach(m=>o.add(m))}const a=[...o].sort();return{content:[{type:"text",text:`Exports from ${s} (${a.length} total):
5
+ ${a.join(`
6
+ `)}`}]}}if(t==="lookup_component"){const s=c?.component,r=c?.package,d=[s,`${s}Props`,`${s.replace(/Props$/,"")}Props`],o=r?[r]:v;for(const a of o){const p=i(n,a,"dist");if(!l(p))continue;const f=g(p);for(const u of f){const m=y(u,"utf-8");for(const k of d){const x=_(m,k);if(x){const S=u.replace(i(n,a)+"/","");return{content:[{type:"text",text:`Found in ${a} (${S}):
7
7
 
8
- ${u}`}]}}}return{content:[{type:"text",text:`Not found: ${s}
8
+ ${x}`}]}}}}}return{content:[{type:"text",text:`Not found: ${s}
9
9
 
10
- Tip: Try lookup_component with just the component name (e.g., "Button" not "ButtonProps"), or use list_components to see available exports.`}]}}return{content:[{type:"text",text:`Unknown tool: ${o}`}]}});async function b(){const e=new y;await l.connect(e)}b().catch(console.error);
10
+ Tip: Try lookup_component with just the component name (e.g., "Button" not "ButtonProps"), or use list_components to see available exports.`}]}}return{content:[{type:"text",text:`Unknown tool: ${t}`}]}});async function j(){const e=new w;await h.connect(e)}j().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/mcp-server",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "MCP server for DoNotDev component type lookups",
5
5
  "type": "module",
6
6
  "private": false,