Skip to main content
Glama
route.ts963 B
import { NextRequest, NextResponse } from 'next/server'; import { getTools, searchTools } from '@/lib/db'; export const dynamic = 'force-dynamic'; export async function GET(request: NextRequest) { try { const searchParams = request.nextUrl.searchParams; const query = searchParams.get('query'); const tags = searchParams.get('tags'); const limit = parseInt(searchParams.get('limit') || '10'); const offset = parseInt(searchParams.get('offset') || '0'); if (query || tags) { const tagsList = tags ? tags.split(',') : []; const results = await searchTools(query || '', tagsList, limit, offset); return NextResponse.json({ tools: results }); } else { const tools = await getTools(limit, offset); return NextResponse.json({ tools }); } } catch (error) { console.error('Error fetching tools:', error); return NextResponse.json({ error: 'Failed to fetch tools' }, { status: 500 }); } }

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/thomasdavis/blah'

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