此项目提供了一个与 Omi API 交互的 Model Context Protocol (MCP) 服务器。该服务器为用户提供了读取对话和记忆、创建新对话和记忆的工具,方便与 Omi API 进行数据交互。
安装完成后,运行以下命令启动服务器:
npm start
启动成功后,您可以访问 http://localhost:3000 使用提供的测试客户端。
git clone https://github.com/your-repository.git
cd your-repository
npm install
.env
文件:
OMI_API_KEY
: Omi API 的密钥PORT
: 服务器运行的端口(默认为 3000
)创建一个 .env
文件并添加以下内容:
OMI_API_KEY=your-api-key-here
PORT=3000
GET /conversations?userId=test-user-123
GET /memories?userId=test-user-123
{
"content": "这是一个新的对话",
"source": "message",
"startedAt": "2024-01-01T00:00:00Z",
"finishedAt": "2024-01-01T01:00:00Z",
"language": "en",
"geolocation": {
"latitude": 0,
"longitude": 0
},
"sourceSpec": "测试创建对话"
}
{
"text": "这是一些文本内容",
"memories": [
{
"content": "这是一条记忆",
"tags": ["测试"]
}
],
"source": "other_text",
"sourceSpec": "测试创建记忆"
}
GET /conversations
userId
: 必填,字符串类型,用户 ID。{
"data": [
{
"id": string,
"content": string,
"source": string,
"createdAt": string,
"updatedAt": string
}
],
"message": string
}
GET /memories
userId
: 必填,字符串类型,用户 ID。{
"data": [
{
"id": string,
"content": string,
"tags": [string],
"source": string,
"createdAt": string,
"updatedAt": string
}
],
"message": string
}
POST /conversations
{
"content": string, // 对话内容
"source": string, // 内容来源,可选值:audio_transcript、message、other_text
"startedAt": string, // 开始时间(ISO 8601 格式)
"finishedAt": string, // 结束时间(ISO 8601 格式)
"language": string, // 语言代码,默认为 en
"geolocation": {
"latitude": number, // 纬度坐标
"longitude": number // 经度坐标
},
"sourceSpec": string // 内容来源的额外说明
}
POST /memories
{
"text": string, // 文本内容(可选)
"memories": [
{
"content": string, // 内容
"tags": [string] // 标签数组(可选)
}
],
"source": string, // 内容来源(可选)
"sourceSpec": string // 内容来源的额外说明(可选)
}
使用提供的测试客户端进行测试:
node test-mcp-client.js
这将启动一个交互式测试客户端,允许您执行以下操作:
test-user-123
)。MCP 服务器包含内置的日志记录功能,默认将日志输出到控制台和文件中。这对于调试和监控服务器活动非常有用。
日志写入 logs/mcp-server.log
文件。日志内容包括:
使用以下命令实时查看日志:
tail -f logs/mcp-server.log
每条日志记录的格式如下:
[2024-03-21T12:34:56.789Z] Log message here
时间戳采用 ISO 8601 格式,便于事件关联和调试。