Skip to main content
Glama
maxkuminov

Obsidian MCP (pgvector + Ollama, self-hosted)

get_recent

Retrieve recently modified notes from your Obsidian vault. Filter by folder, tags, or frontmatter to find specific content quickly.

Instructions

Get recently modified notes.

Args: limit: Number of recent notes to return (default 20). folder: Optional folder prefix to filter (e.g. "Projects/"). tags: Optional list of tag names; only notes carrying ALL listed tags match (e.g. ["meeting"]). frontmatter: Optional dict of frontmatter key/value pairs; strict type match (e.g. {"status": "active"}).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
folderNo
tagsNo
frontmatterNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core implementation of get_recent tool. Queries NoteMetadata ordered by modified_at desc, applies folder/tags/frontmatter filters, and returns formatted markdown list.
    @_tracked("get_recent", ["limit", "folder", "tags", "frontmatter"])
    async def get_recent_impl(
        limit: int = 20,
        folder: str | None = None,
        tags: list[str] | None = None,
        frontmatter: dict | None = None,
    ) -> str:
        """Recently modified notes."""
        from sqlalchemy import select
        from src.models.db import NoteMetadata
    
        uid = current_user_id.get()
        async with async_session() as session:
            query = select(NoteMetadata).order_by(NoteMetadata.modified_at.desc())
            query = apply_note_filters(
                query, folder=folder, tags=tags, frontmatter=frontmatter, user_id=uid
            )
            query = query.limit(limit)
            result = await session.execute(query)
            notes = result.scalars().all()
    
        if not notes:
            return "No recent notes found"
    
        lines = [f"Last {len(notes)} modified notes:\n"]
        for n in notes:
            mod = n.modified_at.strftime("%Y-%m-%d %H:%M") if n.modified_at else "unknown"
            tags_str = f" [{', '.join(n.tags)}]" if n.tags else ""
            lines.append(f"- `{n.file_path}` — {n.title}{tags_str} (modified {mod})")
        return "\n".join(lines)
  • MCP tool registration for 'get_recent' via @mcp.tool() decorator. Defines the tool schema (limit, folder, tags, frontmatter params) and delegates to get_recent_impl.
    @mcp.tool()
    async def get_recent(
        limit: int = 20,
        folder: str | None = None,
        tags: list[str] | None = None,
        frontmatter: dict | None = None,
    ) -> str:
        """Get recently modified notes.
    
        Args:
            limit: Number of recent notes to return (default 20).
            folder: Optional folder prefix to filter (e.g. "Projects/").
            tags: Optional list of tag names; only notes carrying ALL listed tags match
                (e.g. ["meeting"]).
            frontmatter: Optional dict of frontmatter key/value pairs; strict type match
                (e.g. {"status": "active"}).
        """
        return await get_recent_impl(
            limit=limit, folder=folder, tags=tags, frontmatter=frontmatter
        )
  • Import of get_recent_impl from src.mcp_server.tools into the server module.
    get_recent_impl,
  • The _tracked decorator applied to get_recent_impl, which logs usage and timing to the usage_logs table.
    def _tracked(tool_name: str, param_keys: list[str]):
        """Decorator that times the call and logs it to usage_logs."""
        def decorator(fn):
            @wraps(fn)
            async def wrapper(*args, **kwargs):
                start = time.monotonic()
                result = await fn(*args, **kwargs)
                duration_ms = int((time.monotonic() - start) * 1000)
                params = {}
                for i, key in enumerate(param_keys):
                    if i < len(args):
                        params[key] = args[i]
                    elif key in kwargs:
                        params[key] = kwargs[key]
                await _log_usage(tool_name, _truncate_params(params), duration_ms, len(str(result)))
                return result
            return wrapper
        return decorator
  • apply_note_filters helper used by get_recent_impl to apply folder prefix, tag containment, frontmatter containment, and user_id filters to the SQL query.
    def apply_note_filters(
        stmt: Select,
        *,
        folder: str | None = None,
        tags: list[str] | None = None,
        frontmatter: dict | None = None,
        user_id: int | None = None,
    ) -> Select:
        """Append optional `folder`, `tags`, `frontmatter`, `user_id` predicates
        to a select over NoteMetadata.
    
        - `folder`: prefix match on `file_path`. LIKE wildcards (`%`, `_`, `\\`) are escaped.
        - `tags`: ARRAY containment (`notes_metadata.tags @> ARRAY[...]`). AND semantics.
        - `frontmatter`: JSONB containment (`notes_metadata.frontmatter @> :json`). Strict types.
        - `user_id`: scope to one user. `None` (single-user mode / unset) means no
          filter is appended, so existing NULL-user rows are returned. `int` adds
          `.where(NoteMetadata.user_id == user_id)`.
    
        None or empty argument means "no filter" — the predicate is not appended.
        """
        if folder:
            escaped = _escape_like(folder)
            stmt = stmt.where(NoteMetadata.file_path.like(f"{escaped}%", escape="\\"))
        if tags:
            stmt = stmt.where(NoteMetadata.tags.contains(tags))
        if frontmatter:
            stmt = stmt.where(NoteMetadata.frontmatter.contains(frontmatter))
        if user_id is not None:
            stmt = stmt.where(NoteMetadata.user_id == user_id)
        return stmt
Behavior2/5

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

No annotations are provided, so the description carries full burden. It only describes parameters and does not disclose behavioral traits such as ordering (likely descending by modification time), pagination, or performance implications. Basic parameter descriptions are present, but deeper behavioral context is missing.

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 concise and well-structured with clear 'Args:' section. Every sentence adds value without redundancy.

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

Completeness3/5

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

For a simple retrieval tool with an output schema, the input parameters are well documented. However, it lacks mention of ordering (e.g., descending by modification time) and does not differentiate itself from similar siblings like list_notes or get_neighborhood, leaving some context incomplete.

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

Parameters5/5

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

Schema description coverage is 0%, yet the description adds significant meaning to each parameter: limit default/count, folder prefix, tags as AND logic, frontmatter with strict type matching. This goes well beyond the schema's type/ default information.

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

Purpose5/5

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

The description clearly states 'Get recently modified notes' which is a specific verb+resource. It distinguishes from sibling tools like semantic_search or keyword_search by focusing on recency.

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

Usage Guidelines3/5

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

The description implies usage for retrieving recent notes but does not explicitly state when to use this tool versus alternatives like semantic_search or list_notes. No when-not or alternative guidance is provided.

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

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

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