Skip to main content

Overview

The list_libraries_tool returns a dictionary of all available documentation libraries in the OpenGround database, along with their available versions. This tool should be called before performing searches to verify which libraries and versions are available.
This tool uses aggressive caching. Results are computed once at server startup and cached for the lifetime of the MCP server process.

Parameters

This tool takes no parameters.

Return Format

Returns a dict[str, list[str]] mapping library names to sorted lists of available versions.

Structure

Ordering

  • Library names: Sorted alphabetically
  • Versions: Sorted alphabetically (not semantically versioned)
Version sorting is alphabetical, not semantic. So “10.0.0” may appear before “2.0.0”. The actual version strings depend on how they were stored during library ingestion.

Response Fields

array<string>
Array of version strings available for this library. Each version represents a complete snapshot of the documentation at that version.Example: ["0.104.0", "0.109.0", "latest"]

Example Usage

Basic Call

Response:

Empty Database

If no libraries have been added yet:

How It Works

Metadata Query

The tool executes an efficient database query:
  1. Selects distinct library_name and version pairs from the documents table
  2. Groups results by library name
  3. Sorts versions within each library
  4. Caches the complete result set

Caching Strategy

Pre-loading during server startup:The MCP server pre-loads library metadata in a background thread during initialization. This means:
  • First call may be instant (if pre-loading completed)
  • Subsequent calls are always instant (served from cache)
  • Cache persists for the server’s lifetime

Cache Location

The cache is in-memory only:
  • Module-level cache: _metadata_cache in query.py
  • Lifetime: Entire server process
  • Invalidation: Only on server restart
  • Size: Negligible (typically < 10KB even for hundreds of libraries)

Integration Patterns

Present Version Selection

Suggest Library Addition

Typical Response Examples

Small Installation

Production Setup

Best Practices

Call this tool at conversation start:When a user mentions a library, immediately call list_libraries_tool to:
  1. Verify the library exists
  2. Show available versions
  3. Let user/agent choose the appropriate version

Version Selection Strategy

When multiple versions exist:
  1. Ask the user which version they’re using
  2. Default to “latest” if available
  3. Pick newest version string (be careful with alphabetical sorting)
  4. Match user’s environment if you know their setup

Error Handling

Performance Characteristics

First Call

  • Cold start (no cache): 100-500ms depending on database size
  • Warm start (pre-loaded): < 1ms

Subsequent Calls

  • Always: < 1ms (served from memory)

Database Size Impact

Troubleshooting

Empty Results

If list_libraries_tool() returns {}:
  1. Check database exists: Verify ~/.local/share/openground/lancedb/ contains data
  2. Check table exists: Run openground list in terminal
  3. Add libraries: Run openground add <library> to populate database
  4. Check configuration: Verify db_path in ~/.config/openground/config.json

Outdated Cache

If libraries don’t appear after adding them:
  1. Restart MCP server: Cache invalidates only on restart
  2. Check server logs: Ensure library was added successfully
  3. Verify database: Run openground list to confirm library exists

Missing Expected Libraries

If libraries you added don’t appear:
  1. Check ingestion logs: Ensure openground add completed successfully
  2. Verify version: The exact version string must match
  3. Check database path: Ensure MCP server is using correct db_path
  4. Inspect table: Use LanceDB tools to directly query the table