functype-mcp-server 1.4.3 → 1.5.0

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
@@ -105,11 +105,13 @@ Requires functype >= 0.47.0 for full documentation support. Older versions will
105
105
 
106
106
  ## Environment Variables
107
107
 
108
- | Variable | Default | Description |
109
- | ---------------- | --------- | --------------------------------------- |
110
- | `TRANSPORT_TYPE` | `stdio` | Transport mode: `stdio` or `httpStream` |
111
- | `PORT` | `3000` | HTTP port (when using httpStream) |
112
- | `HOST` | `0.0.0.0` | HTTP host (when using httpStream) |
108
+ | Variable | Default | Description |
109
+ | ---------------- | ----------- | ----------------------------------------------------------------------- |
110
+ | `TRANSPORT_TYPE` | `stdio` | Transport mode: `stdio` or `httpStream` |
111
+ | `PORT` | `3000` | HTTP port (when using httpStream) |
112
+ | `HOST` | `127.0.0.1` | HTTP host (when using httpStream). Set `0.0.0.0` to bind all interfaces |
113
+
114
+ **Security note.** `set_functype_version` installs a package and dynamic-imports it, so it is only registered when `TRANSPORT_TYPE=stdio` (the default). Over HTTP, an unauthenticated caller could otherwise downgrade `functype` to a vulnerable version. The HTTP listener also defaults to `127.0.0.1` — set `HOST=0.0.0.0` explicitly if you really want to bind publicly, and front it with auth.
113
115
 
114
116
  ## Development
115
117
 
package/dist/bin.js CHANGED
@@ -3,12 +3,12 @@
3
3
  if (!process.env.TRANSPORT_TYPE) process.env.TRANSPORT_TYPE = "stdio";
4
4
  const args = process.argv.slice(2);
5
5
  if (args.includes("--version") || args.includes("-v")) {
6
- console.log("1.4.3");
6
+ console.log("1.5.0");
7
7
  process.exit(0);
8
8
  }
9
9
  if (args.includes("--help") || args.includes("-h")) {
10
10
  console.log(`
11
- functype-mcp-server v1.4.3
11
+ functype-mcp-server v1.5.0
12
12
 
13
13
  MCP server for functype documentation lookup and TypeScript code validation.
14
14
 
@@ -21,13 +21,14 @@ Options:
21
21
  Environment Variables:
22
22
  TRANSPORT_TYPE Transport mode: "stdio" (default) or "httpStream"
23
23
  PORT HTTP port (default: 3000)
24
- HOST HTTP host (default: 0.0.0.0)
24
+ HOST HTTP host (default: 127.0.0.1) — set 0.0.0.0 to bind publicly
25
25
 
26
26
  Tools:
27
27
  search_docs Search functype documentation
28
28
  get_type_api Get detailed type API reference
29
29
  get_interfaces Get interface hierarchy
30
30
  validate_code Type-check functype code snippets
31
+ set_functype_version Switch installed functype version (stdio transport only)
31
32
 
32
33
  For more information: https://github.com/jordanburke/functype/tree/main/mcp-server
33
34
  `);
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\ndeclare const __VERSION__: string\n\nif (!process.env.TRANSPORT_TYPE) {\n process.env.TRANSPORT_TYPE = \"stdio\"\n}\n\nconst args = process.argv.slice(2)\n\nif (args.includes(\"--version\") || args.includes(\"-v\")) {\n console.log(__VERSION__)\n process.exit(0)\n}\n\nif (args.includes(\"--help\") || args.includes(\"-h\")) {\n console.log(`\nfunctype-mcp-server v${__VERSION__}\n\nMCP server for functype documentation lookup and TypeScript code validation.\n\nUsage: functype-mcp-server [options]\n\nOptions:\n -v, --version Show version number\n -h, --help Show help\n\nEnvironment Variables:\n TRANSPORT_TYPE Transport mode: \"stdio\" (default) or \"httpStream\"\n PORT HTTP port (default: 3000)\n HOST HTTP host (default: 0.0.0.0)\n\nTools:\n search_docs Search functype documentation\n get_type_api Get detailed type API reference\n get_interfaces Get interface hierarchy\n validate_code Type-check functype code snippets\n\nFor more information: https://github.com/jordanburke/functype/tree/main/mcp-server\n`)\n process.exit(0)\n}\n\nasync function main() {\n await import(\"./index.js\")\n}\n\nmain().then()\n"],"mappings":";;AAIA,IAAI,CAAC,QAAQ,IAAI,gBACf,QAAQ,IAAI,iBAAiB;AAG/B,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAEjC,IAAI,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,IAAI,GAAG;CACrD,QAAQ,IAAA,OAAe;CACvB,QAAQ,KAAK,CAAC;AAChB;AAEA,IAAI,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,GAAG;CAClD,QAAQ,IAAI;;;;;;;;;;;;;;;;;;;;;;;CAuBb;CACC,QAAQ,KAAK,CAAC;AAChB;AAEA,eAAe,OAAO;CACpB,MAAM,OAAO;AACf;AAEA,KAAK,CAAC,CAAC,KAAK"}
1
+ {"version":3,"file":"bin.js","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\ndeclare const __VERSION__: string\n\nif (!process.env.TRANSPORT_TYPE) {\n process.env.TRANSPORT_TYPE = \"stdio\"\n}\n\nconst args = process.argv.slice(2)\n\nif (args.includes(\"--version\") || args.includes(\"-v\")) {\n console.log(__VERSION__)\n process.exit(0)\n}\n\nif (args.includes(\"--help\") || args.includes(\"-h\")) {\n console.log(`\nfunctype-mcp-server v${__VERSION__}\n\nMCP server for functype documentation lookup and TypeScript code validation.\n\nUsage: functype-mcp-server [options]\n\nOptions:\n -v, --version Show version number\n -h, --help Show help\n\nEnvironment Variables:\n TRANSPORT_TYPE Transport mode: \"stdio\" (default) or \"httpStream\"\n PORT HTTP port (default: 3000)\n HOST HTTP host (default: 127.0.0.1) — set 0.0.0.0 to bind publicly\n\nTools:\n search_docs Search functype documentation\n get_type_api Get detailed type API reference\n get_interfaces Get interface hierarchy\n validate_code Type-check functype code snippets\n set_functype_version Switch installed functype version (stdio transport only)\n\nFor more information: https://github.com/jordanburke/functype/tree/main/mcp-server\n`)\n process.exit(0)\n}\n\nasync function main() {\n await import(\"./index.js\")\n}\n\nmain().then()\n"],"mappings":";;AAIA,IAAI,CAAC,QAAQ,IAAI,gBACf,QAAQ,IAAI,iBAAiB;AAG/B,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAEjC,IAAI,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,IAAI,GAAG;CACrD,QAAQ,IAAA,OAAe;CACvB,QAAQ,KAAK,CAAC;AAChB;AAEA,IAAI,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,GAAG;CAClD,QAAQ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;CAwBb;CACC,QAAQ,KAAK,CAAC;AAChB;AAEA,eAAe,OAAO;CACpB,MAAM,OAAO;AACf;AAEA,KAAK,CAAC,CAAC,KAAK"}
package/dist/index.d.ts CHANGED
@@ -1 +1,5 @@
1
- export { };
1
+ //#region src/index.d.ts
2
+ declare const isSafeFunctypeVersion: (version: string) => boolean;
3
+ //#endregion
4
+ export { isSafeFunctypeVersion };
5
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -258,19 +258,32 @@ const validateCode = (code, options = {}) => {
258
258
  //#endregion
259
259
  //#region src/index.ts
260
260
  const PROJECT_ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
261
- const SERVER_VERSION = "1.4.3";
261
+ const SERVER_VERSION = "1.5.0";
262
+ const SAFE_FUNCTYPE_VERSION = /^(?:latest|next|beta|alpha|canary|rc|[~^]?v?\d+(?:\.\d+){0,2}(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)$/;
263
+ const isSafeFunctypeVersion = (version) => {
264
+ if (version.trim() !== version) return false;
265
+ if (/[/:\\@\s]/.test(version)) return false;
266
+ return SAFE_FUNCTYPE_VERSION.test(version);
267
+ };
268
+ const isHttpTransport = () => {
269
+ const t = process.env.TRANSPORT_TYPE;
270
+ return t === "httpStream" || t === "http";
271
+ };
262
272
  function createServer() {
273
+ const exposeSetVersion = !isHttpTransport();
263
274
  const server = new FastMCP({
264
275
  name: "functype-mcp-server",
265
276
  version: SERVER_VERSION,
266
277
  instructions: `Functype MCP Server — documentation lookup and code validation for the functype TypeScript FP library (v${VERSION}).
267
278
 
268
279
  Available tools:
269
- - search_docs: Search functype documentation by keyword or type name
270
- - get_type_api: Get detailed API reference for a specific type
271
- - get_interfaces: Get the interface hierarchy (Functor, Monad, Foldable, etc.)
272
- - validate_code: Type-check functype code snippets at compile time
273
- - set_functype_version: Switch the functype version at runtime (installs + reloads)
280
+ ${[
281
+ "- search_docs: Search functype documentation by keyword or type name",
282
+ "- get_type_api: Get detailed API reference for a specific type",
283
+ "- get_interfaces: Get the interface hierarchy (Functor, Monad, Foldable, etc.)",
284
+ "- validate_code: Type-check functype code snippets at compile time",
285
+ ...exposeSetVersion ? ["- set_functype_version: Switch the functype version at runtime (installs + reloads)"] : []
286
+ ].join("\n")}
274
287
 
275
288
  Use validate_code to verify your functype code is type-correct before presenting it to the user.`
276
289
  });
@@ -322,14 +335,19 @@ Use validate_code to verify your functype code is type-correct before presenting
322
335
  return `Validation FAILED — ${result.diagnostics.length} error(s):\n\n${errorLines.join("\n")}${importNote}`;
323
336
  }
324
337
  });
