MCP Keyword Search
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Keyword Searchsearch for 'error' in log.txt case-sensitive"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Keyword Search Server
A FastAPI-based MCP (Model Context Protocol) server that provides a keyword search tool for searching within files.
Features
Keyword Search: Search for keywords in text files with line numbers and occurrence counts
Case Sensitivity: Toggle between case-sensitive and case-insensitive searches
RESTful API: Simple HTTP endpoints for easy integration
Error Handling: Handles missing files, non-text files, and invalid paths
Interactive Docs: Built-in Swagger UI for testing
Setup
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtUsage
Start the server:
python server.pyServer runs at http://127.0.0.1:8000
Test the server (in another terminal):
python test_client.pyAPI Endpoints
POST /search
Search for a keyword in a file and get all matching lines.
Request Body:
{
"file_path": "example.txt",
"keyword": "python",
"case_sensitive": false
}Response:
{
"file_path": "example.txt",
"keyword": "python",
"total_matches": 5,
"matches": [
{
"line_number": 2,
"content": "Python is a popular programming language.",
"occurrences": 1
}
]
}Parameters:
file_path(string, required): Path to the file to searchkeyword(string, required): Keyword to search forcase_sensitive(boolean, optional): Enable case-sensitive search (default: false)
Response Fields:
file_path: The searched file pathkeyword: The keyword that was searchedtotal_matches: Number of lines containing the keywordmatches: Array of matching lines with line numbers, content, and occurrence count
GET /health
Health check endpoint to verify server status.
Response:
{
"status": "healthy"
}GET /
Root endpoint with server information.
Examples
Using curl:
curl -X POST http://127.0.0.1:8000/search \
-H "Content-Type: application/json" \
-d '{"file_path": "example.txt", "keyword": "python", "case_sensitive": false}'Using Python:
import requests
response = requests.post(
"http://127.0.0.1:8000/search",
json={
"file_path": "example.txt",
"keyword": "python",
"case_sensitive": False
}
)
result = response.json()
print(f"Found {result['total_matches']} matches")Testing
The test_client.py script demonstrates various search scenarios:
Case-insensitive searches
Case-sensitive searches
Different keywords
Error handling for missing files
Run it while the server is running to see example outputs.
Error Responses
404: File not found at the specified path
400: Invalid file path or file is not readable as text
500: Internal server error while processing the file
Documentation
Interactive API documentation is available at:
Swagger UI:
http://127.0.0.1:8000/docsReDoc:
http://127.0.0.1:8000/redoc
Project Structure
mcp-keyword-search/
├── server.py # Main FastAPI server
├── test_client.py # Test script with examples
├── example.txt # Sample file for testing
├── requirements.txt # Python dependencies
└── README.md # This fileThis server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/AnsariUsaid/mcp-keyword-search'
If you have feedback or need assistance with the MCP directory API, please join our Discord server