文件搜索服务器

一个基于Python的MCP服务器,用于在文件系统中搜索文件并返回JSON格式的结果。

  • by Tryd0g0lik
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 tryd0g0lik/mcp-server

使用说明

MCP file search server

It is a simple MCP server written in Python that searches for files in the file system based on a path fragment and returns the results in JSON format.

Installation

  1. Clone this repository or download the script 'file_finder_mcp.py'.
  2. Make sure you have Python 3.x installed on your system.

Запуск сервера

  1. Open the terminal and go to the directory containing 'file_finder_mcp.py'.
  2. Start the server with the following command:
python file_finder_mcp.py

Описание

For customization Cline in VSCode to work with the presented MCP server, perform the following steps. Start by installing and configuring all the necessary components.

Step 1: Install VSCode

You have VSCode installed.

Шаг 2: Установка расширения Cline

  1. Open the VSCode.
  2. Go to the Extensions section through the sidebar or click 'Ctrl+Shift+X'.
  3. Enter Cline in the search.
  4. Find the Cline extension and install it.

Шаг 3: Установка Python

Make sure you have Python 3.x installed on your computer.

Step 4: Start the MCP server

Download or create a file 'file_finder_mcp.py(Server code given above).
Open the terminal in VSCode (Ctrl+`) or use any other terminal.
Go to the folder where file_finder_mcp.py is located.
Start the server with the command:

python file_finder_mcp.py

The server will start on port 8080. You will see a message:

Starting MCP server on port 8080...

Step 5: Configure Cline to work with an MCP server

In VSCode, open the Cline configuration file. If the file does not exist, create it in the .vscode folder of your project:

The Path: '.vscode/cline-config.json'

Add the configuration for the MCP server:

{
  "mcpServers": {
    "file-finder-mcp": {
      "args": [
        "python",
        "file_finder_mcp.py"
      ],
      "command": "python",
      "autoApprove": [],
      "disabled": false
    }
  }
}

Here:

  • 'command': Command to start the server (python).
  • 'args': Аргументы для запуска сервера (файл file_finder_mcp.py).
  • 'autoApprove': List of automatically approved actions (leave empty).
  • 'disabled': If false, the server will be active. Save the configuration file.

Шаг 6: Подключение Cline к MCP серверу

Restart VSCode to apply the configuration changes.
Make sure the MCP server is running (see Step 4).
In VSCode, open the Cline panel (if it does not open automatically).
Cline should automatically connect to the MCP server using the configuration from 'cline-config.json'.

Step 7: Sample request and response

curl "http://localhost:8080/?path=example"

or you have Postman installed. Pfgecnbnt 'GETRequest

http://localhost:8080/?path=readme
[
    {
        "name": "readme.markdown",
        "path": "/AdobePhotoshop\\Adobe\\Adobe Photoshop CC 2019\\Required\\Generator-builtin\\node_modules\\optimist\\readme.markdown",
        "size": 11208,
        "creation_date": "2019-10-17 15:25:58"
    },
    {
        "name": "readme.markdown",
        "path": "/AdobePhotoshop\\Adobe\\Adobe Photoshop CC 2019\\Required\\Generator-builtin\\node_modules\\optimist\\node_modules\\minimist\\readme.markdown",
        "size": 1712,
        "creation_date": "2019-10-17 15:25:58"
    },
    {
        "name": "readme.txt",
        "path": "/AdobePhotoshop\\Adobe\\Adobe Photoshop CC 2019\\Required\\Linguistics\\Providers\\Plugins2\\AdobeHunspellPlugin\\dictionaries\\tr_TR\\readme.txt",
        "size": 362,
        "creation_date": "2019-10-17 15:56:44"
    },
    {
        "name": "readme.md",
        "path": "/AdobePhotoshop\\Adobe\\Adobe Photoshop CC 2019\\Required\\Plug-ins\\Generator\\assets.generate\\node_modules\\os-tmpdir\\readme.md",
        "size": 725,
        "creation_date": "2019-10-17 15:25:58"
    },
]