ホーム AI・IT Letting AI Read and Write Files (SillyTavern)

Letting AI Read and Write Files (SillyTavern)

三浦 拓海 三浦 拓海 • 更新: • 公開: • 読了約 14 分
目次
n596421c46dc5

This time, we are talking about adding a file system tool to SillyTavern in a “secure way.” Rest assured, in this method, the tool runs within an isolated environment called a Docker container and can only read and write files on the host (your computer) within a specified shared folder.

Now, how do you save and organize your story data?

My recommendation this time is the “file system” that everyone is already used to.
Yes, for example, you can create folders for stories or character names, and freely put characters, locations, chat histories, chat summaries, and other text data inside—of course, you can also create subfolders. You don't need dedicated software, it's clear what is where, you can open and edit it at any time, copying and backing up is easy, and it has the best compatibility with other UIs, clients, and agents.

Simple is best.

For example, here are some ways to use it:

  • Just by saying “Load XX” at the beginning of a chat, the AI will automatically read all the files. This prepares you to start (or continue) your favorite story.

  • By saying “Write information about the character, location, event, etc., to XX” in the latter half of the chat, the AI will create and write to a file. This expands the world of the story and provides the data needed to start the next chat (or next chapter).

  • When you want to create a new world but it's hard to write everything manually from scratch. You can refine ideas while talking with the AI, and when you think it's good, have it write that data to a file.

In this method, files are read and written by telling the AI what you want and how you want it. It has a higher degree of freedom compared to automated summary or read/write tools, and above all, it is simple and intuitive!

How to add the file system tool

I wish I could say it installs with one click... but it requires some knowledge of MCP and Linux, and I wrote this concisely to avoid a long post, so if there are parts you don't understand, I think you can get detailed explanations by feeding this post to an AI and asking questions.

Overview: Run an MCP server for file system access inside a Docker/Podman container with a shared folder configured. It is isolated, so the AI cannot access the host's file system (only the shared folder). Since many MCP servers do not support HTTP connections, we also use a tool called 1mcp. Connect to the file system server from SillyTavern via MCP (HTTP) to freely read and write within the shared folder.

1 Install SillyTavern's MCP extension
https://github.com/bmen25124/SillyTavern-MCP-Server
https://github.com/bmen25124/SillyTavern-MCP-Client

2 Create a shared folder
Create one folder for sharing (e.g., /home/user/ai/share) and change the permissions so that other users can also read and write to it.

3 Create a Docker/Podman container

podman run -d --name mcp-filesystem --network=host -v /home/user/ai/share:/share ubuntu:24.04 sleep infinity

4 Enter the container, update the system, install necessary software, and create a user account (it is best not to set up the server as root)

5 Install the file system server as a user
https://github.com/mark3labs/mcp-filesystem-server
I use this one, but others are fine too.

Note: If you install it as is, files created by the server will be write-protected for other users. In other words, you would have to change permissions every time you want to edit or delete a file written by the AI. You can avoid this by editing the source and compiling it using the following steps.

git clone https://github.com/mark3labs/mcp-filesystem-server
cd mcp-filesystem-server/

Edit: filesystemserver/handler/write_file.go

Change: if err := os.MkdirAll(parentDir, 0755); err != nil 
To: if err := os.MkdirAll(parentDir, 0777); err != nil 

Change: if err := os.WriteFile(validPath, []byte(content), 0644); err != nil 
To: if err := os.WriteFile(validPath, []byte(content), 0666); err != nil 

Edit: filesystemserver/handler/create_directory.go

Change: if err := os.MkdirAll(validPath, 0755); err != nil 
To: if err := os.MkdirAll(validPath, 0777); err != nil 

Compile

go build

A binary called mcp-filesystem-server will be created; please use this.

6 1mcp
https://github.com/1mcp-app/agent
Install it, create a configuration file (e.g., 1mcp.json), and launch it with the configuration file provided as an argument as described in the 1mcp documentation.

The configuration file will look something like this:

 "mcpServers": 
 "file_system": 
 "command": "/home/user/mcp-filesystem-server/mcp-filesystem-server",
 "args": [
 "/share"
 ]
 
 

7 From SillyTavern > Extension > MCP Settings, configure the MCP and connect to the server.

8 You are done! Now, enable tool calling in SillyTavern, select an LLM model that supports tool calling, and test whether the AI can read and write files within the shared folder (in this case, /share). When you copy a folder into the shared folder, change the folder's permissions so that other users can also read and write to it.

Enjoy ✨

Related
  • [Japanese LLM] Tried using NanoGPT with SillyTavern [NSFW✅]

  • (Video) Let's generate images with SillyTavern!

  • (Video) Introduction to SillyTavern ~To Dream Freely~

同じカテゴリの記事

三浦 拓海
コンテンツディレクター 三浦 拓海
プロフィールを見る →

映画と連続ドラマの公開情報を追う担当。配給会社のプレスシートと公式サイトの発表日を確認したうえで執筆します。

おすすめの関連記事