Example: Using filesystem MCP
Filesystem is a simple MCP that allows the LLM to execute disk based tools on your server. For example, list files, read file, write file etc. In this guide, we will integrate it with<C1Chat />
to create a
conversational agent that can answer questions about your filesystem.
Setting up the MCP Client
First, let’s install the necessary dependencies to work with MCP in your C1 application.You’ll need to install the MCP client library and any specific MCP servers you want to use. For this example, we’ll use a filesystem MCP server.
cli
Create an MCP client integration
Now let’s create the MCP client using the@modelcontextprotocol/sdk
package.
This implementation connects to a filesystem MCP server and handles tool execution.
app/api/chat/mcp.ts
Integrate MCP with your C1 agent
Now let’s update your chat route to use the streamlined MCP integration from the thesysdev examples. This approach uses OpenAI’srunTools
method for automatic tool execution.
Install the dependencies for streaming
cli
app/api/chat/route.ts
Test your MCP-enabled agent
Your agent now has access to powerful filesystem operations through MCP! You can test it with prompts like:- File operations: “Create a new file called ‘notes.txt’ with today’s meeting summary”
- Directory browsing: “List all the files in the current directory”
- File reading: “Read the contents of package.json and summarize the project dependencies”
- File searching: “Find all TypeScript files in the src directory”

View Source Code
See the full code with integrations for thinking states and error handling.