#!/usr/bin/env node
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));

// src/server.ts
var import_server = require("@modelcontextprotocol/sdk/server/index.js");
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
var import_types = require("@modelcontextprotocol/sdk/types.js");

// src/index.ts
var import_core = require("@voltagent/core");
var import_node_fs = __toESM(require("fs"), 1);
var import_node_path = __toESM(require("path"), 1);
var import_zod = require("zod");
var import_node_url = require("url");
var import_meta = {};
function getDirname() {
  try {
    return import_node_path.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
  } catch {
    return process.cwd();
  }
}
var __dirname = getDirname();
var packageRoot = import_node_path.default.resolve(__dirname, "..");
function getVoltAgentPaths() {
  return {
    docsPath: import_node_path.default.join(packageRoot, "docs"),
    examplesPath: import_node_path.default.join(packageRoot, "examples"),
    packagesPath: import_node_path.default.join(packageRoot, "packages"),
    workspaceRoot: packageRoot
  };
}
var searchDocumentationTool = new import_core.Tool({
  name: "search_voltagent_docs",
  description: "Search through VoltAgent documentation by topic or keyword. Returns relevant documentation content.",
  parameters: import_zod.z.object({
    query: import_zod.z.string().describe("The search query or topic to find in documentation"),
    section: import_zod.z.string().optional().describe(
      "Specific documentation section to search in (e.g., 'agents', 'tools', 'getting-started')"
    )
  }),
  execute: async ({ query, section }) => {
    try {
      const paths = getVoltAgentPaths();
      const searchResults = await searchDocumentation(paths.docsPath, query, section);
      if (searchResults.length === 0) {
        return {
          message: `No documentation found for query: "${query}"`,
          results: []
        };
      }
      return {
        message: `Found ${searchResults.length} documentation results for "${query}"`,
        results: searchResults
      };
    } catch (error) {
      return {
        error: `Failed to search documentation: ${error instanceof Error ? error.message : String(error)}`
      };
    }
  }
});
var getDocumentationTool = new import_core.Tool({
  name: "get_voltagent_doc",
  description: "Get the full content of a specific VoltAgent documentation file.",
  parameters: import_zod.z.object({
    filepath: import_zod.z.string().describe(
      "The relative path to the documentation file (e.g., 'agents/overview.md', 'getting-started/quick-start.md')"
    )
  }),
  execute: async ({ filepath }) => {
    try {
      const paths = getVoltAgentPaths();
      const docsPath = paths.docsPath;
      const fullPath = import_node_path.default.join(docsPath, filepath);
      if (!fullPath.startsWith(docsPath)) {
        return { error: "Invalid file path - access denied" };
      }
      if (!import_node_fs.default.existsSync(fullPath)) {
        return { error: `Documentation file not found: ${filepath}` };
      }
      const content = import_node_fs.default.readFileSync(fullPath, "utf-8");
      const stats = import_node_fs.default.statSync(fullPath);
      return {
        filepath,
        content,
        lastModified: stats.mtime.toISOString(),
        size: stats.size
      };
    } catch (error) {
      return {
        error: `Failed to read documentation: ${error instanceof Error ? error.message : String(error)}`
      };
    }
  }
});
var listDocumentationTool = new import_core.Tool({
  name: "list_voltagent_docs",
  description: "List all available VoltAgent documentation files and their structure.",
  parameters: import_zod.z.object({
    section: import_zod.z.string().optional().describe(
      "Specific section to list (e.g., 'agents', 'getting-started'). If not provided, lists all sections."
    )
  }),
  execute: async ({ section }) => {
    try {
      const paths = getVoltAgentPaths();
      const docsPath = paths.docsPath;
      const structure = await getDocumentationStructure(docsPath, section);
      return {
        message: section ? `Documentation structure for section: ${section}` : "Complete VoltAgent documentation structure",
        structure
      };
    } catch (error) {
      return {
        error: `Failed to list documentation: ${error instanceof Error ? error.message : String(error)}`
      };
    }
  }
});
var searchExamplesTool = new import_core.Tool({
  name: "search_voltagent_examples",
  description: "Search through VoltAgent examples by name, description, or technology used.",
  parameters: import_zod.z.object({
    query: import_zod.z.string().describe("The search query to find relevant examples"),
    technology: import_zod.z.string().optional().describe("Specific technology to filter by (e.g., 'nextjs', 'anthropic', 'supabase')")
  }),
  execute: async ({ query, technology }) => {
    try {
      const paths = getVoltAgentPaths();
      const examplesPath = paths.examplesPath;
      const searchResults = await searchExamples(examplesPath, query, technology);
      if (searchResults.length === 0) {
        return {
          message: `No examples found for query: "${query}"${technology ? ` with technology: ${technology}` : ""}`,
          results: []
        };
      }
      return {
        message: `Found ${searchResults.length} examples for "${query}"${technology ? ` with technology: ${technology}` : ""}`,
        results: searchResults
      };
    } catch (error) {
      return {
        error: `Failed to search examples: ${error instanceof Error ? error.message : String(error)}`
      };
    }
  }
});
var getExampleTool = new import_core.Tool({
  name: "get_voltagent_example",
  description: "Get the complete content and files of a specific VoltAgent example.",
  parameters: import_zod.z.object({
    exampleName: import_zod.z.string().describe("The name of the example directory (e.g., 'with-nextjs', 'with-anthropic')")
  }),
  execute: async ({ exampleName }) => {
    try {
      const paths = getVoltAgentPaths();
      const examplesPath = paths.examplesPath;
      const examplePath = import_node_path.default.join(examplesPath, exampleName);
      if (!import_node_fs.default.existsSync(examplePath)) {
        return { error: `Example not found: ${exampleName}` };
      }
      const exampleContent = await getExampleContent(examplePath);
      return {
        exampleName,
        ...exampleContent
      };
    } catch (error) {
      return {
        error: `Failed to get example: ${error instanceof Error ? error.message : String(error)}`
      };
    }
  }
});
var listExamplesTool = new import_core.Tool({
  name: "list_voltagent_examples",
  description: "List all available VoltAgent examples with their descriptions and technologies used.",
  parameters: import_zod.z.object({
    category: import_zod.z.string().optional().describe("Filter examples by category or technology (e.g., 'voice', 'ai', 'database')")
  }),
  execute: async ({ category }) => {
    try {
      const paths = getVoltAgentPaths();
      const examplesPath = paths.examplesPath;
      const examples = await listExamples(examplesPath, category);
      return {
        message: category ? `VoltAgent examples in category: ${category}` : "All available VoltAgent examples",
        totalCount: examples.length,
        examples
      };
    } catch (error) {
      return {
        error: `Failed to list examples: ${error instanceof Error ? error.message : String(error)}`
      };
    }
  }
});
var listChangelogsTool = new import_core.Tool({
  name: "list_voltagent_changelogs",
  description: "List all available VoltAgent package changelogs to check for bug fixes and updates.",
  parameters: import_zod.z.object({}),
  execute: async () => {
    try {
      const paths = getVoltAgentPaths();
      const changelogs = await listPackageChangelogs(paths.packagesPath);
      return {
        message: "Available VoltAgent package changelogs",
        totalCount: changelogs.length,
        changelogs
      };
    } catch (error) {
      return {
        error: `Failed to list changelogs: ${error instanceof Error ? error.message : String(error)}`
      };
    }
  }
});
var getChangelogTool = new import_core.Tool({
  name: "get_voltagent_changelog",
  description: "Get the changelog content for a specific VoltAgent package to check for bug fixes and recent updates.",
  parameters: import_zod.z.object({
    packageName: import_zod.z.string().describe("The name of the package (e.g., 'core', 'cli', 'voice', 'anthropic-ai')"),
    maxEntries: import_zod.z.number().optional().describe("Maximum number of changelog entries to return (default: 10)")
  }),
  execute: async ({
    packageName,
    maxEntries = 10
  }) => {
    try {
      const paths = getVoltAgentPaths();
      const changelogPath = import_node_path.default.join(paths.packagesPath, packageName, "CHANGELOG.md");
      if (!import_node_fs.default.existsSync(changelogPath)) {
        return { error: `Changelog not found for package: ${packageName}` };
      }
      const content = import_node_fs.default.readFileSync(changelogPath, "utf-8");
      const entries = parseChangelogEntries(content, maxEntries);
      const stats = import_node_fs.default.statSync(changelogPath);
      return {
        packageName,
        changelogPath: `packages/${packageName}/CHANGELOG.md`,
        totalSize: stats.size,
        lastModified: stats.mtime.toISOString(),
        entries
      };
    } catch (error) {
      return {
        error: `Failed to get changelog: ${error instanceof Error ? error.message : String(error)}`
      };
    }
  }
});
var searchChangelogsTool = new import_core.Tool({
  name: "search_voltagent_changelogs",
  description: "Search across all VoltAgent package changelogs for specific bug fixes, features, or keywords.",
  parameters: import_zod.z.object({
    query: import_zod.z.string().describe(
      "The search query to find in changelogs (e.g., 'bug fix', 'error', 'authentication')"
    ),
    packages: import_zod.z.array(import_zod.z.string()).optional().describe("Specific packages to search in (if not provided, searches all packages)")
  }),
  execute: async ({ query, packages }) => {
    try {
      const paths = getVoltAgentPaths();
      const results = await searchInChangelogs(paths.packagesPath, query, packages);
      return {
        message: `Found ${results.length} changelog entries matching "${query}"`,
        query,
        results
      };
    } catch (error) {
      return {
        error: `Failed to search changelogs: ${error instanceof Error ? error.message : String(error)}`
      };
    }
  }
});
async function searchDocumentation(docsPath, query, section) {
  const results = [];
  const searchPath = section ? import_node_path.default.join(docsPath, section) : docsPath;
  if (!import_node_fs.default.existsSync(searchPath)) {
    return results;
  }
  const searchInDirectory = (dirPath, currentSection = "") => {
    const items = import_node_fs.default.readdirSync(dirPath, { withFileTypes: true });
    for (const item of items) {
      const fullPath = import_node_path.default.join(dirPath, item.name);
      if (item.isDirectory()) {
        const sectionName = currentSection ? `${currentSection}/${item.name}` : item.name;
        searchInDirectory(fullPath, sectionName);
      } else if (item.name.endsWith(".md") || item.name.endsWith(".mdx")) {
        try {
          const content = import_node_fs.default.readFileSync(fullPath, "utf-8");
          const lowercaseContent = content.toLowerCase();
          const lowercaseQuery = query.toLowerCase();
          if (lowercaseContent.includes(lowercaseQuery)) {
            const lines = content.split("\n");
            const titleLine = lines.find((line) => line.startsWith("# ")) || lines[0];
            const title = titleLine?.replace(/^#\s*/, "") || item.name;
            const matchIndex = lowercaseContent.indexOf(lowercaseQuery);
            const start = Math.max(0, matchIndex - 150);
            const end = Math.min(content.length, matchIndex + 150);
            const excerpt = content.slice(start, end).trim();
            results.push({
              filepath: import_node_path.default.relative(docsPath, fullPath),
              title,
              excerpt: `...${excerpt}...`,
              section: currentSection || import_node_path.default.dirname(import_node_path.default.relative(docsPath, fullPath))
            });
          }
        } catch (error) {
          console.warn(`Error reading file ${fullPath}:`, error);
        }
      }
    }
  };
  searchInDirectory(searchPath);
  return results;
}
async function getDocumentationStructure(docsPath, section) {
  const structure = {};
  const buildStructure = (dirPath, obj) => {
    if (!import_node_fs.default.existsSync(dirPath)) return;
    const items = import_node_fs.default.readdirSync(dirPath, { withFileTypes: true });
    for (const item of items) {
      const fullPath = import_node_path.default.join(dirPath, item.name);
      if (item.isDirectory()) {
        obj[item.name] = {};
        buildStructure(fullPath, obj[item.name]);
      } else if (item.name.endsWith(".md") || item.name.endsWith(".mdx")) {
        try {
          const content = import_node_fs.default.readFileSync(fullPath, "utf-8");
          const lines = content.split("\n");
          const titleLine = lines.find((line) => line.startsWith("# ")) || lines[0];
          const title = titleLine?.replace(/^#\s*/, "") || item.name;
          obj[item.name] = {
            title,
            path: import_node_path.default.relative(docsPath, fullPath),
            size: import_node_fs.default.statSync(fullPath).size
          };
        } catch {
          obj[item.name] = {
            title: item.name,
            path: import_node_path.default.relative(docsPath, fullPath),
            error: "Could not read file"
          };
        }
      }
    }
  };
  const targetPath = section ? import_node_path.default.join(docsPath, section) : docsPath;
  buildStructure(targetPath, structure);
  return structure;
}
async function searchExamples(examplesPath, query, technology) {
  const results = [];
  if (!import_node_fs.default.existsSync(examplesPath)) {
    return results;
  }
  const items = import_node_fs.default.readdirSync(examplesPath, { withFileTypes: true });
  const lowercaseQuery = query.toLowerCase();
  for (const item of items) {
    if (item.isDirectory()) {
      const examplePath = import_node_path.default.join(examplesPath, item.name);
      try {
        const packageJsonPath = import_node_path.default.join(examplePath, "package.json");
        const readmePath = import_node_path.default.join(examplePath, "README.md");
        let description = "";
        let technologies = [];
        if (import_node_fs.default.existsSync(packageJsonPath)) {
          const packageJson = JSON.parse(import_node_fs.default.readFileSync(packageJsonPath, "utf-8"));
          description = packageJson.description || "";
          const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
          technologies = Object.keys(deps).filter(
            (dep) => dep.includes("voltagent") || dep.includes("ai") || dep.includes("anthropic") || dep.includes("openai") || dep.includes("vercel") || dep.includes("next") || dep.includes("react") || dep.includes("supabase") || dep.includes("postgres")
          );
        }
        if (!description && import_node_fs.default.existsSync(readmePath)) {
          const readmeContent = import_node_fs.default.readFileSync(readmePath, "utf-8");
          const descriptionMatch = readmeContent.match(/^#{1,2}\s*(.+?)$/m);
          description = descriptionMatch?.[1] || "";
        }
        const matchesQuery = item.name.toLowerCase().includes(lowercaseQuery) || description.toLowerCase().includes(lowercaseQuery) || technologies.some((tech) => tech.toLowerCase().includes(lowercaseQuery));
        const matchesTechnology = !technology || item.name.toLowerCase().includes(technology.toLowerCase()) || technologies.some((tech) => tech.toLowerCase().includes(technology.toLowerCase()));
        if (matchesQuery && matchesTechnology) {
          results.push({
            name: item.name,
            description: description || `VoltAgent example: ${item.name}`,
            technologies,
            path: item.name
          });
        }
      } catch (error) {
        console.warn(`Error processing example ${item.name}:`, error);
      }
    }
  }
  return results;
}
async function getExampleContent(examplePath) {
  const result = {
    description: "",
    files: [],
    technologies: [],
    readme: void 0
  };
  const keyFiles = [
    "package.json",
    "README.md",
    "src/index.ts",
    "src/index.js",
    "index.ts",
    "index.js"
  ];
  for (const fileName of keyFiles) {
    const filePath = import_node_path.default.join(examplePath, fileName);
    if (import_node_fs.default.existsSync(filePath)) {
      try {
        const content = import_node_fs.default.readFileSync(filePath, "utf-8");
        if (fileName === "package.json") {
          const packageJson = JSON.parse(content);
          result.description = packageJson.description || "";
          const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
          result.technologies = Object.keys(deps);
        }
        if (fileName === "README.md") {
          result.readme = content;
        }
        result.files.push({
          path: fileName,
          content,
          type: import_node_path.default.extname(fileName).slice(1) || "text"
        });
      } catch (error) {
        console.warn(`Error reading file ${fileName}:`, error);
      }
    }
  }
  return result;
}
async function listExamples(examplesPath, category) {
  const examples = [];
  if (!import_node_fs.default.existsSync(examplesPath)) {
    return examples;
  }
  const items = import_node_fs.default.readdirSync(examplesPath, { withFileTypes: true });
  for (const item of items) {
    if (item.isDirectory()) {
      const examplePath = import_node_path.default.join(examplesPath, item.name);
      try {
        const packageJsonPath = import_node_path.default.join(examplePath, "package.json");
        let description = "";
        let technologies = [];
        let exampleCategory = "general";
        if (import_node_fs.default.existsSync(packageJsonPath)) {
          const packageJson = JSON.parse(import_node_fs.default.readFileSync(packageJsonPath, "utf-8"));
          description = packageJson.description || `VoltAgent example: ${item.name}`;
          const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
          technologies = Object.keys(deps);
          if (item.name.includes("voice")) exampleCategory = "voice";
          else if (item.name.includes("ai") || item.name.includes("anthropic") || item.name.includes("openai"))
            exampleCategory = "ai";
          else if (item.name.includes("database") || item.name.includes("postgres") || item.name.includes("supabase"))
            exampleCategory = "database";
          else if (item.name.includes("nextjs") || item.name.includes("vercel"))
            exampleCategory = "web";
          else if (item.name.includes("mcp")) exampleCategory = "mcp";
          else if (item.name.includes("tool")) exampleCategory = "tools";
        }
        if (!category || exampleCategory.includes(category.toLowerCase()) || item.name.toLowerCase().includes(category.toLowerCase())) {
          examples.push({
            name: item.name,
            description,
            technologies,
            category: exampleCategory
          });
        }
      } catch (error) {
        console.warn(`Error processing example ${item.name}:`, error);
      }
    }
  }
  return examples.sort((a, b) => a.name.localeCompare(b.name));
}
async function listPackageChangelogs(packagesPath) {
  const packages = [];
  if (!import_node_fs.default.existsSync(packagesPath)) {
    return packages;
  }
  const items = import_node_fs.default.readdirSync(packagesPath, { withFileTypes: true });
  for (const item of items) {
    if (item.isDirectory()) {
      const changelogPath = import_node_path.default.join(packagesPath, item.name, "CHANGELOG.md");
      const hasChangelog = import_node_fs.default.existsSync(changelogPath);
      let lastModified;
      let size;
      if (hasChangelog) {
        try {
          const stats = import_node_fs.default.statSync(changelogPath);
          lastModified = stats.mtime.toISOString();
          size = stats.size;
        } catch {
        }
      }
      packages.push({
        packageName: item.name,
        hasChangelog,
        lastModified,
        size
      });
    }
  }
  return packages.sort((a, b) => a.packageName.localeCompare(b.packageName));
}
function parseChangelogEntries(content, maxEntries) {
  const entries = [];
  const lines = content.split("\n");
  let currentEntry = null;
  let currentSection = "";
  for (const line of lines) {
    const versionMatch = line.match(
      /^##\s*(?:\[)?([0-9]+\.[0-9]+\.[0-9]+(?:-[a-zA-Z0-9.-]+)?)\]?\s*(?:-\s*(\d{4}-\d{2}-\d{2}))?/
    );
    if (versionMatch) {
      if (currentEntry) {
        entries.push({
          ...currentEntry,
          content: currentEntry.content.trim()
        });
        if (entries.length >= maxEntries) {
          break;
        }
      }
      currentEntry = {
        version: versionMatch[1],
        date: versionMatch[2],
        changes: [],
        content: `${line}
`
      };
      currentSection = "";
    } else if (currentEntry) {
      currentEntry.content += `${line}
`;
      const sectionMatch = line.match(/^###\s*(.+)/);
      if (sectionMatch) {
        currentSection = sectionMatch[1].toLowerCase();
      }
      const bulletMatch = line.match(/^[-*]\s*(.+)/);
      if (bulletMatch) {
        const changeText = bulletMatch[1];
        const changeWithSection = currentSection ? `${currentSection}: ${changeText}` : changeText;
        currentEntry.changes.push(changeWithSection);
      }
    }
  }
  if (currentEntry && entries.length < maxEntries) {
    entries.push({
      ...currentEntry,
      content: currentEntry.content.trim()
    });
  }
  return entries;
}
async function searchInChangelogs(packagesPath, query, packages) {
  const results = [];
  if (!import_node_fs.default.existsSync(packagesPath)) {
    return results;
  }
  const items = import_node_fs.default.readdirSync(packagesPath, { withFileTypes: true });
  const lowercaseQuery = query.toLowerCase();
  for (const item of items) {
    if (item.isDirectory()) {
      if (packages && !packages.includes(item.name)) {
        continue;
      }
      const changelogPath = import_node_path.default.join(packagesPath, item.name, "CHANGELOG.md");
      if (import_node_fs.default.existsSync(changelogPath)) {
        try {
          const content = import_node_fs.default.readFileSync(changelogPath, "utf-8");
          const entries = parseChangelogEntries(content, 50);
          for (const entry of entries) {
            const entryContent = entry.content.toLowerCase();
            if (entryContent.includes(lowercaseQuery)) {
              const lines = entry.content.split("\n");
              let matchedContent = "";
              let context = "";
              for (const line of lines) {
                if (line.toLowerCase().includes(lowercaseQuery)) {
                  matchedContent = line.trim();
                  break;
                }
              }
              const contextLines = lines.slice(0, Math.min(lines.length, 5));
              context = contextLines.join("\n").trim();
              results.push({
                packageName: item.name,
                version: entry.version,
                date: entry.date,
                matchedContent,
                context
              });
            }
          }
        } catch (error) {
          console.warn(`Error reading changelog for ${item.name}:`, error);
        }
      }
    }
  }
  return results.sort((a, b) => {
    if (a.packageName !== b.packageName) {
      return a.packageName.localeCompare(b.packageName);
    }
    return b.version.localeCompare(a.version);
  });
}
var voltAgentDocsTools = [
  searchDocumentationTool,
  getDocumentationTool,
  listDocumentationTool,
  searchExamplesTool,
  getExampleTool,
  listExamplesTool,
  listChangelogsTool,
  getChangelogTool,
  searchChangelogsTool
];

// src/server.ts
var mcpTools = voltAgentDocsTools.map((tool) => ({
  name: tool.name,
  description: tool.description,
  inputSchema: tool.parameters
}));
console.error("=== VoltAgent Docs MCP Server Starting ===");
console.error(`Loaded ${mcpTools.length} tools:`);
mcpTools.forEach((tool, index) => {
  console.error(`  ${index + 1}. ${tool.name} - ${tool.description}`);
});
console.error("===========================================");
var server = new import_server.Server(
  {
    name: "voltagent-docs-mcp",
    version: "0.0.1"
  },
  {
    capabilities: {
      tools: {}
    }
  }
);
server.setRequestHandler(import_types.ListToolsRequestSchema, async () => {
  console.error("=== LIST TOOLS REQUEST RECEIVED ===");
  console.error(`Returning ${mcpTools.length} tools to client`);
  mcpTools.forEach((tool, index) => {
    console.error(`  ${index + 1}. ${tool.name}`);
  });
  console.error("====================================");
  return {
    tools: mcpTools
  };
});
server.setRequestHandler(import_types.CallToolRequestSchema, async (request) => {
  console.error("=== TOOL CALL REQUEST ===");
  console.error(`Tool: ${request.params.name}`);
  console.error("Args:", request.params.arguments);
  console.error("========================");
  const { name, arguments: args } = request.params;
  const tool = voltAgentDocsTools.find((t) => t.name === name);
  if (!tool) {
    console.error(`ERROR: Unknown tool: ${name}`);
    throw new Error(`Unknown tool: ${name}`);
  }
  try {
    const result = await tool.execute(args || {});
    console.error(`Tool ${name} executed successfully`);
    return {
      content: [
        {
          type: "text",
          text: JSON.stringify(result, null, 2)
        }
      ]
    };
  } catch (error) {
    console.error(`Tool execution failed for ${name}:`, error);
    throw new Error(
      `Tool execution failed: ${error instanceof Error ? error.message : String(error)}`
    );
  }
});
async function main() {
  const transport = new import_stdio.StdioServerTransport();
  await server.connect(transport);
  console.error("=== VoltAgent docs MCP server is running ===");
  process.on("SIGINT", async () => {
    console.error("Received SIGINT, shutting down server...");
    await server.close();
    process.exit(0);
  });
  process.on("SIGTERM", async () => {
    console.error("Received SIGTERM, shutting down server...");
    await server.close();
    process.exit(0);
  });
}
main().catch((error) => {
  console.error("Server failed to start:", error);
  process.exit(1);
});
//# sourceMappingURL=server.cjs.map