325
- server.addTool({
338
+ if (exposeSetVersion) server.addTool({
326
339
  name: "set_functype_version",
327
- description: "Switch the functype version at runtime. Installs the specified version and reloads all documentation and type definitions.",
340
+ description: "Switch the functype version at runtime. Installs the specified version and reloads all documentation and type definitions. Stdio transport only.",
328
341
  parameters: z.object({ version: z.string().describe("The functype version to install (e.g., \"0.46.0\", \"latest\", \"^0.45.0\")") }),
329
342
  execute: async (args) => {
343
+ if (!isSafeFunctypeVersion(args.version)) return `Invalid version "${args.version}". Use a semver string (e.g. "1.4.4", "^1.4.0", "~1.4") or a known dist-tag (latest, next, beta, alpha, canary, rc). Alias syntaxes (file:, npm:, git+, URLs) are not allowed.`;
330
344
  const spec = `functype@${args.version}`;
331
345
  try {
332
- execFileSync("pnpm", ["add", spec], {
346
+ execFileSync("pnpm", [
347
+ "add",
348
+ "--ignore-scripts",
349
+ spec
350
+ ], {
333
351
  cwd: PROJECT_ROOT,
334
352
  stdio: "pipe",
335
353
  timeout: 6e4
@@ -351,9 +369,9 @@ Use validate_code to verify your functype code is type-correct before presenting
351
369
  async function main() {
352
370
  await initDocsData();
353
371
  const server = createServer();
354
- const useHttp = process.env.TRANSPORT_TYPE === "httpStream" || process.env.TRANSPORT_TYPE === "http";
372
+ const useHttp = isHttpTransport();
355
373
  const port = parseInt(process.env.PORT || "3000");
356
- const host = process.env.HOST || "0.0.0.0";
374
+ const host = process.env.HOST || "127.0.0.1";
357
375
  if (useHttp) {
358
376
  console.error(`[functype-mcp] Starting HTTP server on ${host}:${port}`);
359
377
  await server.start({
@@ -374,6 +392,6 @@ process.on("SIGINT", () => process.exit(0));
374
392
  process.on("SIGTERM", () => process.exit(0));
375
393
  main().catch(console.error);
376
394
  //#endregion
377
- export {};
395
+ export { isSafeFunctypeVersion };
378
396
 
379
397
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["require"],"sources":["../src/lib/docs/data.ts","../src/lib/docs/formatters.ts","../src/lib/validator/compiler-host.ts","../src/lib/validator/validate.ts","../src/index.ts"],"sourcesContent":["/**\n * Runtime loader for functype CLI data.\n * Uses dynamic import so the data reflects whichever functype version\n * is installed in node_modules at runtime (not baked in at build time).\n */\n\nimport { createRequire } from \"node:module\"\nimport { pathToFileURL } from \"node:url\"\n\nexport type { InterfaceData, TypeData } from \"functype/cli\"\nimport type { InterfaceData, TypeData } from \"functype/cli\"\n\nconst require = createRequire(import.meta.url)\n\nexport let TYPES: Record<string, TypeData> = {}\nexport let INTERFACES: Record<string, InterfaceData> = {}\nexport let CATEGORIES: Record<string, string[]> = {}\nexport let FULL_INTERFACES: Record<string, string> = {}\nexport let VERSION = \"unknown\"\n\nlet initialized = false\n\nexport async function initDocsData(force?: boolean): Promise<void> {\n if (initialized && !force) return\n\n try {\n let cli: typeof import(\"functype/cli\")\n if (force) {\n const resolvedPath = require.resolve(\"functype/cli\")\n cli = await import(`${pathToFileURL(resolvedPath).href}?t=${Date.now()}`)\n } else {\n cli = await import(\"functype/cli\")\n }\n TYPES = cli.TYPES\n INTERFACES = cli.INTERFACES\n CATEGORIES = cli.CATEGORIES\n FULL_INTERFACES = cli.FULL_INTERFACES\n VERSION = cli.VERSION\n initialized = true\n } catch (err) {\n if (force) throw err\n console.error(\"[functype-mcp] Failed to load functype/cli data — doc tools will return empty results:\", err)\n }\n}\n","/**\n * Markdown formatters for MCP tool output.\n * Plain TypeScript — no functype dependency in formatters.\n */\n\nimport type { InterfaceData, TypeData } from \"./data\"\nimport { CATEGORIES, FULL_INTERFACES, INTERFACES, TYPES, VERSION } from \"./data\"\n\nconst METHOD_CATEGORIES = [\"create\", \"transform\", \"extract\", \"check\", \"other\"] as const\n\nexport const formatOverview = (): string => {\n const lines: string[] = [`# functype ${VERSION} — Scala-inspired FP for TypeScript`, \"\"]\n\n for (const [category, typeNames] of Object.entries(CATEGORIES)) {\n lines.push(`## ${category}`, \"\")\n for (const name of typeNames) {\n const type = TYPES[name]\n if (type) {\n const ifaces = type.interfaces.length > 0 ? ` [${type.interfaces.join(\", \")}]` : \"\"\n lines.push(`**${name}**${ifaces}`)\n lines.push(` ${type.description}`, \"\")\n }\n }\n }\n\n lines.push(\"---\", \"Use `get_type_api` for detailed type reference.\", \"Use `get_interfaces` for interface hierarchy.\")\n return lines.join(\"\\n\")\n}\n\nexport const formatType = (name: string, data: TypeData, includeFullInterface?: boolean): string => {\n const ifaceList = data.interfaces.length > 0 ? ` [${data.interfaces.join(\", \")}]` : \"\"\n const lines: string[] = [`# ${name}<T>${ifaceList}`, \"\", data.description, \"\"]\n\n for (const cat of METHOD_CATEGORIES) {\n const methods = data.methods[cat]\n if (methods && methods.length > 0) {\n lines.push(`## ${cat.charAt(0).toUpperCase() + cat.slice(1)}`, \"\")\n for (const method of methods) {\n lines.push(`- \\`${method}\\``)\n }\n lines.push(\"\")\n }\n }\n\n if (includeFullInterface) {\n const fullInterface = FULL_INTERFACES[name]\n if (fullInterface) {\n lines.push(\"## Full Interface\", \"\", \"```typescript\", fullInterface, \"```\")\n }\n }\n\n return lines.join(\"\\n\").trimEnd()\n}\n\nexport const formatInterfaces = (): string => {\n const lines: string[] = [\"# Interfaces\", \"\"]\n\n for (const [name, data] of Object.entries(INTERFACES)) {\n const ext = data.extends ? ` extends ${data.extends}` : \"\"\n lines.push(`## ${name}<A>${ext}`, \"\", data.description, \"\")\n for (const method of data.methods) {\n lines.push(`- \\`${method}\\``)\n }\n lines.push(\"\")\n }\n\n return lines.join(\"\\n\").trimEnd()\n}\n\nexport const searchTypes = (query: string): string => {\n const q = query.toLowerCase()\n\n // Check for exact type name match first (case-sensitive, e.g. \"IO\", \"Map\", \"Option\")\n const exactMatch = TYPES[query]\n if (exactMatch) {\n return formatType(query, exactMatch)\n }\n\n const matches: Array<{ name: string; data: TypeData }> = []\n\n for (const [name, data] of Object.entries(TYPES)) {\n const nameMatch = name.toLowerCase().includes(q)\n const descMatch = data.description.toLowerCase().includes(q)\n const ifaceMatch = data.interfaces.some((i) => i.toLowerCase().includes(q))\n const methodMatch = Object.values(data.methods)\n .flat()\n .some((m) => m.toLowerCase().includes(q))\n\n if (nameMatch || descMatch || ifaceMatch || methodMatch) {\n matches.push({ name, data })\n }\n }\n\n if (matches.length === 0) {\n return `No types found matching \"${query}\". Available types: ${Object.keys(TYPES).join(\", \")}`\n }\n\n if (matches.length === 1) {\n const match = matches[0]!\n return formatType(match.name, match.data)\n }\n\n // Prioritize name matches over description/method substring matches\n const nameMatches = matches.filter((m) => m.name.toLowerCase().includes(q))\n const otherMatches = matches.filter((m) => !m.name.toLowerCase().includes(q))\n const sorted = [...nameMatches, ...otherMatches]\n\n const lines: string[] = [`# Search results for \"${query}\"`, \"\", `Found ${sorted.length} matching types:`, \"\"]\n for (const match of sorted) {\n const ifaces = match.data.interfaces.length > 0 ? ` [${match.data.interfaces.join(\", \")}]` : \"\"\n lines.push(`**${match.name}**${ifaces}`)\n lines.push(` ${match.data.description}`, \"\")\n }\n\n lines.push(\"---\", \"Use `get_type_api` with a specific type name for full details.\")\n return lines.join(\"\\n\")\n}\n\nexport const getTypeByName = (name: string): { name: string; data: TypeData } | undefined => {\n const direct = TYPES[name]\n if (direct) return { name, data: direct }\n\n const entry = Object.entries(TYPES).find(([typeName]) => typeName.toLowerCase() === name.toLowerCase())\n if (entry) return { name: entry[0], data: entry[1] }\n\n return undefined\n}\n\nexport const getInterfaceByName = (name: string): { name: string; data: InterfaceData } | undefined => {\n const direct = INTERFACES[name]\n if (direct) return { name, data: direct }\n\n const entry = Object.entries(INTERFACES).find(([ifaceName]) => ifaceName.toLowerCase() === name.toLowerCase())\n if (entry) return { name: entry[0], data: entry[1] }\n\n return undefined\n}\n","/**\n * Custom TypeScript CompilerHost for in-memory type-checking of functype code.\n * Resolves functype .d.ts files from node_modules for accurate type validation.\n */\n\nimport { readFileSync } from \"node:fs\"\nimport { createRequire } from \"node:module\"\nimport { dirname, join, resolve } from \"node:path\"\n\nimport ts from \"typescript\"\n\nconst require = createRequire(import.meta.url)\n\nconst resolveFunctypeDistDir = (): string => {\n // Resolve the main entry point, then walk up to find the dist dir\n const functypeMain = require.resolve(\"functype\")\n // functypeMain is something like .../node_modules/functype/dist/index.js\n // Walk up until we find a directory containing package.json\n let dir = dirname(functypeMain)\n for (let i = 0; i < 5; i++) {\n try {\n readFileSync(join(dir, \"package.json\"), \"utf-8\")\n return join(dir, \"dist\")\n } catch {\n dir = dirname(dir)\n }\n }\n // Fallback: assume dist is sibling to main\n return dirname(functypeMain)\n}\n\nconst fileCache = new Map<string, string | undefined>()\n\nexport const clearFileCache = (): void => {\n fileCache.clear()\n}\n\nconst readFileCached = (path: string): string | undefined => {\n if (fileCache.has(path)) return fileCache.get(path)\n try {\n const content = readFileSync(path, \"utf-8\")\n fileCache.set(path, content)\n return content\n } catch {\n fileCache.set(path, undefined)\n return undefined\n }\n}\n\nexport const VIRTUAL_FILENAME = \"/__functype_validate__.ts\"\n\nexport const compilerOptions: ts.CompilerOptions = {\n strict: true,\n target: ts.ScriptTarget.ES2020,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n noEmit: true,\n noUncheckedIndexedAccess: true,\n skipLibCheck: true,\n esModuleInterop: true,\n allowSyntheticDefaultImports: true,\n declaration: false,\n sourceMap: false,\n}\n\nexport const createCompilerHost = (sourceCode: string): ts.CompilerHost => {\n const functypeDistDir = resolveFunctypeDistDir()\n const defaultHost = ts.createCompilerHost(compilerOptions)\n\n const host: ts.CompilerHost = {\n ...defaultHost,\n\n getSourceFile(fileName, languageVersion) {\n if (fileName === VIRTUAL_FILENAME) {\n return ts.createSourceFile(fileName, sourceCode, languageVersion, true)\n }\n return defaultHost.getSourceFile(fileName, languageVersion)\n },\n\n fileExists(fileName) {\n if (fileName === VIRTUAL_FILENAME) return true\n return defaultHost.fileExists(fileName)\n },\n\n readFile(fileName) {\n if (fileName === VIRTUAL_FILENAME) return sourceCode\n return readFileCached(fileName) ?? defaultHost.readFile(fileName)\n },\n\n resolveModuleNames(moduleNames, containingFile) {\n return moduleNames.map((moduleName): ts.ResolvedModule | undefined => {\n if (moduleName === \"functype\" || moduleName.startsWith(\"functype/\")) {\n const subpath = moduleName === \"functype\" ? \"index.d.ts\" : moduleName.replace(\"functype/\", \"\") + \".d.ts\"\n const resolvedFileName = resolve(functypeDistDir, subpath)\n if (readFileCached(resolvedFileName) !== undefined) {\n return { resolvedFileName, isExternalLibraryImport: true }\n }\n // Try with /index.d.ts for subpath modules\n const indexPath = resolve(functypeDistDir, subpath.replace(\".d.ts\", \"/index.d.ts\"))\n if (readFileCached(indexPath) !== undefined) {\n return { resolvedFileName: indexPath, isExternalLibraryImport: true }\n }\n return undefined\n }\n\n const result = ts.resolveModuleName(moduleName, containingFile, compilerOptions, defaultHost)\n return result.resolvedModule\n })\n },\n }\n\n return host\n}\n","/**\n * Core validation function — type-checks functype code snippets using the TypeScript Compiler API.\n */\n\nimport ts from \"typescript\"\n\nimport { compilerOptions, createCompilerHost, VIRTUAL_FILENAME } from \"./compiler-host\"\nimport type { ValidateOptions, ValidationDiagnostic, ValidationResult } from \"./types\"\n\nconst DEFAULT_IMPORTS = `import { Option, Some, None, Either, Right, Left, Try, List, Set, Map, Lazy, LazyList, Task, IO, Cond, Match, Brand, ValidatedBrand, Tuple, Stack, Ok, Err } from \"functype\"\\n`\n\nconst hasFunctypeImport = (code: string): boolean => /from\\s+[\"']functype(?:\\/[^\"']*)?[\"']/.test(code)\n\nexport const validateCode = (code: string, options: ValidateOptions = {}): ValidationResult => {\n const autoImport = options.autoImport ?? true\n const shouldPrepend = autoImport && !hasFunctypeImport(code)\n const importLineCount = shouldPrepend ? 1 : 0\n const fullCode = shouldPrepend ? DEFAULT_IMPORTS + code : code\n\n const host = createCompilerHost(fullCode)\n const program = ts.createProgram([VIRTUAL_FILENAME], compilerOptions, host)\n const allDiagnostics = ts.getPreEmitDiagnostics(program)\n\n const fileDiagnostics = allDiagnostics.filter((d) => d.file?.fileName === VIRTUAL_FILENAME)\n\n const rawDiagnostics = fileDiagnostics.map((d) => {\n const { line, character } = d.file!.getLineAndCharacterOfPosition(d.start ?? 0)\n return {\n originalLine: line,\n line: line - importLineCount + 1,\n column: character + 1,\n message: ts.flattenDiagnosticMessageText(d.messageText, \"\\n\"),\n code: d.code,\n severity: (d.category === ts.DiagnosticCategory.Error ? \"error\" : \"warning\") as \"error\" | \"warning\",\n }\n })\n\n // Filter out diagnostics from the prepended import line(s) and map to final type\n const userDiagnostics: ValidationDiagnostic[] = rawDiagnostics\n .filter((d) => !shouldPrepend || d.originalLine >= importLineCount)\n .map(({ originalLine: _, ...rest }) => rest)\n\n return {\n success: userDiagnostics.filter((d) => d.severity === \"error\").length === 0,\n diagnostics: userDiagnostics,\n importsPrepended: shouldPrepend,\n }\n}\n","import { execFileSync } from \"node:child_process\"\nimport { dirname } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport { FastMCP } from \"fastmcp\"\nimport { z } from \"zod\"\n\nimport { initDocsData, TYPES, VERSION } from \"./lib/docs/data\"\nimport { formatInterfaces, formatOverview, formatType, getTypeByName, searchTypes } from \"./lib/docs/formatters\"\nimport { clearFileCache } from \"./lib/validator/compiler-host\"\nimport { validateCode } from \"./lib/validator/validate\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\nconst PROJECT_ROOT = dirname(__dirname)\n\ndeclare const __VERSION__: string\nconst SERVER_VERSION = (\n typeof __VERSION__ !== \"undefined\" ? __VERSION__ : \"0.0.0-dev\"\n) as `${number}.${number}.${number}`\n\nfunction createServer() {\n const server = new FastMCP({\n name: \"functype-mcp-server\",\n version: SERVER_VERSION,\n instructions: `Functype MCP Server — documentation lookup and code validation for the functype TypeScript FP library (v${VERSION}).\n\nAvailable tools:\n- search_docs: Search functype documentation by keyword or type name\n- get_type_api: Get detailed API reference for a specific type\n- get_interfaces: Get the interface hierarchy (Functor, Monad, Foldable, etc.)\n- validate_code: Type-check functype code snippets at compile time\n- set_functype_version: Switch the functype version at runtime (installs + reloads)\n\nUse validate_code to verify your functype code is type-correct before presenting it to the user.`,\n })\n\n server.addTool({\n name: \"search_docs\",\n description:\n \"Search functype documentation by keyword or type name. Omit query for a full overview of all types and categories.\",\n parameters: z.object({\n query: z.string().optional().describe(\"Type name or keyword to search for. Omit for full overview.\"),\n }),\n execute: async (args) => {\n if (!args.query || args.query.trim() === \"\") {\n return formatOverview()\n }\n return searchTypes(args.query)\n },\n })\n\n server.addTool({\n name: \"get_type_api\",\n description:\n \"Get detailed API reference for a specific functype type including methods by category and optionally the full TypeScript interface definition.\",\n parameters: z.object({\n type_name: z.string().describe(\"The type name (e.g., Option, Either, List, IO)\"),\n include_full_interface: z\n .boolean()\n .optional()\n .default(false)\n .describe(\"Include full TypeScript interface definition\"),\n }),\n execute: async (args) => {\n const found = getTypeByName(args.type_name)\n if (!found) {\n // Show TYPES keys (the curated source) — that's what get_type_api\n // can actually answer. FULL_INTERFACES keys were the previous source\n // and produced a misleading list (some entries had no detailed data\n // and would fail lookup).\n const available = Object.keys(TYPES).sort().join(\", \")\n return `Type \"${args.type_name}\" not found. Available types: ${available}`\n }\n return formatType(found.name, found.data, args.include_full_interface)\n },\n })\n\n server.addTool({\n name: \"get_interfaces\",\n description:\n \"Get the functype interface hierarchy — Functor, Monad, Foldable, Extractable, Matchable, etc. — with their methods and inheritance.\",\n parameters: z.object({}),\n execute: async () => {\n return formatInterfaces()\n },\n })\n\n server.addTool({\n name: \"validate_code\",\n description:\n \"Type-check a functype code snippet using the TypeScript compiler. Returns PASSED or a list of type errors with line/column/message. Use this to verify functype code is type-correct before presenting to users.\",\n parameters: z.object({\n code: z.string().describe(\"TypeScript code snippet using functype to type-check\"),\n auto_import: z\n .boolean()\n .optional()\n .default(true)\n .describe(\"Automatically import all functype types if no import statement is present. Default: true\"),\n }),\n execute: async (args) => {\n const result = validateCode(args.code, { autoImport: args.auto_import })\n\n if (result.success) {\n const importNote = result.importsPrepended ? \" (functype imports auto-added)\" : \"\"\n return `Validation PASSED${importNote}\\n\\nThe code is type-correct.`\n }\n\n const errorLines = result.diagnostics.map((d) => `- Line ${d.line}, Col ${d.column}: ${d.message} (TS${d.code})`)\n const importNote = result.importsPrepended ? \"\\n\\nNote: functype imports were auto-added.\" : \"\"\n\n return `Validation FAILED — ${result.diagnostics.length} error(s):\\n\\n${errorLines.join(\"\\n\")}${importNote}`\n },\n })\n\n server.addTool({\n name: \"set_functype_version\",\n description:\n \"Switch the functype version at runtime. Installs the specified version and reloads all documentation and type definitions.\",\n parameters: z.object({\n version: z.string().describe('The functype version to install (e.g., \"0.46.0\", \"latest\", \"^0.45.0\")'),\n }),\n execute: async (args) => {\n const spec = `functype@${args.version}`\n try {\n execFileSync(\"pnpm\", [\"add\", spec], { cwd: PROJECT_ROOT, stdio: \"pipe\", timeout: 60_000 })\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n return `Failed to install ${spec}: ${message}`\n }\n\n clearFileCache()\n\n try {\n await initDocsData(true)\n } catch {\n return `Installed ${spec}, but this version does not export functype/cli. Documentation and type definitions are unavailable. The validator will still use the installed version's .d.ts files. Consider using functype >= 0.47.0 for full MCP support.`\n }\n\n return `Switched to functype v${VERSION}. Documentation and type definitions have been reloaded.`\n },\n })\n\n return server\n}\n\nasync function main() {\n await initDocsData()\n\n const server = createServer()\n\n const useHttp = process.env.TRANSPORT_TYPE === \"httpStream\" || process.env.TRANSPORT_TYPE === \"http\"\n const port = parseInt(process.env.PORT || \"3000\")\n const host = process.env.HOST || \"0.0.0.0\"\n\n if (useHttp) {\n console.error(`[functype-mcp] Starting HTTP server on ${host}:${port}`)\n await server.start({\n transportType: \"httpStream\",\n httpStream: { port, host, endpoint: \"/mcp\" },\n })\n console.error(`[functype-mcp] HTTP server ready at http://${host}:${port}/mcp`)\n } else {\n console.error(\"[functype-mcp] Starting in stdio mode\")\n await server.start({ transportType: \"stdio\" })\n }\n}\n\nprocess.on(\"SIGINT\", () => process.exit(0))\nprocess.on(\"SIGTERM\", () => process.exit(0))\n\nmain().catch(console.error)\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAMA,YAAU,cAAc,OAAO,KAAK,GAAG;AAE7C,IAAW,QAAkC,CAAC;AAC9C,IAAW,aAA4C,CAAC;AACxD,IAAW,aAAuC,CAAC;AACnD,IAAW,kBAA0C,CAAC;AACtD,IAAW,UAAU;AAErB,IAAI,cAAc;AAElB,eAAsB,aAAa,OAAgC;CACjE,IAAI,eAAe,CAAC,OAAO;CAE3B,IAAI;EACF,IAAI;EACJ,IAAI,OAEF,MAAM,MAAM,OAAO,GAAG,cADDA,UAAQ,QAAQ,cACU,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI;OAErE,MAAM,MAAM,OAAO;EAErB,QAAQ,IAAI;EACZ,aAAa,IAAI;EACjB,aAAa,IAAI;EACjB,kBAAkB,IAAI;EACtB,UAAU,IAAI;EACd,cAAc;CAChB,SAAS,KAAK;EACZ,IAAI,OAAO,MAAM;EACjB,QAAQ,MAAM,0FAA0F,GAAG;CAC7G;AACF;;;ACnCA,MAAM,oBAAoB;CAAC;CAAU;CAAa;CAAW;CAAS;AAAO;AAE7E,MAAa,uBAA+B;CAC1C,MAAM,QAAkB,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Q;CAEjC,IAAI,SAAS;EACX,QAAQ,MAAM,0CAA0C,KAAK,GAAG,MAAM;EACtE,MAAM,OAAO,MAAM;GACjB,eAAe;GACf,YAAY;IAAE;IAAM;IAAM,UAAU;GAAO;EAC7C,CAAC;EACD,QAAQ,MAAM,8CAA8C,KAAK,GAAG,KAAK,KAAK;CAChF,OAAO;EACL,QAAQ,MAAM,uCAAuC;EACrD,MAAM,OAAO,MAAM,EAAE,eAAe,QAAQ,CAAC;CAC/C;AACF;AAEA,QAAQ,GAAG,gBAAgB,QAAQ,KAAK,CAAC,CAAC;AAC1C,QAAQ,GAAG,iBAAiB,QAAQ,KAAK,CAAC,CAAC;AAE3C,KAAK,CAAC,CAAC,MAAM,QAAQ,KAAK"}
1
+ {"version":3,"file":"index.js","names":["require"],"sources":["../src/lib/docs/data.ts","../src/lib/docs/formatters.ts","../src/lib/validator/compiler-host.ts","../src/lib/validator/validate.ts","../src/index.ts"],"sourcesContent":["/**\n * Runtime loader for functype CLI data.\n * Uses dynamic import so the data reflects whichever functype version\n * is installed in node_modules at runtime (not baked in at build time).\n */\n\nimport { createRequire } from \"node:module\"\nimport { pathToFileURL } from \"node:url\"\n\nexport type { InterfaceData, TypeData } from \"functype/cli\"\nimport type { InterfaceData, TypeData } from \"functype/cli\"\n\nconst require = createRequire(import.meta.url)\n\nexport let TYPES: Record<string, TypeData> = {}\nexport let INTERFACES: Record<string, InterfaceData> = {}\nexport let CATEGORIES: Record<string, string[]> = {}\nexport let FULL_INTERFACES: Record<string, string> = {}\nexport let VERSION = \"unknown\"\n\nlet initialized = false\n\nexport async function initDocsData(force?: boolean): Promise<void> {\n if (initialized && !force) return\n\n try {\n let cli: typeof import(\"functype/cli\")\n if (force) {\n const resolvedPath = require.resolve(\"functype/cli\")\n cli = await import(`${pathToFileURL(resolvedPath).href}?t=${Date.now()}`)\n } else {\n cli = await import(\"functype/cli\")\n }\n TYPES = cli.TYPES\n INTERFACES = cli.INTERFACES\n CATEGORIES = cli.CATEGORIES\n FULL_INTERFACES = cli.FULL_INTERFACES\n VERSION = cli.VERSION\n initialized = true\n } catch (err) {\n if (force) throw err\n console.error(\"[functype-mcp] Failed to load functype/cli data — doc tools will return empty results:\", err)\n }\n}\n","/**\n * Markdown formatters for MCP tool output.\n * Plain TypeScript — no functype dependency in formatters.\n */\n\nimport type { InterfaceData, TypeData } from \"./data\"\nimport { CATEGORIES, FULL_INTERFACES, INTERFACES, TYPES, VERSION } from \"./data\"\n\nconst METHOD_CATEGORIES = [\"create\", \"transform\", \"extract\", \"check\", \"other\"] as const\n\nexport const formatOverview = (): string => {\n const lines: string[] = [`# functype ${VERSION} — Scala-inspired FP for TypeScript`, \"\"]\n\n for (const [category, typeNames] of Object.entries(CATEGORIES)) {\n lines.push(`## ${category}`, \"\")\n for (const name of typeNames) {\n const type = TYPES[name]\n if (type) {\n const ifaces = type.interfaces.length > 0 ? ` [${type.interfaces.join(\", \")}]` : \"\"\n lines.push(`**${name}**${ifaces}`)\n lines.push(` ${type.description}`, \"\")\n }\n }\n }\n\n lines.push(\"---\", \"Use `get_type_api` for detailed type reference.\", \"Use `get_interfaces` for interface hierarchy.\")\n return lines.join(\"\\n\")\n}\n\nexport const formatType = (name: string, data: TypeData, includeFullInterface?: boolean): string => {\n const ifaceList = data.interfaces.length > 0 ? ` [${data.interfaces.join(\", \")}]` : \"\"\n const lines: string[] = [`# ${name}<T>${ifaceList}`, \"\", data.description, \"\"]\n\n for (const cat of METHOD_CATEGORIES) {\n const methods = data.methods[cat]\n if (methods && methods.length > 0) {\n lines.push(`## ${cat.charAt(0).toUpperCase() + cat.slice(1)}`, \"\")\n for (const method of methods) {\n lines.push(`- \\`${method}\\``)\n }\n lines.push(\"\")\n }\n }\n\n if (includeFullInterface) {\n const fullInterface = FULL_INTERFACES[name]\n if (fullInterface) {\n lines.push(\"## Full Interface\", \"\", \"```typescript\", fullInterface, \"```\")\n }\n }\n\n return lines.join(\"\\n\").trimEnd()\n}\n\nexport const formatInterfaces = (): string => {\n const lines: string[] = [\"# Interfaces\", \"\"]\n\n for (const [name, data] of Object.entries(INTERFACES)) {\n const ext = data.extends ? ` extends ${data.extends}` : \"\"\n lines.push(`## ${name}<A>${ext}`, \"\", data.description, \"\")\n for (const method of data.methods) {\n lines.push(`- \\`${method}\\``)\n }\n lines.push(\"\")\n }\n\n return lines.join(\"\\n\").trimEnd()\n}\n\nexport const searchTypes = (query: string): string => {\n const q = query.toLowerCase()\n\n // Check for exact type name match first (case-sensitive, e.g. \"IO\", \"Map\", \"Option\")\n const exactMatch = TYPES[query]\n if (exactMatch) {\n return formatType(query, exactMatch)\n }\n\n const matches: Array<{ name: string; data: TypeData }> = []\n\n for (const [name, data] of Object.entries(TYPES)) {\n const nameMatch = name.toLowerCase().includes(q)\n const descMatch = data.description.toLowerCase().includes(q)\n const ifaceMatch = data.interfaces.some((i) => i.toLowerCase().includes(q))\n const methodMatch = Object.values(data.methods)\n .flat()\n .some((m) => m.toLowerCase().includes(q))\n\n if (nameMatch || descMatch || ifaceMatch || methodMatch) {\n matches.push({ name, data })\n }\n }\n\n if (matches.length === 0) {\n return `No types found matching \"${query}\". Available types: ${Object.keys(TYPES).join(\", \")}`\n }\n\n if (matches.length === 1) {\n const match = matches[0]!\n return formatType(match.name, match.data)\n }\n\n // Prioritize name matches over description/method substring matches\n const nameMatches = matches.filter((m) => m.name.toLowerCase().includes(q))\n const otherMatches = matches.filter((m) => !m.name.toLowerCase().includes(q))\n const sorted = [...nameMatches, ...otherMatches]\n\n const lines: string[] = [`# Search results for \"${query}\"`, \"\", `Found ${sorted.length} matching types:`, \"\"]\n for (const match of sorted) {\n const ifaces = match.data.interfaces.length > 0 ? ` [${match.data.interfaces.join(\", \")}]` : \"\"\n lines.push(`**${match.name}**${ifaces}`)\n lines.push(` ${match.data.description}`, \"\")\n }\n\n lines.push(\"---\", \"Use `get_type_api` with a specific type name for full details.\")\n return lines.join(\"\\n\")\n}\n\nexport const getTypeByName = (name: string): { name: string; data: TypeData } | undefined => {\n const direct = TYPES[name]\n if (direct) return { name, data: direct }\n\n const entry = Object.entries(TYPES).find(([typeName]) => typeName.toLowerCase() === name.toLowerCase())\n if (entry) return { name: entry[0], data: entry[1] }\n\n return undefined\n}\n\nexport const getInterfaceByName = (name: string): { name: string; data: InterfaceData } | undefined => {\n const direct = INTERFACES[name]\n if (direct) return { name, data: direct }\n\n const entry = Object.entries(INTERFACES).find(([ifaceName]) => ifaceName.toLowerCase() === name.toLowerCase())\n if (entry) return { name: entry[0], data: entry[1] }\n\n return undefined\n}\n","/**\n * Custom TypeScript CompilerHost for in-memory type-checking of functype code.\n * Resolves functype .d.ts files from node_modules for accurate type validation.\n */\n\nimport { readFileSync } from \"node:fs\"\nimport { createRequire } from \"node:module\"\nimport { dirname, join, resolve } from \"node:path\"\n\nimport ts from \"typescript\"\n\nconst require = createRequire(import.meta.url)\n\nconst resolveFunctypeDistDir = (): string => {\n // Resolve the main entry point, then walk up to find the dist dir\n const functypeMain = require.resolve(\"functype\")\n // functypeMain is something like .../node_modules/functype/dist/index.js\n // Walk up until we find a directory containing package.json\n let dir = dirname(functypeMain)\n for (let i = 0; i < 5; i++) {\n try {\n readFileSync(join(dir, \"package.json\"), \"utf-8\")\n return join(dir, \"dist\")\n } catch {\n dir = dirname(dir)\n }\n }\n // Fallback: assume dist is sibling to main\n return dirname(functypeMain)\n}\n\nconst fileCache = new Map<string, string | undefined>()\n\nexport const clearFileCache = (): void => {\n fileCache.clear()\n}\n\nconst readFileCached = (path: string): string | undefined => {\n if (fileCache.has(path)) return fileCache.get(path)\n try {\n const content = readFileSync(path, \"utf-8\")\n fileCache.set(path, content)\n return content\n } catch {\n fileCache.set(path, undefined)\n return undefined\n }\n}\n\nexport const VIRTUAL_FILENAME = \"/__functype_validate__.ts\"\n\nexport const compilerOptions: ts.CompilerOptions = {\n strict: true,\n target: ts.ScriptTarget.ES2020,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n noEmit: true,\n noUncheckedIndexedAccess: true,\n skipLibCheck: true,\n esModuleInterop: true,\n allowSyntheticDefaultImports: true,\n declaration: false,\n sourceMap: false,\n}\n\nexport const createCompilerHost = (sourceCode: string): ts.CompilerHost => {\n const functypeDistDir = resolveFunctypeDistDir()\n const defaultHost = ts.createCompilerHost(compilerOptions)\n\n const host: ts.CompilerHost = {\n ...defaultHost,\n\n getSourceFile(fileName, languageVersion) {\n if (fileName === VIRTUAL_FILENAME) {\n return ts.createSourceFile(fileName, sourceCode, languageVersion, true)\n }\n return defaultHost.getSourceFile(fileName, languageVersion)\n },\n\n fileExists(fileName) {\n if (fileName === VIRTUAL_FILENAME) return true\n return defaultHost.fileExists(fileName)\n },\n\n readFile(fileName) {\n if (fileName === VIRTUAL_FILENAME) return sourceCode\n return readFileCached(fileName) ?? defaultHost.readFile(fileName)\n },\n\n resolveModuleNames(moduleNames, containingFile) {\n return moduleNames.map((moduleName): ts.ResolvedModule | undefined => {\n if (moduleName === \"functype\" || moduleName.startsWith(\"functype/\")) {\n const subpath = moduleName === \"functype\" ? \"index.d.ts\" : moduleName.replace(\"functype/\", \"\") + \".d.ts\"\n const resolvedFileName = resolve(functypeDistDir, subpath)\n if (readFileCached(resolvedFileName) !== undefined) {\n return { resolvedFileName, isExternalLibraryImport: true }\n }\n // Try with /index.d.ts for subpath modules\n const indexPath = resolve(functypeDistDir, subpath.replace(\".d.ts\", \"/index.d.ts\"))\n if (readFileCached(indexPath) !== undefined) {\n return { resolvedFileName: indexPath, isExternalLibraryImport: true }\n }\n return undefined\n }\n\n const result = ts.resolveModuleName(moduleName, containingFile, compilerOptions, defaultHost)\n return result.resolvedModule\n })\n },\n }\n\n return host\n}\n","/**\n * Core validation function — type-checks functype code snippets using the TypeScript Compiler API.\n */\n\nimport ts from \"typescript\"\n\nimport { compilerOptions, createCompilerHost, VIRTUAL_FILENAME } from \"./compiler-host\"\nimport type { ValidateOptions, ValidationDiagnostic, ValidationResult } from \"./types\"\n\nconst DEFAULT_IMPORTS = `import { Option, Some, None, Either, Right, Left, Try, List, Set, Map, Lazy, LazyList, Task, IO, Cond, Match, Brand, ValidatedBrand, Tuple, Stack, Ok, Err } from \"functype\"\\n`\n\nconst hasFunctypeImport = (code: string): boolean => /from\\s+[\"']functype(?:\\/[^\"']*)?[\"']/.test(code)\n\nexport const validateCode = (code: string, options: ValidateOptions = {}): ValidationResult => {\n const autoImport = options.autoImport ?? true\n const shouldPrepend = autoImport && !hasFunctypeImport(code)\n const importLineCount = shouldPrepend ? 1 : 0\n const fullCode = shouldPrepend ? DEFAULT_IMPORTS + code : code\n\n const host = createCompilerHost(fullCode)\n const program = ts.createProgram([VIRTUAL_FILENAME], compilerOptions, host)\n const allDiagnostics = ts.getPreEmitDiagnostics(program)\n\n const fileDiagnostics = allDiagnostics.filter((d) => d.file?.fileName === VIRTUAL_FILENAME)\n\n const rawDiagnostics = fileDiagnostics.map((d) => {\n const { line, character } = d.file!.getLineAndCharacterOfPosition(d.start ?? 0)\n return {\n originalLine: line,\n line: line - importLineCount + 1,\n column: character + 1,\n message: ts.flattenDiagnosticMessageText(d.messageText, \"\\n\"),\n code: d.code,\n severity: (d.category === ts.DiagnosticCategory.Error ? \"error\" : \"warning\") as \"error\" | \"warning\",\n }\n })\n\n // Filter out diagnostics from the prepended import line(s) and map to final type\n const userDiagnostics: ValidationDiagnostic[] = rawDiagnostics\n .filter((d) => !shouldPrepend || d.originalLine >= importLineCount)\n .map(({ originalLine: _, ...rest }) => rest)\n\n return {\n success: userDiagnostics.filter((d) => d.severity === \"error\").length === 0,\n diagnostics: userDiagnostics,\n importsPrepended: shouldPrepend,\n }\n}\n","import { execFileSync } from \"node:child_process\"\nimport { dirname } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport { FastMCP } from \"fastmcp\"\nimport { z } from \"zod\"\n\nimport { initDocsData, TYPES, VERSION } from \"./lib/docs/data\"\nimport { formatInterfaces, formatOverview, formatType, getTypeByName, searchTypes } from \"./lib/docs/formatters\"\nimport { clearFileCache } from \"./lib/validator/compiler-host\"\nimport { validateCode } from \"./lib/validator/validate\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\nconst PROJECT_ROOT = dirname(__dirname)\n\ndeclare const __VERSION__: string\nconst SERVER_VERSION = (\n typeof __VERSION__ !== \"undefined\" ? __VERSION__ : \"0.0.0-dev\"\n) as `${number}.${number}.${number}`\n\n// Accepts: dist-tags (latest|next|beta|alpha|canary|rc), and semver of the form\n// [~^]?v?N(.N(.N)?)? with optional prerelease + build metadata. Refuses anything\n// else — in particular pnpm/npm alias syntaxes (file:, git+, npm:, http(s):, …)\n// that would let an attacker install an arbitrary package as `functype`.\n// See GHSA-wcjj-9m6g-2fr2.\nconst SAFE_FUNCTYPE_VERSION =\n /^(?:latest|next|beta|alpha|canary|rc|[~^]?v?\\d+(?:\\.\\d+){0,2}(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?)$/\n\nexport const isSafeFunctypeVersion = (version: string): boolean => {\n if (version.trim() !== version) return false\n if (/[/:\\\\@\\s]/.test(version)) return false\n return SAFE_FUNCTYPE_VERSION.test(version)\n}\n\nconst isHttpTransport = (): boolean => {\n const t = process.env.TRANSPORT_TYPE\n return t === \"httpStream\" || t === \"http\"\n}\n\nfunction createServer() {\n // set_functype_version installs + dynamic-imports the requested package, so\n // it is a privileged tool. Only expose it on stdio, where the trust boundary\n // is the local user. Over HTTP, anyone who can reach the port could downgrade\n // the installed functype to a vulnerable version. See GHSA-wcjj-9m6g-2fr2.\n const exposeSetVersion = !isHttpTransport()\n\n const toolList = [\n \"- search_docs: Search functype documentation by keyword or type name\",\n \"- get_type_api: Get detailed API reference for a specific type\",\n \"- get_interfaces: Get the interface hierarchy (Functor, Monad, Foldable, etc.)\",\n \"- validate_code: Type-check functype code snippets at compile time\",\n ...(exposeSetVersion\n ? [\"- set_functype_version: Switch the functype version at runtime (installs + reloads)\"]\n : []),\n ].join(\"\\n\")\n\n const server = new FastMCP({\n name: \"functype-mcp-server\",\n version: SERVER_VERSION,\n instructions: `Functype MCP Server — documentation lookup and code validation for the functype TypeScript FP library (v${VERSION}).\n\nAvailable tools:\n${toolList}\n\nUse validate_code to verify your functype code is type-correct before presenting it to the user.`,\n })\n\n server.addTool({\n name: \"search_docs\",\n description:\n \"Search functype documentation by keyword or type name. Omit query for a full overview of all types and categories.\",\n parameters: z.object({\n query: z.string().optional().describe(\"Type name or keyword to search for. Omit for full overview.\"),\n }),\n execute: async (args) => {\n if (!args.query || args.query.trim() === \"\") {\n return formatOverview()\n }\n return searchTypes(args.query)\n },\n })\n\n server.addTool({\n name: \"get_type_api\",\n description:\n \"Get detailed API reference for a specific functype type including methods by category and optionally the full TypeScript interface definition.\",\n parameters: z.object({\n type_name: z.string().describe(\"The type name (e.g., Option, Either, List, IO)\"),\n include_full_interface: z\n .boolean()\n .optional()\n .default(false)\n .describe(\"Include full TypeScript interface definition\"),\n }),\n execute: async (args) => {\n const found = getTypeByName(args.type_name)\n if (!found) {\n // Show TYPES keys (the curated source) — that's what get_type_api\n // can actually answer. FULL_INTERFACES keys were the previous source\n // and produced a misleading list (some entries had no detailed data\n // and would fail lookup).\n const available = Object.keys(TYPES).sort().join(\", \")\n return `Type \"${args.type_name}\" not found. Available types: ${available}`\n }\n return formatType(found.name, found.data, args.include_full_interface)\n },\n })\n\n server.addTool({\n name: \"get_interfaces\",\n description:\n \"Get the functype interface hierarchy — Functor, Monad, Foldable, Extractable, Matchable, etc. — with their methods and inheritance.\",\n parameters: z.object({}),\n execute: async () => {\n return formatInterfaces()\n },\n })\n\n server.addTool({\n name: \"validate_code\",\n description:\n \"Type-check a functype code snippet using the TypeScript compiler. Returns PASSED or a list of type errors with line/column/message. Use this to verify functype code is type-correct before presenting to users.\",\n parameters: z.object({\n code: z.string().describe(\"TypeScript code snippet using functype to type-check\"),\n auto_import: z\n .boolean()\n .optional()\n .default(true)\n .describe(\"Automatically import all functype types if no import statement is present. Default: true\"),\n }),\n execute: async (args) => {\n const result = validateCode(args.code, { autoImport: args.auto_import })\n\n if (result.success) {\n const importNote = result.importsPrepended ? \" (functype imports auto-added)\" : \"\"\n return `Validation PASSED${importNote}\\n\\nThe code is type-correct.`\n }\n\n const errorLines = result.diagnostics.map((d) => `- Line ${d.line}, Col ${d.column}: ${d.message} (TS${d.code})`)\n const importNote = result.importsPrepended ? \"\\n\\nNote: functype imports were auto-added.\" : \"\"\n\n return `Validation FAILED — ${result.diagnostics.length} error(s):\\n\\n${errorLines.join(\"\\n\")}${importNote}`\n },\n })\n\n if (exposeSetVersion) {\n server.addTool({\n name: \"set_functype_version\",\n description:\n \"Switch the functype version at runtime. Installs the specified version and reloads all documentation and type definitions. Stdio transport only.\",\n parameters: z.object({\n version: z.string().describe('The functype version to install (e.g., \"0.46.0\", \"latest\", \"^0.45.0\")'),\n }),\n execute: async (args) => {\n if (!isSafeFunctypeVersion(args.version)) {\n return `Invalid version \"${args.version}\". Use a semver string (e.g. \"1.4.4\", \"^1.4.0\", \"~1.4\") or a known dist-tag (latest, next, beta, alpha, canary, rc). Alias syntaxes (file:, npm:, git+, URLs) are not allowed.`\n }\n const spec = `functype@${args.version}`\n try {\n execFileSync(\"pnpm\", [\"add\", \"--ignore-scripts\", spec], {\n cwd: PROJECT_ROOT,\n stdio: \"pipe\",\n timeout: 60_000,\n })\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n return `Failed to install ${spec}: ${message}`\n }\n\n clearFileCache()\n\n try {\n await initDocsData(true)\n } catch {\n return `Installed ${spec}, but this version does not export functype/cli. Documentation and type definitions are unavailable. The validator will still use the installed version's .d.ts files. Consider using functype >= 0.47.0 for full MCP support.`\n }\n\n return `Switched to functype v${VERSION}. Documentation and type definitions have been reloaded.`\n },\n })\n }\n\n return server\n}\n\nasync function main() {\n await initDocsData()\n\n const server = createServer()\n\n const useHttp = isHttpTransport()\n const port = parseInt(process.env.PORT || \"3000\")\n // Default to loopback so an \"I just turned on httpStream\" doesn't silently\n // expose the server to the LAN. Set HOST=0.0.0.0 explicitly to bind public.\n const host = process.env.HOST || \"127.0.0.1\"\n\n if (useHttp) {\n console.error(`[functype-mcp] Starting HTTP server on ${host}:${port}`)\n await server.start({\n transportType: \"httpStream\",\n httpStream: { port, host, endpoint: \"/mcp\" },\n })\n console.error(`[functype-mcp] HTTP server ready at http://${host}:${port}/mcp`)\n } else {\n console.error(\"[functype-mcp] Starting in stdio mode\")\n await server.start({ transportType: \"stdio\" })\n }\n}\n\nprocess.on(\"SIGINT\", () => process.exit(0))\nprocess.on(\"SIGTERM\", () => process.exit(0))\n\nmain().catch(console.error)\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAMA,YAAU,cAAc,OAAO,KAAK,GAAG;AAE7C,IAAW,QAAkC,CAAC;AAC9C,IAAW,aAA4C,CAAC;AACxD,IAAW,aAAuC,CAAC;AACnD,IAAW,kBAA0C,CAAC;AACtD,IAAW,UAAU;AAErB,IAAI,cAAc;AAElB,eAAsB,aAAa,OAAgC;CACjE,IAAI,eAAe,CAAC,OAAO;CAE3B,IAAI;EACF,IAAI;EACJ,IAAI,OAEF,MAAM,MAAM,OAAO,GAAG,cADDA,UAAQ,QAAQ,cACU,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI;OAErE,MAAM,MAAM,OAAO;EAErB,QAAQ,IAAI;EACZ,aAAa,IAAI;EACjB,aAAa,IAAI;EACjB,kBAAkB,IAAI;EACtB,UAAU,IAAI;EACd,cAAc;CAChB,SAAS,KAAK;EACZ,IAAI,OAAO,MAAM;EACjB,QAAQ,MAAM,0FAA0F,GAAG;CAC7G;AACF;;;ACnCA,MAAM,oBAAoB;CAAC;CAAU;CAAa;CAAW;CAAS;AAAO;AAE7E,MAAa,uBAA+B;CAC1C,MAAM,QAAkB,CAAC,cAAc,QAAQ,sCAAsC,EAAE;CAEvF,KAAK,MAAM,CAAC,UAAU,cAAc,OAAO,QAAQ,UAAU,GAAG;EAC9D,MAAM,KAAK,MAAM,YAAY,EAAE;EAC/B,KAAK,MAAM,Q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I;GACzB,QAAQ;IACN,OAAO,aAAa,KAAK;GAC3B;GAEA,OAAO,yBAAyB,QAAQ;EAC1C;CACF,CAAC;CAGH,OAAO;AACT;AAEA,eAAe,OAAO;CACpB,MAAM,aAAa;CAEnB,MAAM,SAAS,aAAa;CAE5B,MAAM,UAAU,gBAAgB;CAChC,MAAM,OAAO,SAAS,QAAQ,IAAI,QAAQ,MAAM;CAGhD,MAAM,OAAO,QAAQ,IAAI,QAAQ;CAEjC,IAAI,SAAS;EACX,QAAQ,MAAM,0CAA0C,KAAK,GAAG,MAAM;EACtE,MAAM,OAAO,MAAM;GACjB,eAAe;GACf,YAAY;IAAE;IAAM;IAAM,UAAU;GAAO;EAC7C,CAAC;EACD,QAAQ,MAAM,8CAA8C,KAAK,GAAG,KAAK,KAAK;CAChF,OAAO;EACL,QAAQ,MAAM,uCAAuC;EACrD,MAAM,OAAO,MAAM,EAAE,eAAe,QAAQ,CAAC;CAC/C;AACF;AAEA,QAAQ,GAAG,gBAAgB,QAAQ,KAAK,CAAC,CAAC;AAC1C,QAAQ,GAAG,iBAAiB,QAAQ,KAAK,CAAC,CAAC;AAE3C,KAAK,CAAC,CAAC,MAAM,QAAQ,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype-mcp-server",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "description": "MCP server for functype documentation lookup and TypeScript code validation",
5
5
  "keywords": [
6
6
  "mcp",
@@ -45,15 +45,15 @@
45
45
  "LICENSE"
46
46
  ],
47
47
  "dependencies": {
48
- "fastmcp": "^4.3.0",
48
+ "fastmcp": "^4.3.1",
49
49
  "typescript": "^6.0.3",
50
50
  "zod": "^4.4.3",
51
- "functype": "1.4.3"
51
+ "functype": "1.5.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^24.13.2",
55
- "ts-builds": "^3.2.0",
56
- "tsdown": "^0.22.2",
55
+ "ts-builds": "^3.2.1",
56
+ "tsdown": "^0.22.3",
57
57
  "tsx": "^4.22.4"
58
58
  },
59
59
  "prettier": "ts-builds/prettier",