图书与文件搜索服务

一个基于TypeScript和Node.js的MCP服务器,提供通过作者搜索图书和在本地文件中搜索关键词的功能。

  • by maniranjan2023
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 maniranjan2023/MCP-Server

使用说明

📚 MCP Open Library & File Search Server

This project is an MCP (Model Context Protocol) server built with TypeScript and Node.js. It provides two core tools:

  1. search_author — search for books by author using the Open Library API.
  2. search_in_file — search for a keyword inside any local text file.

🚀 Features

🔍 search_author

Fetches book data by a given author name from the Open Library API.

Input

{
  "author": "tolkien"
}

Output A JSON response containing book search results.


🗂 search_in_file

Scans a file for a keyword and returns the matching lines and their numbers.

Input

{
  "filePath": "./sample.txt",
  "keyword": "example"
}

Output

Found 2 match(es) for "example" in "./sample.txt":

Line 3: This is an example line
Line 8: Another example text

🏗️ Project Structure

MCP/
├── build/           # Compiled JS files
├── src/             # Source TypeScript files
│   └── index.ts
├── sample.txt       # Example file for keyword search
├── package.json
├── tsconfig.json
├── .gitignore
└── README.md

⚙️ Setup & Run

  1. Install dependencies

    npm install
    
  2. Build

    npm run build
    
  3. Run

    npm start
    

    Or directly (without compiling):

    npm run dev
    

🧩 Example: Using in MCP Inspector

For search_in_file:

{
  "filePath": "./sample.txt",
  "keyword": "OpenAI"
}

For search_author:

{
  "author": "tolkien"
}

🧠 Technologies


🧾 License

MIT License © 2025


👨‍💻 Author

Your Name 📧 maniranjan1512@gmail.com 🌐 github.com/maniranjan2023