知识图谱服务工具

Binelek MCP Server 是一个提供知识图谱查询、搜索、AI交互和数据管道服务的API网关工具。

  • by k5tuck
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 k5tuck/binelek-mcp-server

使用说明

Binelek MCP服务器

Binelek平台的模型上下文协议(MCP)服务器。该服务器提供MCP工具,用于通过API网关与Binelek知识图、搜索、人工智能和数据管道服务进行交互。

特性

  • 知识图谱工具:查询、创建、更新和删除实体和关系
  • 搜索工具:语义、关键字和混合搜索功能
  • AI工具:与人工智能聊天、预测、分析实体
  • 管道工具:触发和监控数据管道
  • 管理工具:域配置、YAML验证、代码生成

安装

npm install
npm run build

配置

创建一个 .env 文件(复制自 .env.example):

BINELEK_GATEWAY_URL=http://localhost:8092
BINELEK_TENANT_ID=core
BINELEK_JWT_TOKEN=your-jwt-token-here
LOG_LEVEL=info

用法

作为独立服务器

npm start

使用克劳德桌面

添加到您的Claude Desktop配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):

{
  "mcpServers": {
    "binelek": {
      "command": "node",
      "args": ["/path/to/binelek-mcp-server/build/index.js"],
      "env": {
        "BINELEK_GATEWAY_URL": "http://localhost:8092",
        "BINELEK_TENANT_ID": "core",
        "BINELEK_JWT_TOKEN": "your-jwt-token"
      }
    }
  }
}

使用VS代码扩展

这 binelek-vscode-extension 使用此MCP服务器。有关设置说明,请参阅该项目的README。

可用工具

本体工具

  • binelek_get_entity -按ID获取实体
  • binelek_query_entities -执行Cypher查询
  • binelek_create_entity -创建新实体
  • binelek_update_entity -更新现有实体
  • binelek_delete_entity -删除实体
  • binelek_get_relationships -获取实体关系
  • binelek_create_relationship -建立关系

搜索工具

  • binelek_semantic_search -基于嵌入的语义搜索
  • binelek_keyword_search -使用Elasticsearch进行关键字搜索
  • binelek_hybrid_search -语义+关键字组合搜索

AI工具

  • binelek_ai_chat -与Binelek AI助手聊天
  • binelek_ai_predict -使用ML模型进行预测
  • binelek_ai_analyze_entity -人工智能实体分析

管道工具

  • binelek_list_pipelines -列出所有管道
  • binelek_get_pipeline -获取管道详细信息
  • binelek_trigger_pipeline -触发管道执行
  • binelek_get_pipeline_runs -获取管道运行历史记录

管理工具

  • binelek_list_domains -列出可用域
  • binelek_get_domain -获取域配置
  • binelek_get_ontology_schema -获取本体YAML模式
  • binelek_validate_yaml -验证本体YAML
  • binelek_generate_code -从YAML生成代码

认证

MCP服务器使用JWT令牌向Binelek API网关进行身份验证。你可以:

  1. 设置在环境中: BINELEK_JWT_TOKEN=your-token
  2. 在.env文件中设置:参见 .env.example
  3. 通过MCP配置传递:在Claude Desktop或VS Code中配置时

要获得JWT令牌,请通过Binelek平台进行身份验证或使用auth API:

curl -X POST http://localhost:8092/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"your-password"}'

建筑

MCP Client (Claude/VS Code)
  ↓ stdio
MCP Server (this project)
  ↓ HTTP/REST
API Gateway (localhost:8092)
  ↓ routes to
Backend Services (Ontology, Search, AI, Pipeline, etc.)

重要:MCP服务器仅与API网关通信,从不直接与后端服务通信。这确保了正确的身份验证、租户隔离和速率限制。

发展

# Install dependencies
npm install

# Build
npm run build

# Development mode (auto-reload)
npm run dev

# Type check
npm run type-check

错误处理

服务器优雅地处理错误,并以MCP格式返回错误:

{
  "content": [{
    "type": "text",
    "text": "Error: Entity not found: prop_123"
  }],
  "isError": true
}

许可证

麻省理工学院