Skip to main content
Glama

get_unique_values

Retrieve all distinct values for a metadata field in your Obsidian vault to analyze content patterns and organize information effectively.

Instructions

Get all unique values for a metadata field

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldYesMetadata field name
vaultYesVault name

Implementation Reference

  • Core implementation of get_unique_values tool: iterates over all notes, extracts metadata, collects unique values for the specified field using a Set, handles arrays, and returns sorted array.
    getUniqueValues(field: string): any[] { const values = new Set<any>(); for (const note of this.notes) { const metadata = this.extractMetadata(note); const value = this.getNestedValue(metadata, field); if (value !== undefined && value !== null) { if (Array.isArray(value)) { value.forEach(v => values.add(v)); } else { values.add(value); } } } return Array.from(values); }
  • Input schema definition for the get_unique_values tool, requiring 'vault' and 'field' parameters.
    inputSchema: { type: 'object', properties: { vault: { type: 'string', description: 'Vault name' }, field: { type: 'string', description: 'Metadata field name' }, }, required: ['vault', 'field'], },
  • src/index.ts:339-350 (registration)
    Tool registration in the list of tools returned by ListToolsRequestHandler.
    { name: 'get_unique_values', description: 'Get all unique values for a metadata field', inputSchema: { type: 'object', properties: { vault: { type: 'string', description: 'Vault name' }, field: { type: 'string', description: 'Metadata field name' }, }, required: ['vault', 'field'], }, },
  • Top-level dispatch handler for get_unique_values: loads notes from vault connector, updates DataviewService, calls getUniqueValues, and formats response.
    case 'get_unique_values': { const connector = this.connectors.get(args?.vault as string); if (!connector) { throw new Error(`Vault "${args?.vault}" not found`); } const notesResult = await connector.getAllNotes(); if (!notesResult.success || !notesResult.data) { throw new Error('Failed to get notes'); } this.dataviewService.updateNotes(notesResult.data); const values = this.dataviewService.getUniqueValues(args?.field as string); return { content: [{ type: 'text', text: JSON.stringify(values, null, 2) }], }; }

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/bazylhorsey/obsidian-mcp-server'

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