Skip to main content
Glama
searchPatterns.tsโ€ข1.46 kB
import Ravelry from '@/class/ravelry.class'; import { mcpServer } from '@/index'; import { z } from 'zod'; mcpServer.tool( 'search-patterns', 'Search patterns on Ravelry', { query: z.string().describe('Item to be search on ravelry'), page: z.number().int().positive().default(1).describe('Page number to retrieve'), craft: z.string().describe('Craft type to be searched (knitting, crochet)'), availability: z .string() .default('free') .describe('Price of the item can be either: free, ravelry, online'), }, async ({ query, page, craft, availability }) => { const ravelryInstance = new Ravelry( process.env.AUTH_USER as string, process.env.AUTH_PASS as string, ); try { const patterns = await ravelryInstance.searchPatterns(query, page, craft, availability); if (!patterns) { return { isError: true, content: [{ type: 'text', text: 'No pattern found' }], }; } const response = patterns.map(pattern => { return { free: pattern.free, id: pattern.id, name: pattern.name, permalink: pattern.permalink, }; }); return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }], }; } catch (error) { return { isError: true, content: [{ type: 'text', text: 'Failure while searching patterns' }], }; } }, );

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/gpaul-mcp/MCP_ravelry'

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