Skip to main content
Glama

analyze_tag_cooccurrence

Identify frequently co-occurring tags in journal entries to uncover patterns and relationships in your data. Accepts a list of tags for analysis within specified or default journals.

Instructions

Analyze which tags frequently appear together

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
journalNoJournal name (uses current/default if not specified)
tagsYesTags to analyze for co-occurrence

Implementation Reference

  • Core implementation of the analyze_tag_cooccurrence tool. Computes co-occurrence counts for pairs of input tags by searching journal entries containing both tags in each pair.
    export async function analyzeTagCooccurrence( tags: string[], journal: string | undefined, executor: JrnlExecutor, ): Promise<{ cooccurrences: TagCooccurrence[] }> { if (tags.length < 2) { return { cooccurrences: [] }; } // For each pair of tags, find entries that contain both const cooccurrences: TagCooccurrence[] = []; for (let i = 0; i < tags.length - 1; i++) { for (let j = i + 1; j < tags.length; j++) { const tag1 = tags[i]; const tag2 = tags[j]; // Search for entries with both tags const command = buildSearchCommand({ tags: [tag1, tag2] }, journal); const result = await executor.execute(command); try { const data = JSON.parse(result); const count = data.entries ? data.entries.length : 0; if (count > 0) { cooccurrences.push({ tag1: tag1.startsWith("@") ? tag1 : `@${tag1}`, tag2: tag2.startsWith("@") ? tag2 : `@${tag2}`, count, }); } } catch (error) { // Skip this pair if there's an error // console.error(`Error analyzing cooccurrence for ${tag1} and ${tag2}: ${error}`); } } } // Sort by count descending cooccurrences.sort((a, b) => b.count - a.count); return { cooccurrences }; }
  • Input schema definition for the analyze_tag_cooccurrence tool, specifying required 'tags' array and optional 'journal'.
    inputSchema: { type: "object", properties: { tags: { type: "array", items: { type: "string" }, description: "Tags to analyze for co-occurrence", minItems: 2, }, journal: { type: "string", description: "Journal name (uses current/default if not specified)", }, }, required: ["tags"], },
  • TypeScript interface defining the structure of tag co-occurrence results returned by the handler.
    export interface TagCooccurrence { tag1: string; tag2: string; count: number; }
  • src/index.ts:78-97 (registration)
    Tool registration in the ListTools response, including name, description, and input schema.
    { name: "analyze_tag_cooccurrence", description: "Analyze which tags frequently appear together", inputSchema: { type: "object", properties: { tags: { type: "array", items: { type: "string" }, description: "Tags to analyze for co-occurrence", minItems: 2, }, journal: { type: "string", description: "Journal name (uses current/default if not specified)", }, }, required: ["tags"], }, },
  • src/index.ts:178-194 (registration)
    Dispatch logic in CallToolRequest handler that invokes the analyzeTagCooccurrence function with parsed arguments.
    case "analyze_tag_cooccurrence": return { content: [ { type: "text", text: JSON.stringify( await analyzeTagCooccurrence( Array.isArray(args?.tags) ? args.tags : [], journal, executor, ), null, 2, ), }, ], };

Other Tools

Related Tools

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/yostos/jrnl-mcp'

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