dataforseo-mcp-server
Version:
CLI and MCP server for DataForSEO API — browse documentation and make authenticated API requests
30 lines • 1.23 kB
JavaScript
import { AVAILABLE_SECTIONS } from "../../config/index.js";
export function filterBySection(content, section) {
const normalizedSection = section.trim();
const lines = content.split("\n");
const matchingSection = AVAILABLE_SECTIONS.find((s) => s.toLowerCase() === normalizedSection.toLowerCase());
if (!matchingSection) {
const available = AVAILABLE_SECTIONS.map((s) => ` - ${s}`).join("\n");
throw new Error(`Unknown section "${section}". Available sections:\n${available}`);
}
const headerToFind = `## ${matchingSection}`;
const startIndex = lines.findIndex((line) => line.trim() === headerToFind);
if (startIndex === -1) {
throw new Error(`Section "${matchingSection}" not found in documentation index.`);
}
const result = [`# ${matchingSection}`, ""];
let i = startIndex + 1;
while (i < lines.length) {
const line = lines[i];
if (line.startsWith("## ") && !line.startsWith("###")) {
break;
}
result.push(line);
i++;
}
return result.join("\n").trimEnd();
}
export function listSections() {
return AVAILABLE_SECTIONS.map((s) => `- ${s}`).join("\n");
}
//# sourceMappingURL=section.js.map