Skip to main content
Glama

Glif

Official
by glifxyz
list-bots.ts2.66 kB
import { z } from "zod"; import { listBots } from "../api.js"; import { parseToolArguments, type ToolRequest, } from "../utils/request-parsing.js"; import { logger } from "../utils/utils.js"; import type { ToolResponse } from "./index.js"; export const schema = z.object({ sort: z.enum(["new", "popular", "featured"]).optional(), username: z.string().optional(), searchQuery: z.string().optional(), }); export const definition = { name: "list_bots", description: "Get a list of bots and sim templates with optional filtering and sorting. Supports sort={new,popular,featured} (defaults to popular), username filtering, and text search.", inputSchema: { type: "object", properties: { sort: { type: "string", enum: ["new", "popular", "featured"], description: "Optional sort order for bots (defaults to featured)", }, username: { type: "string", description: "Optional filter for bots by creator username", }, searchQuery: { type: "string", description: "Optional search query to filter bots by name or description", }, }, required: [], }, }; export async function handler(request: ToolRequest): Promise<ToolResponse> { try { const args = parseToolArguments(request, schema); const params: { sort?: "new" | "popular" | "featured"; creator?: string; searchQuery?: string; } = {}; if (args.sort) params.sort = args.sort; if (args.username) params.creator = args.username; if (args.searchQuery) params.searchQuery = args.searchQuery; const bots = await listBots(params); // Format the bot list const formattedBots = bots .map((bot) => { const skills = bot.spellsForBot && bot.spellsForBot.length > 0 ? `\nSkills: ${bot.spellsForBot .map((s) => s.spell?.name || "Unknown Skill") .join(", ")}` : ""; return `${bot.name} (@${bot.username}) - ID: ${bot.id} Bio: ${bot.bio || "No bio"} Created by: ${bot.user?.name || "Unknown"} (@${bot.user?.username || "unknown"}) Messages: ${bot.messageCount || 0}${skills}\n`; }) .join("\n"); return { content: [ { type: "text", text: `Available bots:\n\n${formattedBots}`, }, ], }; } catch (error) { logger.error("Error listing bots:", error); return { content: [ { type: "text", text: `Error listing bots: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }

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/glifxyz/glif-mcp-server'

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