A custom Model Context Protocol (MCP) implementation that allows Gemini AI to interact directly with your local file system. This project consists of both an MCP Server that exposes file system tools and an MCP Client that integrates with Google's Gemini AI.
- Local File Interaction: Search, read, and write files directly in your local environment.
- AI-Powered Assistance: Integrated with Gemini AI (Wizard-Bot) for intelligent file analysis and code generation.
- Secure Workspace: Operations are restricted to a specific workspace directory (
mcp_workspaceby default) to ensure security. - Standardized Protocol: Built using the Model Context Protocol (MCP) SDK.
search_files: Recursively search for files in the workspace matching a pattern.read_file: Read the content of a specific file.write_file: Create or overwrite a file with specified content.
analyse_code: Analyse the code file by taking the filePath as a argumentgenerate_file: Generate the file from a description by taking the file-name, description and language as a argument.summarize_workspace: Summarize the entire workspace
-
Clone the repository:
git clone <repository-url> cd Custom-Local-MCP-Server
-
Install dependencies:
npm install
The application requires an API key from Google Gemini to function. Create a .env file in the root directory and add the following variables:
# Required: Your Google Gemini API Key
GEMINI_API_KEY=your_api_key_here
# Optional: The Gemini model to use (Defaults to gemini-1.5-flash-lite)
# Note: Ensure the model name is correct as per Google's latest releases.
GEMINI_MODEL=gemini-1.5-flash-lite
# Optional: Custom workspace path for file operations
# Defaults to a folder named 'mcp_workspace' in the project root if not set.
MCP_WORKSPACE_PATH=./mcp_workspace
#Required: For displaying the suggestion while typing
MAX_VISIBLE_SUGGESTION=5To start the interactive CLI client:
npm run devOnce started, you can chat with Wizard-Bot and ask it to perform file operations. For example:
- "Search for all .ts files in my workspace."
- "Read the content of src/server.ts and explain it."
- "Create a new file called hello.txt with the text 'Hello from MCP!'"
Type exit or quit to end the session.
To test the MCP server functionality, you can use the MCP Inspector:
npm run testsrc/server.ts: The MCP Server implementation that defines and registers tools.src/client.ts: The MCP Client that connects to the server and handles the AI chat loop.src/tools/: Contains the individual tool implementations (search, read, write).src/utils/: Utility functions for directory walking and path validation.mcp_workspace/: The default directory where all file operations occur.
This tool has write access to your local files within the ALLOWED_DIR (specified by MCP_WORKSPACE_PATH). Always review the actions the AI is proposing before allowing it to proceed if used in a production environment.