Skip to main content
Glama
chetaniitbhilai

Keyword Search MCP Server

README.mdβ€’2.28 kB
# βœ… MCP Server – Keyword Search Tool (Case-Insensitive) This project is a simple **MCP (Model Context Protocol) Server** built using FastAPI. It includes a tool that allows users to **search for a keyword inside a file** (case-insensitive). --- ## πŸ“„ Documentation You can view the detailed documentation here: **[Assignment Documentation](https://docs.google.com/document/d/1prMqMwjT5Zi70FqnQzCr1r0WSaW4CHpoGg6EjazEonM/edit?usp=sharing)** --- ## πŸ“ Project Structure ``` mcp-server/ β”œβ”€β”€ server.py β”œβ”€β”€ tools/ β”‚ β”œβ”€β”€ __init__.py β”‚ └── search_tool.py β”œβ”€β”€ requirements.txt └── README.md ``` --- ## βš™οΈ 1. Setup Instructions ### βœ… Step 1: Clone or Create Project Folder ```bash cd mcp-server ``` ### βœ… Step 2: Create and Activate Virtual Environment (Optional but Recommended) ```bash python -m venv venv # Activate it: # On Windows: venv\Scripts\activate # On Linux/Mac: source venv/bin/activate ``` ### βœ… Step 3: Install Dependencies ```bash pip install -r requirements.txt ``` --- ## πŸš€ 2. Run the MCP Server ```bash uvicorn server:app --reload --port 8000 ``` If successful, you will see: ``` Uvicorn running on http://127.0.0.1:8000 ``` Visit in browser: ``` http://127.0.0.1:8000 ``` Or API docs (auto-generated): ``` http://127.0.0.1:8000/docs ``` --- ## πŸ” 3. Search Keyword in a File (API Usage) ### βœ… Request Format (POST `/search`) ```json { "file_path": "path/to/file.txt", "keyword": "example" } ``` ### βœ… Example using `curl`: ```bash curl -X POST "http://127.0.0.1:8000/search" \ -H "Content-Type: application/json" \ -d '{"file_path": "sample.txt", "keyword": "hello"}' ``` ### βœ… Example Response: ```json { "results": [ "Line 2: Hello World", "Line 5: hElLo again" ] } ``` --- ## πŸ›  4. Code Summary ### `server.py` Defines API endpoint `/search`. --- ## βœ… 5. Features βœ” FastAPI-powered MCP server βœ” Case-insensitive keyword search βœ” Shows line number + text where keyword exists βœ” Error handling for missing files --- ## πŸ“Œ 6. Future Improvements (Optional) * πŸ”Ή Search across directories * πŸ”Ή Regex support * πŸ”Ή Return JSON with `{line_number, content}` format * πŸ”Ή File type filtering (.txt, .py, .md, etc.)

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/chetaniitbhilai/Ressl_MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server