File Search MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
File Search MCP Server
A Model Context Protocol (MCP) server that provides powerful file and directory search capabilities using keyword matching with context.
Features
File Search: Search for keywords within a specific file with configurable context lines
Directory Search: Recursively search for keywords across all files in a directory
Case Sensitivity: Optional case-sensitive or case-insensitive search
Context Lines: View surrounding lines for better context
File Filtering: Filter searches by file extension
Error Handling: Comprehensive error handling for file access issues
Related MCP server: MCP Keyword Search
Tools
1. search_keyword_in_file
Search for a keyword within a specific file and return matching lines with context.
Parameters:
file_path(string): Path to the file to search inkeyword(string): The keyword or phrase to search forcase_sensitive(boolean, optional): Whether search should be case-sensitive (default: false)context_lines(integer, optional): Number of lines before/after match to include (default: 2)
Returns: Formatted string with all matching lines, line numbers, and surrounding context.
Example:
Found 3 match(es) for 'import' in 'file_search_server.py':
--- Match 1 (Line 1) ---
>>> 1: import os
2: from typing import Optional
3: from mcp.server.fastmcp import FastMCP2. search_keyword_in_directory
Search for a keyword across all files in a directory recursively.
Parameters:
directory_path(string): Path to the directory to search inkeyword(string): The keyword or phrase to search forfile_pattern(string, optional): File extension filter (e.g., '.py', '.txt')case_sensitive(boolean, optional): Whether search should be case-sensitive (default: false)
Returns: Formatted string with all matching files and their matching lines.
Example:
Found matches for 'TODO' in 3 file(s):
š main.py (2 match(es))
Line 45: # TODO: Implement error handling
Line 78: # TODO: Add unit testsInstallation
Prerequisites
Python 3.8 or higher
pip package manager
Steps
Clone the repository:
git clone https://github.com/yourusername/file-search-mcp-server.git
cd file-search-mcp-serverInstall dependencies:
pip install -r requirements.txtUsage
With MCP Inspector (Testing)
Test your server using the MCP Inspector:
npx @modelcontextprotocol/inspector python file_search_server.pyThis opens a web interface where you can:
View available tools
Test tool calls with different parameters
See request/response details
With Claude Desktop
Locate your Claude Desktop config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Add the server configuration:
{
"mcpServers": {
"file_search": {
"command": "python",
"args": [
"/absolute/path/to/file_search_server.py"
]
}
}
}Restart Claude Desktop
Test the connection:
Look for the š icon in Claude Desktop
You should see "file_search" listed with 2 tools
With Windsurf
Locate Windsurf's MCP config file:
Windows:
%APPDATA%\Windsurf\User\globalStorage\windsurf-mcp\mcp_settings.json
Add the server configuration:
{
"mcpServers": {
"file_search": {
"command": "python",
"args": [
"/absolute/path/to/file_search_server.py"
]
}
}
}Restart Windsurf
With Cursor or VS Code (Cline)
Install the Cline extension (for VS Code)
Locate the config file:
VS Code:
%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.jsonCursor:
%APPDATA%\Cursor\User\globalStorage\cursor-mcp\config.json
Add the server configuration (same as above)
Restart your editor
Example Usage
Search in a Single File
Search for "import" in /path/to/file.pySearch in a Directory
Find all occurrences of "TODO" in /path/to/projectCase-Sensitive Search
Search for "API_KEY" (case-sensitive) in /path/to/config.pySearch Specific File Types
Search for "function" in /path/to/project, only in .js filesSupported File Types
When no file pattern is specified, the server searches these text file extensions:
Python: .py
Web: .html, .css, .js, .ts
Config: .json, .yaml, .yml, .toml, .ini, .cfg, .conf
Documentation: .txt, .md
Code: .java, .cpp, .c, .h, .hpp, .rs, .go, .rb, .php, .sh
Data: .xml
Troubleshooting
Server Not Connecting
Verify Python installation:
python --versionCheck FastMCP installation:
pip show fastmcpTest server manually:
python file_search_server.pyPath Issues on Windows
Use forward slashes:
C:/Users/name/file.pyOr escaped backslashes:
C:\\Users\\name\\file.pyAvoid spaces in file paths or use quotes
Permission Errors
Ensure the server has read permissions for the files/directories you're searching.
Development
Project Structure
file-search-mcp-server/
āāā file_search_server.py # Main MCP server implementation
āāā requirements.txt # Python dependencies
āāā README.md # This file
āāā .gitignore # Git ignore rulesRunning Tests
Use the MCP Inspector to test your server:
npx @modelcontextprotocol/inspector python file_search_server.pyTechnical Details
Protocol: Model Context Protocol (MCP)
Transport: stdio (standard input/output)
Framework: FastMCP
Language: Python 3.8+
License
MIT License - Feel free to use and modify as needed.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
Created as part of an MCP server development assignment by Saqlain Ahmed P.
Acknowledgments
Built using FastMCP
Follows the Model Context Protocol specification
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Read and search folders on your own computer with explicit consent. Files are never uploaded.
Securely search and manage workspace context files for AI agents and teams.
Search the source code (HTML, JavaScript, CSS) of web pages.
Search your Obsidian vault to quickly find notes by title or keyword, summarize related content, aā¦
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides powerful text search capabilities using the grep command-line utility, allowing users to search files and directories using both natural language descriptions and regex patterns.523 npm7MIT
- FlicenseNot gradedqualityDmaintenanceEnables keyword searching within text files with configurable case sensitivity, returning matching lines with line numbers and occurrence counts.-
- FlicenseNot gradedqualityDmaintenanceEnables searching for keywords within files with case-sensitive/insensitive options, returning matching lines with line numbers for easy reference.-
- AlicenseNot gradedqualityDmaintenanceEnables searching for keywords in files with support for case-sensitive/insensitive matching, returning line numbers, full line content, and match counts for all occurrences.MIT