Lesson
Automate: Scripting AI Knowledge Creation with MCP CLI Tools
Learn how to programmatically generate and import notes into your knowledge base using a command-line tool, making that knowledge available to your AI agents.
- Access
- Included
- Transcript
- Needs source
AI agents are only as smart as the information they can access. Manually curating and feeding them knowledge is a slow, tedious process. This lesson demonstrates a powerful, automated approach using a command-line interface (CLI) tool to programmatically generate structured notes, making them instantly available to AI agents like Cursor's Composer.
This method allows you to script the creation of your knowledge base, import notes from other sources, or even pipe the output of other AI models directly into your "second brain." The end result is a robust, up-to-date knowledge system that empowers your AI agents to provide more accurate and context-aware assistance.
Simple Note Creation
At its core, the workflow uses a CLI tool to create a markdown file with the correct frontmatter and content. You can specify the title, folder, and content directly from the command line.
This is perfect for simple scripting or quick note creation without leaving the terminal.
bm --project "script-generator" tool write-note --title "Hello World" --folder "knowledge" --content "Hi John"
This command generates a Hello World.md file inside the knowledge folder:
---
title: Hello World
type: note
permalink: knowledge/hello-world
---
Hi John
Automating with AI-Generated Content
The real power comes from chaining tools together. You can use one tool (like an AI model) to generate content and pipe its output directly into the note-creation tool. This creates a fully automated pipeline for populating your knowledge base.
Here, we ask Claude to generate a list of TypeScript best practices and pipe the result directly into our bm tool to create a new note.
claude -p "Generate a list of TypeScript best practices" | bm --project "script-generator" tool write-note --title "TypeScript Best Practices" --folder "knowledge"
The Payoff: Instant AI Recall
Once these notes are part of your project's knowledge base, your AI agent can find and use them based on simple, natural language queries. You don't need to remember the exact file name or location; the agent's semantic search capabilities handle the retrieval.
When asked to find specific information, the agent can recall the document you just created.
Please load in our TypeScript best practices for imports.
By automating the creation of your knowledge base, you build a powerful, scalable system that enhances the capabilities of your AI tools, making them more effective for both personal productivity and team collaboration.