Skip to main content
Glama
search.tool.ts773 B
import { z } from "zod"; import { searchArticles } from "@/lib/data"; import { createLoggedTool } from "@/lib/logger"; import type { McpServer } from "@/lib/mcp-types"; export function createSearchTool(server: McpServer, userId?: string) { createLoggedTool( server, "search", "Search articles. Pass in a query string.", { query: z.string().describe("The search query for articles."), }, async ({ query }: { query: string }) => { const searchResults = await searchArticles(query, 10); return { structuredContent: { results: searchResults.results }, content: [ { type: "text" as const, text: JSON.stringify(searchResults), }, ], }; }, userId ); }

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/mcpauth/mcpauth'

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