UNPKG

@iflow-mcp/ansvar-systems-german-law-mcp

Version:

German legal research MCP server with statutes, case law, and preparatory works from gesetze-im-internet.de

27 lines (26 loc) • 889 B
import { ShellError } from "./errors.js"; export class AdapterRegistry { adapters = new Map(); register(adapter) { const code = adapter.country.code.toLowerCase(); if (this.adapters.has(code)) { throw new ShellError("duplicate_country", `Country adapter is already registered: ${code}`); } this.adapters.set(code, adapter); } registerMany(adapters) { for (const adapter of adapters) { this.register(adapter); } } get(countryCode) { const adapter = this.adapters.get(countryCode.toLowerCase()); if (!adapter) { throw new ShellError("unknown_country", `No adapter found for country: ${countryCode}`); } return adapter; } list() { return [...this.adapters.values()].sort((a, b) => a.country.code.localeCompare(b.country.code)); } }