文件管理API

一个基于FastAPI的轻量级API,用于与本地文件交互,包括列出文件和读取文件内容。

  • by Vinipallakki
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 vinipallakki/mcp-demo

使用说明

📂 MCP演示项目

这很简单 模型上下文协议(MCP) 演示项目。 它公开了一个轻量级的API,以便使用 快速 API.


⚡ 特性

  • 列出内部文件 docs/ 文件夹
  • 通过API读取文件的内容
  • 内置于 快速 API + 乌维科恩
  • 为RAG、LLM或自定义工具扩展MCP的简单入口点

📂 项目结构

github_mcp/
│── docs/                # Text files for testing
│   ├── sample_1.txt
│   ├── sample_2.txt
│
│── server.py            # MCP FastAPI server
│── requirements.txt     # Python dependencies
│── README.md            # Project documentation
│── .env                 # (optional) environment variables

🚀 设置和运行

1.克隆仓库

git clone https://github.com/<your-username>/github_mcp.git
cd github_mcp

2.创建虚拟环境

python -m venv venv
source venv/bin/activate   # Mac/Linux
venv\Scripts\activate      # Windows

3.安装依赖项

pip install -r requirements.txt

4.运行MCP服务器

python server.py

服务器将在以下时间启动: 👉 http://127.0.0.1:8000


📡 API终点

✅ 列出文件

GET /list_files

示例响应:

{"files": ["sample_1.txt", "sample_2.txt"]}

📖 读取文件

GET /read_file/{filename}

例子:

curl http://127.0.0.1:8000/read_file/sample_1.txt

答复:

{"filename": "sample_1.txt", "content": "This is a test file."}

🛠️ 后续步骤

  • 添加 LLM动力嵌入式 (RAG管道)
  • 扩展与 聊天端点
  • 与集成 LangChain/MCP客户端

📜 许可证

MIT许可证。免费使用和修改。


你想让我也包括一个 requirements.txt 片段 在README中,这样GitHub用户就可以在不打开文件的情况下复制粘贴了?