Skip to main content
Glama

memory_similar

Find similar projects by comparing analysis IDs to identify related documentation deployments and repository patterns.

Instructions

Find similar projects from memory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
analysisIdYesAnalysis ID to find similar projects for
limitNoMaximum number of similar projects

Implementation Reference

  • Main handler function that implements finding similar projects by searching memory for matching language and framework tags, deduplicating, and computing similarity scores.
    export async function getSimilarProjects( analysisData: any, limit: number = 5, ): Promise<any[]> { const manager = await initializeMemory(); // Search for projects with similar characteristics const similarProjects: any[] = []; // Search by language if (analysisData.language?.primary) { const languageMatches = await manager.search( { tags: [analysisData.language.primary] }, { sortBy: "timestamp" }, ); similarProjects.push(...languageMatches); } // Search by framework if (analysisData.framework?.name) { const frameworkMatches = await manager.search( { tags: [analysisData.framework.name] }, { sortBy: "timestamp" }, ); similarProjects.push(...frameworkMatches); } // Deduplicate and return top matches const unique = Array.from( new Map(similarProjects.map((p) => [p.metadata.projectId, p])).values(), ); return unique.slice(0, limit).map((project) => ({ projectId: project.metadata.projectId, similarity: calculateSimilarity(analysisData, project.data), recommendation: project.metadata.ssg, timestamp: project.timestamp, })); }
  • Defines the input schema and registers the memory_similar tool within the memoryTools array.
    { name: "memory_similar", description: "Find similar projects from memory", inputSchema: { type: "object", properties: { analysisId: { type: "string", description: "Analysis ID to find similar projects for", }, limit: { type: "number", description: "Maximum number of similar projects", default: 5, }, }, required: ["analysisId"], }, },
  • Helper function to compute a similarity score between two project analysis objects based on language, framework, size, and documentation type.
    function calculateSimilarity(data1: any, data2: any): number { let score = 0; // Language match if (data1.language?.primary === data2.language?.primary) score += 0.3; // Framework match if (data1.framework?.name === data2.framework?.name) score += 0.3; // Size similarity if (Math.abs((data1.stats?.files || 0) - (data2.stats?.files || 0)) < 100) score += 0.2; // Documentation type match if (data1.documentation?.type === data2.documentation?.type) score += 0.2; return Math.min(score, 1.0); }
  • Exports the getSimilarProjects handler function for use in tool implementations.
    getSimilarProjects,

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/tosin2013/documcp'

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