Skip to main content
Glama

GitMCP

handlers.ts1.59 kB
import type { RepoData, UrlType } from "../../../shared/repoData.js"; import type { RepoHandler } from "./RepoHandler.js"; import { getDefaultRepoHandler } from "./DefaultRepoHandler.js"; import { getGenericRepoHandler } from "./GenericRepoHandler.js"; import { getThreejsRepoHandler } from "./ThreejsRepoHandler.js"; import { getReactRouterRepoHandler } from "./ReactRouterRepoHandler.js"; const handlers: RepoHandlerMap = { // handle all types of urls for three.js "all::mrdoob/three.js": getThreejsRepoHandler(), // handle only the github type of urls for "generic" repos "all::docs/": getGenericRepoHandler(), "all::remix-run/react-router": getReactRouterRepoHandler(), }; export function getHandlerByRepoData(repoData: RepoData): RepoHandler { if (!repoData.repo && repoData.owner !== "docs") { console.log("Invalid repo data:", repoData); throw new Error( `Invalid repository data: ${JSON.stringify(repoData, null, 2)}`, ); } const repoKey = `${repoData.owner ?? ""}/${repoData.repo ?? ""}` as RepoKey; return ( // check if the keyWithUrlType is in the handlers handlers[`${repoData.urlType}::${repoKey}` as UrlTypeRepoKey] ?? // check if the allKey is in the handlers handlers[`all::${repoKey}` as AllRepoKey] ?? // if not, return the default handler getDefaultRepoHandler() ); } type RepoKey = `${string}/${string}`; type UrlTypeRepoKey = `${UrlType}::${RepoKey}`; type AllRepoKey = `all::${RepoKey}`; type MapRepoKey = UrlTypeRepoKey | AllRepoKey; type RepoHandlerMap = { [key in MapRepoKey]: RepoHandler; };

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/idosal/git-mcp'

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