无效MCP服务器
该项目提供了一个模型上下文协议(MCP)服务器,用于存储和检索LLM上下文数据。它与 run_local.py 用于运行轻量级的Hugging Face模型 app.py 用于简单的Streamlit UI。
快速开始
- 安装必备组件
- Node.js和npm - Python 3.11 - PostgreSQL(确保服务正在运行)
- 安装依赖项
npm install # Node packages
pip install -r requirements.txt- 配置数据库
创建一个 .env 在项目根目录中创建文件,并至少设置以下变量:
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_NAME=llm_context_db
DATABASE_USER=your_db_user
DATABASE_PASSWORD=your_db_password # must be a string
PORT=3000
JWT_SECRET=change-me-in-production-min-32-chars如果 DATABASE_PASSWORD 如果缺少,您将看到错误: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string.
- 构建服务器
npm run build- 运行一切
python start.pyMCP API将在 http://localhost:3000 本地模型服务器位于 http://localhost:8000.按 Ctrl+C 阻止他们。
- 可选:启动Streamlit界面
streamlit run app.py开发技巧
- 使用运行测试
pytest和npm test.
- 仅使用以下命令启动本地模型
python run_local.py --model sshleifer/tiny-gpt2 --port 8000.
- 格式和线头
pre-commit run --all-files.
setup.sh如果需要,提供交互式数据库设置。
- 安装依赖项
- 节点: npm install - python pip install -r requirements.txt
- 构建:
npm run build
- 测试:
npm test对于Node,pytest对于Python
- 运行本地模型:
python run_local.py --model sshleifer/tiny-gpt2 --port 8000
- 流线型UI:
streamlit run app.py
一键开始
要一步启动MCP服务器和本地模型服务器,请运行:
python start.py这 start.py 脚本是跨平台的,可以安装任何缺失的节点和 Python依赖关系,必要时构建TypeScript服务器,然后启动 MCP服务器与本地模型服务器并排。在类Unix系统上,你可以 也使用 ./start.sh.
该脚本安装缺少的节点依赖关系,在需要时构建服务器,然后在本地模型服务器旁边启动MCP服务。连接细节打印在终端上,便于与IDE和工具集成。
IDE集成
要将IDE的上下文功能连接到MCP服务器,请提供如下配置文件 ide_config.json 指向 start.py 在这个存储库中。
替换 /path/to/Void-MCP-Server/start.py 使用系统上的绝对路径:
{
"context_servers": {
"my-mcp-server": {
"command": {
"path": "python",
"args": [
"/path/to/Void-MCP-Server/start.py"
],
"env": {}
},
"settings": {}
}
}
}跑 python start.py --help 对于可用选项,例如 --model, --port,以及 --model-port 以定制服务器。
