Skip to main content
Glama

keychain_create_note

Create secure notes in your Bitwarden vault to store sensitive information with customizable fields and organizational options.

Instructions

Create a secure note item.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
notesNo
fieldsNo
favoriteNo
organizationIdNo
collectionIdsNo
folderIdNo

Implementation Reference

  • Tool registration for "keychain_create_note" calling SDK's createNote method.
      `${deps.toolPrefix}.create_note`,
      {
        title: 'Create Note',
        description: 'Create a secure note item.',
        inputSchema: {
          name: z.string(),
          notes: z.string().optional(),
          fields: z
            .array(
              z.object({
                name: z.string(),
                value: z.string(),
                hidden: z.boolean().optional(),
              }),
            )
            .optional(),
          favorite: z.boolean().optional(),
          organizationId: z.string().optional(),
          collectionIds: z.array(z.string()).optional(),
          folderId: z.string().optional(),
        },
        _meta: toolMeta,
      },
      async (input, extra) => {
        if (isReadOnly) return readonlyBlocked();
        const sdk = await deps.getSdk(extra.authInfo);
        const created = await sdk.createNote(input);
        return {
          structuredContent: { item: created },
          content: [{ type: 'text', text: 'Created.' }],
        };
      },
    );
  • Implementation of createNote method in KeychainSdk, which constructs a note and calls the Bitwarden CLI.
    async createNote(input: {
      name: string;
      notes?: string;
      fields?: ItemFieldInput[];
      reveal?: boolean;
      favorite?: boolean;
      organizationId?: string;
      collectionIds?: string[];
      folderId?: string;
    }): Promise<unknown> {
      return this.bw.withSession(async (session) => {
        if (this.syncOnWrite()) {
          await this.bw
            .runForSession(session, ['sync'], {
              timeoutMs: 120_000,
            })
            .catch(() => {});
        }
    
        const tpl = (await this.bw.getTemplateItemForSession(
          session,
        )) as AnyRecord;
        const item = deepClone(tpl);
        item.type = ITEM_TYPE.note;
        item.name = input.name;
        item.notes = input.notes ?? '';
        item.favorite = input.favorite ?? false;
        if (input.organizationId) item.organizationId = input.organizationId;
        if (input.folderId) item.folderId = input.folderId;
        if (!item.secureNote || typeof item.secureNote !== 'object') {
          item.secureNote = { type: 0 };
        }
        item.fields = normalizeFields(input.fields) ?? [];
        if (input.collectionIds) item.collectionIds = input.collectionIds;
    
        const encoded = encodeJsonForBw(item);
        const { stdout } = await this.bw.runForSession(
          session,
          ['create', 'item', encoded],
          { timeoutMs: 120_000 },
        );
        const created = this.parseBwJson<AnyRecord>(stdout);
    
        if (input.collectionIds?.length) {
          const encodedCols = encodeJsonForBw(input.collectionIds);
          await this.bw
            .runForSession(
              session,
              ['edit', 'item-collections', String(created.id), encodedCols],
              { timeoutMs: 120_000 },
            )
            .catch(() => {});
        }
    
        return this.maybeRedact(created, input.reveal);
      });
    }

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