Skip to main content
Glama

OpenAI SDK Knowledge MCP Server

by seratch
id-utils.test.ts2.08 kB
import { IdUtils } from "../../pipeline/processors/id-utils"; describe("IdUtils", () => { describe("ensureSafeId", () => { it("should return short IDs unchanged", () => { const shortId = "github_issue_123"; expect(IdUtils.ensureSafeId(shortId)).toBe(shortId); }); it("should return IDs at exactly 64 bytes unchanged", () => { const exactId = "a".repeat(64); expect(IdUtils.ensureSafeId(exactId)).toBe(exactId); expect(IdUtils.ensureSafeId(exactId).length).toBe(64); }); it("should truncate and hash IDs longer than 64 bytes", () => { const longId = "github_owner_repo_file_" + "very_long_path_name_".repeat(10); expect(longId.length).toBeGreaterThan(64); const safeId = IdUtils.ensureSafeId(longId); expect(safeId.length).toBeLessThanOrEqual(64); expect(safeId).toContain("_"); expect(safeId).toMatch(/^github_owner_repo_file_.*_[0-9a-f]{8}$/); }); it("should generate consistent hashes for the same input", () => { const longId = "github_file_" + "x".repeat(100); const safeId1 = IdUtils.ensureSafeId(longId); const safeId2 = IdUtils.ensureSafeId(longId); expect(safeId1).toBe(safeId2); }); it("should generate different hashes for different inputs", () => { const longId1 = "github_file_" + "x".repeat(100); const longId2 = "github_file_" + "y".repeat(100); const safeId1 = IdUtils.ensureSafeId(longId1); const safeId2 = IdUtils.ensureSafeId(longId2); expect(safeId1).not.toBe(safeId2); }); it("should handle the original error case", () => { const problematicId = "github_file_src/very/long/path/to/some/file/that/exceeds/the/limit.ts"; expect(problematicId.length).toBeGreaterThan(64); const safeId = IdUtils.ensureSafeId(problematicId); expect(safeId.length).toBeLessThanOrEqual(64); expect(safeId).toContain( "github_file_src/very/long/path/to/some/file/that/exceed", ); expect(safeId).toMatch(/_[0-9a-f]{8}$/); }); }); });

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/seratch/openai-sdk-knowledge-org'

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