Skip to main content
Glama

ACP Commerce MCP Server

lookup-items.ts1.87 kB
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { ProductSearchService } from '../services/ProductSearchService.js'; import { MerchantSessionService } from '../services/MerchantSessionService.js'; import { LookupItemsSchema } from '../utils/validation.js'; import { formatACPError } from '../utils/error-handler.js'; export function registerLookupItemsTool( server: McpServer, merchantService: MerchantSessionService, searchService: ProductSearchService, sessionId: string ) { server.tool( 'lookup_items', 'Search for products in the merchant catalog', { query: { type: 'string', description: 'Search query for products', }, limit: { type: 'number', description: 'Maximum number of results (1-50)', default: 10, }, category: { type: 'string', description: 'Optional category filter', }, }, async (args) => { try { const validated = LookupItemsSchema.parse(args); const results = await searchService.search(validated); const payload = { data: { products: results, }, metadata: { count: results.length, query: validated.query, request_id: sessionId, timestamp: new Date().toISOString(), }, }; return { content: [ { type: 'text', text: JSON.stringify(payload, null, 2), }, ], }; } catch (error) { const acpError = formatACPError(error, sessionId, 'lookup_items'); return { content: [ { type: 'text', text: JSON.stringify(acpError, null, 2), }, ], isError: true, }; } } ); }

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/gratitude5dee/wzrdmcp'

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