Chainlit and MCP Filesystem: connect AI to local files

Learn MCP architecture and a Chainlit setup with OpenAI, then follow file creation, reading and a deletion request that moves the file to a backup.

Player not loading? Watch on YouTube

The original video is in French. This tutorial explains Model Context Protocol (MCP) through a Chainlit chat application connected to OpenAI and an MCP Filesystem server. The example gives an AI agent access to local files through tools. It uses an OpenAI model; the tutorial does not demonstrate how to run models locally or operate offline.

The speaker introduces the host, client and server roles. Chainlit is the host application, the MCP client handles protocol communication, and servers expose tools with names, descriptions and input schemas. The application calls those tools rather than giving the model a direct connection to the server.

The setup uses the Chainlit and OpenAI libraries plus a Node.js MCP Filesystem server. When a chat session starts, the application retrieves and displays the available tools. For each user message, it converts the MCP tool definitions into OpenAI's function format. The model selects tools, the application executes them, and a second model call produces the response. The example configures a root directory for file access. This configuration is not demonstrated as a general security sandbox.

The demonstration creates Jordan.txt, writes text into it and reads a Markdown file. A request to delete Jordan.txt instead triggers a move operation that retains a backup. That result shows why the selected tool and its arguments matter when checking whether a file operation matched the request.