Skip to main content
Glama
metrics.ts925 B
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; import { register } from '../utils/metrics.js'; export async function metricsRoutes(fastify: FastifyInstance) { fastify.get('/metrics', async (_request, reply) => { const metrics = await register.metrics(); reply .header('Content-Type', register.contentType) .send(metrics); }); // Handle other HTTP methods with helpful error const methodNotAllowedHandler = async (_request: FastifyRequest, reply: FastifyReply) => { reply.status(405).send({ error: { message: 'Method Not Allowed. Use GET for metrics.', code: 405, allowed_methods: ['GET'] } }); }; fastify.post('/metrics', methodNotAllowedHandler); fastify.put('/metrics', methodNotAllowedHandler); fastify.delete('/metrics', methodNotAllowedHandler); fastify.patch('/metrics', methodNotAllowedHandler); }

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/MillCityAI/mcp-hello-world'

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