Skip to main content
Glama
yostos
by yostos

analyze_tag_cooccurrence

Identify which tags frequently appear together in journal entries to reveal patterns and relationships between topics.

Instructions

Analyze which tags frequently appear together

Input Schema

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

Implementation Reference

  • Core implementation of the analyze_tag_cooccurrence tool: computes pairwise co-occurrences of tags by searching for entries containing both tags and counting matches, sorts by frequency.
    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 };
    }
  • 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 extracts arguments, determines journal, calls analyzeTagCooccurrence, and formats response.
    case "analyze_tag_cooccurrence":
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              await analyzeTagCooccurrence(
                Array.isArray(args?.tags) ? args.tags : [],
                journal,
                executor,
              ),
              null,
              2,
            ),
          },
        ],
      };
  • TypeScript interface defining the output structure for tag co-occurrences.
    export interface TagCooccurrence {
      tag1: string;
      tag2: string;
      count: number;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe how it behaves: e.g., what 'analyze' entails (e.g., returns co-occurrence counts, requires specific permissions, has rate limits, or affects data). This leaves gaps in understanding the tool's operational traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Analyze which tags frequently appear together.' It is front-loaded with the core purpose, has zero waste, and is appropriately sized for the tool's complexity. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a tool that performs analysis (implying data processing), the description is incomplete. It doesn't explain what the analysis returns (e.g., statistics, patterns), potential limitations, or how it interacts with other tools like 'list_journals'. For a 2-parameter tool with behavioral implications, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('tags' as an array with minItems 2, 'journal' as optional with default behavior). The description adds no additional meaning beyond the schema, such as explaining tag formats or journal context. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Analyze which tags frequently appear together.' It specifies the action (analyze) and the resource (tags), but doesn't differentiate from sibling tools like 'list_tags' or 'search_entries' which might also involve tags. The purpose is specific but lacks sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'search_entries' (which might filter by tags) or 'get_statistics' (which could provide other analyses), nor does it specify prerequisites or exclusions. Usage is implied from the purpose but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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