Skip to main content
Glama
Cognitive-Stack

Hermes Search MCP Server

search-tools.ts1.77 kB
"use strict"; import { SearchClient, SearchIndexClient, AzureKeyCredential } from "@azure/search-documents"; import { getConfig } from "../config/env"; const config = getConfig(); const searchClient = new SearchClient( config.endpoint, config.indexName, new AzureKeyCredential(config.apiKey) ); const indexClient = new SearchIndexClient( config.endpoint, new AzureKeyCredential(config.apiKey) ); export const searchDocuments = async (query: string, options?: { top?: number; filter?: string; select?: string[]; }) => { try { const results = await searchClient.search(query, { top: options?.top || 5, filter: options?.filter, select: options?.select, }); const documents = []; for await (const result of results.results) { documents.push(result.document); } return JSON.stringify(documents); } catch (error: unknown) { if (error instanceof Error) { throw new Error(`Search failed: ${error.message}`); } throw new Error("Search failed with unknown error"); } }; export const indexContent = async (documents: any[]) => { try { const result = await searchClient.mergeOrUploadDocuments(documents); return JSON.stringify(result); } catch (error: unknown) { if (error instanceof Error) { throw new Error(`Indexing failed: ${error.message}`); } throw new Error("Indexing failed with unknown error"); } }; export const deleteIndex = async () => { try { await indexClient.deleteIndex(config.indexName); return "Index deleted successfully"; } catch (error: unknown) { if (error instanceof Error) { throw new Error(`Index deletion failed: ${error.message}`); } throw new Error("Index deletion failed with unknown error"); } };

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/Cognitive-Stack/hermes-search-mcp'

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