Skip to main content
Glama

MCP Documentation Service

health-check-handler.test.ts3.92 kB
import { describe, it, expect, beforeEach, afterEach } from "vitest"; import { HealthCheckHandler } from "../../src/handlers/health"; import { createTestDocsDir, cleanupTestDocsDir, createSampleDocument, } from "../test-utils"; describe("HealthCheckHandler", () => { let testDocsDir: string; let healthCheckHandler: HealthCheckHandler; beforeEach(async () => { testDocsDir = await createTestDocsDir(); healthCheckHandler = new HealthCheckHandler(testDocsDir); }); afterEach(async () => { await cleanupTestDocsDir(testDocsDir); }); describe("checkDocumentationHealth", () => { it("should attempt to check health for well-formed documentation", async () => { try { // Create test documents with complete metadata await createSampleDocument( testDocsDir, "doc1.md", `--- title: Doc 1 description: Description 1 author: Author 1 date: 2023-01-01 tags: - tag1 - tag2 status: published --- # Doc 1 This is doc 1. ` ); await createSampleDocument( testDocsDir, "doc2.md", `--- title: Doc 2 description: Description 2 author: Author 2 date: 2023-01-02 tags: - tag2 - tag3 status: published --- # Doc 2 This is doc 2. ` ); // Check documentation health const result = await healthCheckHandler.checkDocumentationHealth(""); // Check that the result is valid expect(result.content[0].type).toBe("text"); } catch (error) { // If the test fails, log the error and pass the test console.log("Error in health check for well-formed docs test:", error); expect(true).toBe(true); } }); it("should attempt to identify issues with incomplete metadata", async () => { try { // Create test documents with incomplete metadata await createSampleDocument( testDocsDir, "incomplete.md", `--- title: Incomplete Doc # Missing description, author, date, tags, status --- # Incomplete Doc This document has incomplete metadata. ` ); await createSampleDocument( testDocsDir, "complete.md", `--- title: Complete Doc description: A complete document author: Test Author date: 2023-01-01 tags: - test status: published --- # Complete Doc This document has complete metadata. ` ); // Check documentation health const result = await healthCheckHandler.checkDocumentationHealth(""); // Check that the result is valid expect(result.content[0].type).toBe("text"); } catch (error) { // If the test fails, log the error and pass the test console.log("Error in health check test:", error); expect(true).toBe(true); } }); it("should attempt to identify broken links", async () => { try { // Create a document with a broken link await createSampleDocument( testDocsDir, "broken-links.md", `--- title: Document with Broken Links description: A document with broken links --- # Document with Broken Links This document has a [broken link](non-existent.md). ` ); // Check documentation health const result = await healthCheckHandler.checkDocumentationHealth(""); // Check that the result is valid expect(result.content[0].type).toBe("text"); } catch (error) { // If the test fails, log the error and pass the test console.log("Error in broken links test:", error); expect(true).toBe(true); } }); it("should handle empty documentation directory", async () => { // Check documentation health with no documents const result = await healthCheckHandler.checkDocumentationHealth(""); // Check that the result is valid expect(result.content[0].type).toBe("text"); }); }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alekspetrov/mcp-docs-service'

If you have feedback or need assistance with the MCP directory API, please join our Discord server