genkitx-fs
v0.0.1
Published
A Genkit plugin for interacting with the filesystem.
Readme
Genkit Filesystem Tools
This Genkit plugin provides a set of tools for interacting with the filesystem. These tools allow Genkit flows to perform filesystem operations like listing files, reading and writing files, creating directories, and deleting files and directories.
Installation
npm install genkitx-fsUsage
Here is an example of how to use the filesystem tools in a Genkit flow:
import { genkit, z } from "genkit";
import { googleAI } from "@genkit-ai/googleai";
import { defineFsTools } from "genkitx-fs";
const ai = genkit({
plugins: [googleAI()],
model: googleAI.model("gemini-2.5-flash"),
});
const fsTools = defineFsTools(ai);
// To register only readonly tools, you can pass the `readonly` option:
// const fsTools = defineFsTools(ai, { readonly: true });
ai.defineFlow(
{
name: "query",
inputSchema: z
.string()
.default(
'Create a file named "test.txt" with the content "Hello, world!". ' +
'Then, list the files in the current directory. Current directory: ' +
process.cwd()
),
},
async (prompt) => {
const { text } = await ai.generate({
prompt,
tools: [...fsTools],
});
return text;
}
);This flow takes a natural language prompt and uses the filesystem tools to perform operations on the local filesystem.
Available Tools
This plugin provides the following tools:
fs_cwdfs_listfs_read
When readonly option is not set or is false, the following tools are also available:
fs_writefs_deletefs_mkdir
MCP Server
You can run genkitx-fs as an MCP server (stdio) using the following command:
npx -y genkitx-fsLearn more about Genkit on https://genkit.dev
Get started with Genkit: https://genkit.dev/docs/get-started/
