Automate: Scripting AI Knowledge Creation with MCP CLI Tools

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.

Create an AI-Automated MCP-Driven Markdown Knowledge Base
Lesson 5 of 10

Create an AI-Automated MCP-Driven Markdown Knowledge Base

Share with a coworker

Transcript

[00:00] If you're a fan of automation, which I assume most of you are, and want to build tools around this, you can use BM for basic memory. I'm going to target my project as script generator. Then I can invoke any of the tools. I'm going to invoke the write note tool with a title of Hello World, a folder of knowledge, and content of Hi John. Then this will instantly create a Hello World file inside of my knowledge with the content of Hi John.

[00:31] So this is amazing for importing notes or generating notes. For example, Claude with a prompt of generate a list of typescript best practices and piping that to BM into my script generator project with a tool of write note and then the title TypeScript best practices and a folder of knowledge. Then we just hit enter and then however many seconds later we now have a knowledge TypeScript best practices document which was created by Cloud Code and we can store this in our memory and tweak it for personal use or for our team. So the next time I invoke an agent and I start a new conversation, I don't even need to know about that document. I can say, please load in our TypeScript best practices for imports, and it will go ahead and call our MCP tool.

[01:24] And it found, I'll scroll back up, you'll see it found the note for our best practices right in the document, so that we pulled in this sort of information only using plain English inside of the agent.