Skip to main content
Glama

docs-mcp-server

list.tsx1.97 kB
import type { FastifyInstance } from "fastify"; import type { ListLibrariesTool } from "../../../tools/ListLibrariesTool"; import { RemoveTool } from "../../../tools"; import LibraryList from "../../components/LibraryList"; /** * Registers the API routes for library management. * @param server - The Fastify instance. * @param listLibrariesTool - The tool instance for listing libraries. * @param removeTool - The tool instance for removing library versions. */ export function registerLibrariesRoutes( server: FastifyInstance, listLibrariesTool: ListLibrariesTool, removeTool: RemoveTool // Accept RemoveTool ) { server.get("/web/libraries", async (_request, reply) => { // Add reply try { const result = await listLibrariesTool.execute(); // Set content type to HTML for JSX rendering reply.type("text/html; charset=utf-8"); // Render the component directly return <LibraryList libraries={result.libraries} />; } catch (error) { server.log.error(error, "Failed to list libraries"); reply.status(500).send("Internal Server Error"); // Handle errors } }); // Add DELETE route for removing versions server.delete<{ Params: { libraryName: string; versionParam: string } }>( "/web/libraries/:libraryName/versions/:versionParam", async (request, reply) => { const { libraryName, versionParam } = request.params; const version = versionParam === "unversioned" ? undefined : versionParam; try { await removeTool.execute({ library: libraryName, version }); reply.status(204).send(); // No Content on success } catch (error: any) { server.log.error( error, `Failed to remove ${libraryName}@${versionParam}` ); // Check for specific errors if needed, e.g., NotFoundError reply .status(500) .send({ message: error.message || "Failed to remove version." }); } } ); }

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/arabold/docs-mcp-server'

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