Brightsy MCP 服务器
实现模型上下文协议的服务器,用于将大型语言模型连接到Brightsy AI代理,允许用户向这些代理发送消息并接收响应。
服务介绍
Brightsy MCP 服务器
这是一个 Model Context Protocol (MCP) 服务器,用于连接到 Brightsy AI 代理。
安装
npm install
使用方法
要启动服务器:
npm start -- --agent-id=<your-agent-id> --api-key=<your-api-key>
或者使用位置参数:
npm start -- <your-agent-id> <your-api-key> [tool-name] [message]
您还可以提供一个初始消息发送给代理:
npm start -- --agent-id=<your-agent-id> --api-key=<your-api-key> --message="Hello, agent!"
自定义工具名称
默认情况下,MCP 服务器注册了一个名为 "brightsy" 的工具。您可以使用 --tool-name 参数来自定义此名称:
npm start -- --agent-id=<your-agent-id> --api-key=<your-api-key> --tool-name=<custom-tool-name>
您也可以将工具名称作为第三个位置参数设置:
npm start -- <your-agent-id> <your-api-key> <custom-tool-name>
或者使用 BRIGHTSY_TOOL_NAME 环境变量:
export BRIGHTSY_TOOL_NAME=custom-tool-name
npm start -- --agent-id=<your-agent-id> --api-key=<your-api-key>
环境变量
可以使用以下环境变量来配置服务器:
BRIGHTSY_AGENT_ID: 要使用的代理 ID(命令行参数的替代选项)BRIGHTSY_API_KEY: 要使用的 API 密钥(命令行参数的替代选项)BRIGHTSY_TOOL_NAME: 要注册的工具名称(默认值:"brightsy")
测试 agent_proxy 工具
agent_proxy 工具允许您向 Brightsy AI 代理代理请求。要测试该工具,您可以使用提供的测试脚本。
先决条件
在运行测试之前,请设置以下环境变量:
export AGENT_ID=your-agent-id
export API_KEY=your-api-key
# Optional: customize the tool name for testing
export TOOL_NAME=custom-tool-name
或者,您可以将这些值作为命令行参数传递:
# Using named arguments
npm run test:cli -- --agent-id=your-agent-id --api-key=your-api-key --tool-name=custom-tool-name
# Using positional arguments
npm run test:cli -- your-agent-id your-api-key custom-tool-name
运行测试
要运行所有测试:
npm test
要运行特定测试:
# Test using the command line interface
npm run test:cli
# Test using the direct MCP protocol
npm run test:direct
测试脚本
-
命令行测试 (
test-agent-proxy.ts):通过使用测试消息运行 MCP 服务器来测试 agent_proxy 工具。 -
直接 MCP 协议测试 (
test-direct.ts):通过直接向服务器发送格式正确的 MCP 请求来测试 agent_proxy 工具。
工具工作原理
MCP 服务器注册了一个工具(默认命名为 "brightsy"),该工具将请求转发给与 OpenAI 兼容的 AI 代理,并返回响应。它接受一个 messages 参数,这是一个包含 role 和 content 属性的消息对象数组。
在 MCP 客户端中的示例用法:
// Using the default tool name
const response = await client.callTool("brightsy", {
messages: [
{
role: "user",
content: "Hello, can you help me with a simple task?"
}
]
});
// Or using a custom tool name if configured
const response = await client.callTool("custom-tool-name", {
messages: [
{
role: "user",
content: "Hello, can you help me with a simple task?"
}
]
});
响应将在 content 字段中包含代理的回复。