TypeScript MCP with Filesystem Server and Ollama Integration
About
A TypeScript example showcasing the integration of Ollama with the Model Context Protocol (MCP), specifically the Filesystem MCP Server. This project provides an interactive command-line interface for an AI agent that can utilize filesystem tools.
Details
- Author
- ausboss
- Downloads
- 446
- Categories
- AI
Jump to
- MCP client implementation using the official TypeScript SDK.
- Filesystem interaction like listing directories and reading files.
- Ollama integration for an AI agent with tool calling.
- Interactive command‑line chat interface.
- Configuration‑driven setup via mcp-config.json.
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
TypeScript MCP with Filesystem Server and Ollama IntegrationCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Install Node.js (≥18), Ollama, and globally install the Filesystem MCP Server. Clone the repository, run npm install, configure mcp-config.json with server and model details, then execute npm run start to start an interactive chat session.
read_file
Read the complete contents of a file as text. DEPRECATED: Use read_text_file instead.
read_text_file
Read the complete contents of a file from the file system as text. Handles various text encodings and provides detailed error messages if the file cannot be read. Use this tool when you need to examine the contents of a single file. Use the 'head' parameter to read only the first N lines of a file, or the 'tail' parameter to read only the last N lines of a file. Operates on the file as text regardless of extension. Only works within allowed directories.
read_media_file
Read a file and return it as a base64-encoded content block with its MIME type. Image and audio files are returned as image/audio content; any other file type is returned as an embedded resource. Only works within allowed directories.
read_multiple_files
Read the contents of multiple files simultaneously. This is more efficient than reading files one by one when you need to analyze or compare multiple files. Each file's content is returned with its path as a reference. Failed reads for individual files won't stop the entire operation. Only works within allowed directories.
write_file
Create a new file or completely overwrite an existing file with new content. Use with caution as it will overwrite existing files without warning. Handles text content with proper encoding. Only works within allowed directories.
edit_file
Make line-based edits to a text file. Each edit replaces exact line sequences with new content. Returns a git-style diff showing the changes made. Only works within allowed directories.
create_directory
Create a new directory or ensure a directory exists. Can create multiple nested directories in one operation. If the directory already exists, this operation will succeed silently. Perfect for setting up directory structures for projects or ensuring required paths exist. Only works within allowed directories.
list_directory
Get a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Only works within allowed directories.
list_directory_with_sizes
Get a detailed listing of all files and directories in a specified path, including sizes. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is useful for understanding directory structure and finding specific files within a directory. Only works within allowed directories.
directory_tree
Get a recursive tree view of files and directories as a JSON structure. Each entry includes 'name', 'type' (file/directory), and 'children' for directories. Files have no children array, while directories always have a children array (which may be empty). The output is formatted with 2-space indentation for readability. Only works within allowed directories.
move_file
Move or rename files and directories. Can move files between directories and rename them in a single operation. If the destination exists, the operation will fail. Works across different directories and can be used for simple renaming within the same directory. Both source and destination must be within allowed directories.
search_files
Recursively search for files and directories matching a pattern. The patterns should be glob-style patterns that match paths relative to the working directory. Use pattern like '*.ext' to match files in current directory, and '**/*.ext' to match files in all subdirectories. Returns full paths to all matching items. Great for finding files when you don't know their exact location. Only searches within allowed directories.
get_file_info
Retrieve detailed metadata about a file or directory. Returns comprehensive information including size, creation time, last modified time, permissions, and type. This tool is perfect for understanding file characteristics without reading the actual content. Only works within allowed directories.
list_allowed_directories
Returns the list of directories that this server is allowed to access. Subdirectories within these allowed directories are also accessible. Use this to understand which directories and their nested paths are available before trying to access files.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"typescript mcp with filesystem server and ollama integration": {
"filesystem": {
"command": "npx",
"args": [
"@modelcontextprotocol/server-filesystem",
"./"
]
}
}
}
}
McpServers
{
"filesystem": {
"command": "npx",
"args": [
"@modelcontextprotocol/server-filesystem",
"./"
]
}
}
TypeScript MCP with Filesystem Server and Ollama Integration
This project demonstrates how to interact with a Model Context Protocol (MCP) server using TypeScript, specifically focusing on the Filesystem MCP Server. This project leverages the official @modelcontextprotocol/sdk TypeScript SDK to facilitate communication with MCP servers. It also provides an example of integrating this setup with Ollama to create an AI agent capable of interacting with your local file system.
✨ Features
- MCP Client Implementation: Shows how to create and connect to an MCP server using TypeScript.
- Filesystem Interaction: Provides an example of using the Filesystem MCP Server to perform operations like listing directories.
- Ollama Integration: Demonstrates how to use Ollama as an AI agent to process prompts and utilize the filesystem tools exposed by the MCP server.
- Tool Calling: Implements the concept of tool calling, allowing the AI agent to request and utilize functionalities provided by the MCP server.
- Interactive Chat Interface: Offers a simple command-line interface to interact with the Ollama-powered agent.
- Configuration-Driven: Uses a mcp-config.json file for easy configuration of MCP server details and Ollama settings.
🚀 Prerequisites
Before running this project, ensure you have the following installed:
- Node.js: (Version 18 or higher recommended)
- npm or yarn: (Package managers for JavaScript)
- Ollama: You need to have Ollama installed and running. You can find installation instructions on the Ollama website.
- Globally Installed Filesystem MCP Server: Install the @modelcontextprotocol/server-filesystem package globally:
npm install -g @modelcontextprotocol/server-filesystem
# or
yarn global add @modelcontextprotocol/server-filesystem
-
node or npx in your PATH: The project relies on executing the Filesystem MCP Server. Ensure that either the node executable (if running the server directly) or npx (to execute the server package) is accessible in your system's PATH environment variable.
🛠️ Installation
1. Clone the repository:
git clone https://github.com/ausboss/mcp-ollama-agent.git
cd mcp-ollama-agent
2. Install dependencies:
npm install
# or
yarn install
⚙️ Configuration
The project's configuration is managed through the mcp-config.json file at the root of the project.
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["@modelcontextprotocol/server-filesystem", "./"]
}
},
"ollama": {
"host": "http://localhost:11434",
"model": "qwen2.5:latest"
}
}
- mcpServers: This section defines your MCP servers.
- filesystem: This is the configuration for the Filesystem MCP Server.
- command: The command to execute the server. Here, we are using npx to run the globally installed @modelcontextprotocol/server-filesystem package. You can also directly specify the path to the node executable if you prefer to run the server script directly.
- args: An array of arguments passed to the command. In this case, ./ specifies the root directory that the Filesystem MCP Server will have access to. Adjust this path carefully to control the server's access.
- ollama: This section configures the connection to your Ollama server.
- host: The address of your Ollama server. The default is http://localhost:11434.
- model: The name of the Ollama model you want to use. Ensure this model supports tool calling (functions). Popular models like qwen2.5:latest often have this capability. You can check the model's documentation or Ollama's available models.
Important:
- Filesystem Access: Be cautious when configuring the args for the Filesystem MCP Server. The path specified here determines the directories the AI agent will be able to interact with. Avoid giving access to sensitive areas.
- Ollama Model: Ensure the specified Ollama model supports the concept of "tools" or "functions" in its API. This is crucial for the integration to work correctly.
▶️ Running the Application
To start the interactive chat with the Ollama agent, run the following command:
```bash
npm run start
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.
