This commit is contained in:
nasir@endelospay.com
2025-07-11 20:22:12 +05:00
commit 8c74b0e23f
120 changed files with 206874 additions and 0 deletions

View File

@@ -0,0 +1,207 @@
#!/usr/bin/env node
/**
* Generate complete MCP tools documentation with accurate categorization
*/
// Set environment variables
process.env.LARAVEL_API_BASE_URL = "https://example.com";
console.log("📋 Generating complete MCP tools documentation...\n");
import("./src/tools/ToolGenerator.js")
.then(async ({ ToolGenerator }) => {
import("./src/proxy/ApiClient.js").then(async ({ ApiClient }) => {
import("./src/auth/AuthManager.js").then(async ({ AuthManager }) => {
import("./src/config/ConfigManager.js").then(
async ({ ConfigManager }) => {
import("./src/config/endpoints.js").then(
async (endpointsModule) => {
try {
const config = new ConfigManager();
const authManager = new AuthManager(
null,
config.getAll(true)
);
const apiClient = new ApiClient(config.getAll(), authManager);
const toolGenerator = new ToolGenerator(apiClient);
const tools = toolGenerator.generateAllTools();
const { ENDPOINT_CATEGORIES } = endpointsModule;
// Group tools by auth type
const toolsByAuth = {
public: [],
provider: [],
patient: [],
partner: [],
affiliate: [],
network: [],
};
tools.forEach((tool) => {
const toolDef = toolGenerator.getTool(tool.name);
if (toolDef) {
toolsByAuth[toolDef.authType].push({
name: tool.name,
description: tool.description,
endpoint: toolDef.endpoint,
inputSchema: tool.inputSchema,
});
}
});
// Group tools by category within each auth type
function groupByCategory(toolsList) {
const categories = {};
toolsList.forEach((tool) => {
const category = tool.endpoint.category;
if (!categories[category]) {
categories[category] = [];
}
categories[category].push(tool);
});
return categories;
}
console.log("=== COMPLETE TOOL INVENTORY ===\n");
// Generate statistics
console.log("## Tool Statistics\n");
console.log(`- **Total Tools**: ${tools.length}`);
console.log(
`- **Public Tools**: ${toolsByAuth.public.length} (no authentication required)`
);
console.log(
`- **Provider Tools**: ${toolsByAuth.provider.length} (provider/EMR authentication required)`
);
console.log(
`- **Patient Tools**: ${toolsByAuth.patient.length} (patient portal authentication required)`
);
console.log(
`- **Partner Tools**: ${toolsByAuth.partner.length} (partner business authentication required)`
);
console.log(
`- **Affiliate Tools**: ${toolsByAuth.affiliate.length} (affiliate business authentication required)`
);
console.log(
`- **Network Tools**: ${toolsByAuth.network.length} (network business authentication required)`
);
// Generate category distribution
console.log("\n## Functional Distribution\n");
const allCategories = {};
Object.values(toolsByAuth)
.flat()
.forEach((tool) => {
const category = tool.endpoint.category;
if (!allCategories[category]) {
allCategories[category] = { total: 0, byAuth: {} };
}
allCategories[category].total++;
const authType = toolsByAuth.public.includes(tool)
? "public"
: toolsByAuth.provider.includes(tool)
? "provider"
: toolsByAuth.patient.includes(tool)
? "patient"
: toolsByAuth.partner.includes(tool)
? "partner"
: toolsByAuth.affiliate.includes(tool)
? "affiliate"
: "network";
if (!allCategories[category].byAuth[authType]) {
allCategories[category].byAuth[authType] = 0;
}
allCategories[category].byAuth[authType]++;
});
// Sort categories by total count
const sortedCategories = Object.entries(allCategories).sort(
([, a], [, b]) => b.total - a.total
);
sortedCategories.forEach(([category, data]) => {
const authBreakdown = Object.entries(data.byAuth)
.map(([auth, count]) => `${count} ${auth}`)
.join(", ");
console.log(
`- **${category
.replace(/_/g, " ")
.replace(/\b\w/g, (l) => l.toUpperCase())}**: ${
data.total
} tools (${authBreakdown})`
);
});
// Generate detailed tool listings by auth type
console.log("\n---\n");
// Function to generate auth section
function generateAuthSection(authType, toolsList) {
if (toolsList.length === 0) return;
const authName =
authType.charAt(0).toUpperCase() + authType.slice(1);
console.log(
`## ${authName} Tools (${toolsList.length} tools)\n`
);
const toolsByCategory = groupByCategory(toolsList);
Object.entries(toolsByCategory).forEach(
([category, categoryTools]) => {
const categoryName = category
.replace(/_/g, " ")
.replace(/\b\w/g, (l) => l.toUpperCase());
console.log(`### ${categoryName}\n`);
console.log(
"| Tool Name | Method | Endpoint | Description |"
);
console.log(
"| --------- | ------ | -------- | ----------- |"
);
categoryTools.forEach((tool) => {
const method = tool.endpoint.method;
const path = tool.endpoint.path;
const desc =
tool.endpoint.description || "API endpoint";
console.log(
`| \`${tool.name}\` | ${method} | \`${path}\` | ${desc} |`
);
});
console.log("");
}
);
console.log("---\n");
}
// Generate all auth sections
generateAuthSection("public", toolsByAuth.public);
generateAuthSection("provider", toolsByAuth.provider);
generateAuthSection("patient", toolsByAuth.patient);
generateAuthSection("partner", toolsByAuth.partner);
generateAuthSection("affiliate", toolsByAuth.affiliate);
generateAuthSection("network", toolsByAuth.network);
console.log("\n=== DOCUMENTATION GENERATED ===");
console.log(
"Copy the output above to update the MCP-TOOLS-REFERENCE.md file"
);
} catch (error) {
console.error("❌ Error:", error.message);
console.error("Stack:", error.stack);
}
}
);
}
);
});
});
})
.catch((error) => {
console.error("❌ Import error:", error.message);
});