Skip to main content
Glama

Search Items

keychain_search_items
Read-only

Search vault items like logins, notes, and SSH keys using text queries and filters for organization, folder, collection, or URL to locate specific credentials and data.

Instructions

Search vault items by text and filters (org/folder/collection/url).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textNo
typeNo
organizationIdNo
folderIdNo
collectionIdNo
urlNo
trashNo
limitNo

Implementation Reference

  • Tool definition and handler registration for search_items.
      `${deps.toolPrefix}.search_items`,
      {
        title: 'Search Items',
        description:
          'Search vault items by text and filters (org/folder/collection/url).',
        annotations: { readOnlyHint: true },
        inputSchema: {
          text: z.string().optional(),
          type: z
            .enum(['login', 'note', 'ssh_key', 'card', 'identity'])
            .optional(),
          organizationId: z
            .union([z.string(), z.literal('null'), z.literal('notnull')])
            .optional(),
          folderId: z
            .union([z.string(), z.literal('null'), z.literal('notnull')])
            .optional(),
          collectionId: z.string().optional(),
          url: z.string().optional(),
          trash: z.boolean().optional(),
          limit: z.number().int().min(1).max(500).optional(),
        },
        _meta: toolMeta,
      },
      async (input, extra) => {
        const sdk = await deps.getSdk(extra.authInfo);
        const items = await sdk.searchItems(input);
        const minimal = items.map((i) => sdk.minimalSummary(i));
        return {
          structuredContent: { results: minimal },
          content: [{ type: 'text', text: `Found ${minimal.length} item(s).` }],
        };
      },
    );
  • Actual implementation of item search logic using Bitwarden CLI.
    async searchItems(input: SearchItemsInput): Promise<unknown[]> {
      const { limit } = input;
      const rawText = (input.text ?? '').trim();
      const tokens = rawText.includes('|')
        ? rawText
            .split('|')
            .map((s) => s.trim())
            .filter((s) => s.length > 0)
        : rawText.length > 0
          ? [rawText]
          : [];
    
      const orgFilter = input.organizationId;
      const orgId =
        orgFilter && orgFilter !== 'null' && orgFilter !== 'notnull'
          ? orgFilter
          : undefined;
    
      const folderFilter = input.folderId;
      const folderId =
        folderFilter && folderFilter !== 'null' && folderFilter !== 'notnull'
          ? folderFilter
          : undefined;
    
      const items = await this.bw.withSession(async (session) => {
        const baseArgs: string[] = ['list', 'items'];
        if (input.url) baseArgs.push('--url', input.url);
        if (folderId) baseArgs.push('--folderid', folderId);
        if (input.collectionId)
          baseArgs.push('--collectionid', input.collectionId);
        if (orgId) baseArgs.push('--organizationid', orgId);
        if (input.trash) baseArgs.push('--trash');
    
        // NOTE: bw's `--search` does not treat "a | b" as "a OR b". If callers pass
        // a pipe-delimited string (common when combining name + username), we split
        // and union the results.
        const terms = tokens.length ? tokens : [undefined];
        const byId = new Map<string, unknown>();
    
        for (const term of terms) {
          const args = [...baseArgs];
          if (term) args.push('--search', term);
          const { stdout } = await this.bw.runForSession(session, args, {
            timeoutMs: 120_000,
          });
          const results = this.parseBwJson<unknown[]>(stdout);
          for (const raw of results) {
            if (!raw || typeof raw !== 'object') continue;
            const id = (raw as { id?: unknown }).id;
            if (typeof id === 'string' && id.length > 0) byId.set(id, raw);
          }
        }
    
        return [...byId.values()];
      });
    
      const orgFiltered = items.filter((raw) => {
        if (!raw || typeof raw !== 'object') return false;
        const item = raw as AnyRecord;
    
        if (orgFilter === 'null') {
          return item.organizationId == null;
        }
        if (orgFilter === 'notnull') {
          return typeof item.organizationId === 'string' && item.organizationId;
        }
        return true;
      });
    
      const folderFiltered = orgFiltered.filter((raw) => {
        if (!raw || typeof raw !== 'object') return false;
        const item = raw as AnyRecord;
    
        if (folderFilter === 'null') {
          return item.folderId == null;
        }
        if (folderFilter === 'notnull') {
          return typeof item.folderId === 'string' && item.folderId;
        }
        return true;
      });
    
      const filtered = folderFiltered.filter((raw) => {
        if (!raw || typeof raw !== 'object') return false;
        const item = raw as AnyRecord;
        if (!input.type) return true;
        if (input.type === 'ssh_key') return isSshKeyItem(item);
        if (input.type === 'login') return item.type === ITEM_TYPE.login;
        if (input.type === 'card') return item.type === ITEM_TYPE.card;
        if (input.type === 'identity') return item.type === ITEM_TYPE.identity;
        if (input.type === 'note')
          return item.type === ITEM_TYPE.note && !isSshKeyItem(item);
        return true;
      });
    
      return typeof limit === 'number' ? filtered.slice(0, limit) : filtered;
    }
Behavior3/5

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

The annotation readOnlyHint=true already indicates this is a safe read operation. The description adds minimal behavioral context by mentioning search filters (org/folder/collection/url), but doesn't disclose important details like search behavior (partial/full text match), pagination (implied by limit parameter but not explained), or authentication requirements. No contradiction with annotations exists.

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 extremely concise—a single sentence with zero wasted words. It's front-loaded with the core action (search vault items) and efficiently lists filter types in parentheses. Every word earns its place without redundancy or fluff.

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?

For a search tool with 8 parameters, 0% schema coverage, no output schema, and only a basic readOnlyHint annotation, the description is insufficient. It lacks details on search semantics, result format, error conditions, and parameter interactions. While concise, it doesn't provide enough context for reliable agent use given the tool's complexity.

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

Parameters2/5

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

With 0% schema description coverage for 8 parameters, the description carries full burden. It mentions text and four filter types (org/folder/collection/url), covering only 5 of 8 parameters. It omits explanation of type (with enum values), trash, and limit parameters entirely, and doesn't clarify the special null/notnull values for organizationId and folderId. The description adds some value but fails to compensate for the schema coverage gap.

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 as searching vault items with text and filters, specifying the resource (vault items) and action (search). It distinguishes itself from sibling tools like keychain_get_item or keychain_list_collections by focusing on filtered search rather than direct retrieval or listing. However, it doesn't explicitly differentiate from potential similar search tools (none exist in siblings).

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 when search is preferable to direct get/list operations, what the search scope is (e.g., personal vs organizational vaults), or any prerequisites. The agent must infer usage from the tool name and parameters alone.

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/icoretech/warden-mcp'

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