Skip to main content
Glama
test-zstd.ts•3.73 kB
#!/usr/bin/env bun import { assertContains, assertSuccess, callTool, type TestOptions, withMCPServer } from "./utils.js" const testZstdDecompression = async (options: TestOptions): Promise<void> => { console.log("\nšŸ—œļø Testing zstd decompression functionality...") await withMCPServer(options.executable, async (server) => { // Test 1: Fetch a crate that requires zstd decompression console.log("\nšŸ“¦ Test 1: Fetch crate documentation with zstd compression...") // Using a crate that we know has rustdoc JSON console.log("ā³ Fetching anyhow documentation (this may take a moment)...") const startTime = Date.now() const lookupResponse = await callTool(server, "lookup_crate_docs", { crateName: "anyhow" }) const fetchTime = Date.now() - startTime assertSuccess(lookupResponse) if (!lookupResponse.result?.content?.[0]?.text) { throw new Error("Failed to fetch crate documentation") } const docText = lookupResponse.result.content[0].text console.log(`āœ… Successfully fetched and decompressed documentation in ${fetchTime}ms`) // Test 2: Verify decompressed content is valid console.log("\nšŸ” Test 2: Verify decompressed content...") // Check for expected content in anyhow docs const expectedPatterns = ["anyhow", "error", "result", "context"] let foundPatterns = 0 for (const pattern of expectedPatterns) { if (docText.toLowerCase().includes(pattern)) { foundPatterns++ } } if (foundPatterns < 2) { throw new Error( "Decompressed content doesn't contain expected anyhow documentation patterns" ) } console.log( `āœ… Verified documentation content (found ${foundPatterns}/${expectedPatterns.length} expected patterns)` ) // Test 3: Fetch item documentation (also uses zstd) console.log("\nšŸ“„ Test 3: Fetch specific item documentation...") const itemResponse = await callTool( server, "lookup_item_docs", { crateName: "anyhow", itemPath: "Error" }, 3 ) assertSuccess(itemResponse) if (!itemResponse.result?.content?.[0]?.text) { throw new Error("Failed to fetch item documentation") } const itemText = itemResponse.result.content[0].text assertContains(itemText.toLowerCase(), "error", "Item documentation should contain 'error'") console.log("āœ… Successfully fetched and decompressed item documentation") // Test 4: Test with a smaller crate to ensure zstd works for various sizes console.log("\nšŸ“ Test 4: Test with smaller crate...") const smallCrateResponse = await callTool( server, "lookup_crate_docs", { crateName: "once_cell" }, 4 ) assertSuccess(smallCrateResponse) if (!smallCrateResponse.result?.content?.[0]?.text) { throw new Error("Failed to fetch small crate documentation") } const smallCrateText = smallCrateResponse.result.content[0].text if (!smallCrateText.includes("once_cell") && !smallCrateText.includes("OnceCell")) { throw new Error("Small crate documentation doesn't contain expected content") } console.log("āœ… Zstd decompression works for crates of various sizes") console.log("\nāœ… All zstd decompression tests passed") }) } export const runZstdTests = async (options: TestOptions): Promise<void> => { await testZstdDecompression(options) } // Main execution if (import.meta.main) { const args = process.argv.slice(2) if (args.length < 2) { console.error("Usage: bun test/integration/test-zstd.ts <executable> <target>") process.exit(1) } const [executable, target] = args const options: TestOptions = { executable, target } try { await runZstdTests(options) } catch (error) { console.error(`\nāŒ Zstd decompression tests failed: ${error}`) process.exit(1) } }

Latest Blog Posts

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/vexxvakan/mcp-docsrs'

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