A minimal, fast Model Context Protocol (MCP) server that exposes a single tool: search_file for searching within files. Designed to work with Cursor and Claude Desktop, plus a small CLI for direct use.
Repository: https://github.com/devleo10/mcp-search-server
- Bun (runtime + package manager)
- TypeScript
@modelcontextprotocol/sdkv1.21.0 (official MCP SDK)- Express 5 (HTTP mode)
- JSON-RPC 2.0 (protocol)
- Is: an MCP server that returns context/results from a file search tool
- Isn’t: a model/LLM. The model lives in the MCP client (Cursor, Claude)
bun installHTTP mode (default):
bun run start # http://localhost:3000/mcpstdio mode (for Cursor/Claude):
export MCP_TRANSPORT=stdio # macOS/Linux
$env:MCP_TRANSPORT="stdio" # Windows PowerShell
bun run startOptional: restrict file access to a workspace root
export WORKSPACE_ROOT=/path/to/project- Create or edit your MCP config
- Windows:
%APPDATA%\Cursor\mcp.json - macOS:
~/.cursor/mcp.json - Linux:
~/.config/Cursor/mcp.json
- Add the server
{
"mcpServers": {
"search-server": {
"command": "bun",
"args": ["run", "/path/to/mcp-search-server/src/server.ts"],
"cwd": "/path/to/mcp-search-server",
"env": {
"MCP_TRANSPORT": "stdio",
"WORKSPACE_ROOT": "/path/to/mcp-search-server"
}
}
}
}Windows example (use double backslashes):
{
"mcpServers": {
"search-server": {
"command": "bun",
"args": ["run", "C:\\path\\to\\mcp-search-server\\src\\server.ts"],
"cwd": "C:\\path\\to\\mcp-search-server",
"env": {
"MCP_TRANSPORT": "stdio",
"WORKSPACE_ROOT": "C:\\path\\to\\mcp-search-server"
}
}
}
}Note: Replace /path/to/mcp-search-server with your actual project directory path.
- Restart Cursor and ask:
- “What MCP tools are available?” → should list
search_file - “Search for ‘keyword’ in
samples/sample.txtwith 2 lines of context”
Tips
- Use paths relative to
WORKSPACE_ROOT - Ask for context: “with 2 lines of context”
# basic
bun run cli -- samples/sample.txt keyword
# case-insensitive with context
bun run cli -- samples/sample.txt keyword -i -c 2
# regex
bun run cli -- samples/sample.txt "function.*\(" -rOptions
-r, --regexenable regex-i, --insensitivecase-insensitive-c N, --context Ncontext lines (0–100)-m N, --max Nmax results (1–100000)
Here's how to test the tool using MCP Inspector:
-
Install MCP Inspector (if not already installed):
npm install -g @modelcontextprotocol/inspector
-
Start your server:
bun run start
-
Run MCP Inspector:
mcp-inspector http://localhost:3000/mcp
-
Test the tool:
- Select
search_filefrom the tools list - Use this sample input:
{ "path": "samples/sample.txt", "keyword": "keyword", "options": { "insensitive": true, "context": 2 } } - Click "Call Tool" to see the results
- Select
Note: Add a screenshot showing the MCP Inspector interface with the tool call and results
Input
{
"path": "samples/sample.txt",
"keyword": "keyword",
"options": {
"regex": false,
"insensitive": true,
"context": 2,
"maxResults": 1000
}
}Output (content[0].text contains JSON)
{
"matches": [ { "line": 13, "text": "..." } ],
"meta": { "path": "samples/sample.txt", "keyword": "keyword", "count": 1, "durationMs": 5 }
}bun testsrc/
server.ts # MCP server + transport
search.ts # search engine (streaming + in-memory)
bin/
search-cli.ts
samples/
tests/
- “File not found” → use paths inside
WORKSPACE_ROOTand relative to it - “Access denied: Path must be within workspace root” → fix
WORKSPACE_ROOT - Cursor doesn’t show tools → restart Cursor, check MCP logs (View → Output → MCP)
License: MIT
