Skip to main content
Glama
fourcolors

Omi MCP Server

by fourcolors

Omi MCP 服务器

铁匠徽章

该项目提供了一个模型上下文协议 (MCP) 服务器,用于与 Omi API 交互。该服务器提供了读取对话和记忆以及创建新对话和记忆的工具。

设置

  1. 克隆存储库

  2. 使用npm install安装依赖项

  3. 使用以下变量创建.env文件:

    API_KEY=your_api_key APP_ID=your_app_id

Related MCP server: MCP Toolkit

用法

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Omi MCP 服务器:

npx -y @smithery/cli install @fourcolors/omi-mcp --client claude

构建服务器

npm run build

运行服务器

npm run start

开发模式

对于使用热重载进行开发:

npm run dev

测试服务器

其中包含一个简单的测试客户端,用于与 MCP 服务器交互。构建项目后,运行:

npm run test

或者直接:

./test-mcp-client.js

这将启动 MCP 服务器并提供一个交互式菜单来测试可用的工具。测试客户端使用默认测试用户 ID ( test-user-123 ) 执行所有操作。

清理并重建

清理构建目录并从头开始重建:

npm run rebuild

使用 Claude 和 Cursor 进行配置

克劳德配置

要通过 Anthropic Console 或 API 将此 MCP 服务器与 Claude 一起使用:

  1. 本地启动 MCP 服务器:

    npm run start
  2. 设置 Claude 对话时,请配置 MCP 连接:

    { "mcp_config": { "transports": [ { "type": "stdio", "executable": { "path": "/path/to/your/omi-mcp-local/dist/index.js", "args": [] } } ] } }
  3. 给 Claude 的示例提示:

    Please fetch the latest 5 conversations for user "user123" using the Omi API.
  4. Claude 将使用 MCP 执行read_omi_conversations工具:

    { "id": "req-1", "type": "request", "method": "tools.read_omi_conversations", "params": { "user_id": "user123", "limit": 5 } }

游标配置

要将此 MCP 服务器与 Cursor 一起使用:

  1. 在终端中启动 MCP 服务器:

    npm run start
  2. 在 Cursor 中,前往“设置”>“扩展”>“MCP 服务器”

  3. 使用以下设置添加新的 MCP 服务器:

    • 名称:Omi API

    • 网址:stdio:/path/to/your/omi-mcp-local/dist/index.js

    • 启用服务器

  4. 现在,您可以直接在 Cursor 中使用 Omi 工具。例如:

    @Omi API Please fetch memories for user "user123" and summarize them.
  5. Cursor 将与您的 MCP 服务器通信以执行必要的 API 调用。

可用工具

MCP 服务器提供以下工具:

read_omi_conversations

使用可选过滤器从 Omi 检索特定用户的对话。

参数:

  • user_id (字符串):用于获取对话的用户 ID

  • limit (数字,可选):返回的最大对话数量

  • offset (数字,可选):分页时要跳过的对话数

  • include_discarded (布尔值,可选):是否包含丢弃的对话

  • statuses (字符串,可选):以逗号分隔的状态列表,用于过滤对话

读取_omi_memories

从 Omi 检索特定用户的记忆。

参数:

  • user_id (string): 获取记忆的用户 ID

  • limit (数字,可选):返回的最大记忆数量

  • offset (数字,可选):分页时要跳过的内存数量

创建 omi 对话

在 Omi 中为特定用户创建新对话。

参数:

  • text (字符串):对话的全文内容

  • user_id (字符串):创建对话的用户 ID

  • text_source (字符串):文本内容的来源(选项:“audio_transcript”、“message”、“other_text”)

  • started_at (字符串,可选):对话/事件开始的时间(ISO 8601 格式)

  • finished_at (字符串,可选):对话/事件结束的时间(ISO 8601 格式)

  • language (字符串,可选):语言代码(默认值:“en”)

  • geolocation (对象,可选):对话的位置数据

    • latitude (数字):纬度坐标

    • longitude (数字):经度坐标

  • text_source_spec (字符串,可选):有关来源的附加规范

创建_omi_记忆

为特定用户在近江创建新的回忆。

参数:

  • user_id (字符串):要创建记忆的用户 ID

  • text (字符串,可选):将从中提取记忆的文本内容

  • memories (数组,可选):直接创建的显式内存对象数组

    • content (字符串):内存的内容

    • tags (字符串数组,可选):内存的标签

  • text_source (字符串,可选):文本内容的来源

  • text_source_spec (字符串,可选):有关来源的附加规范

测试

要测试 MCP 服务器,您可以使用提供的测试客户端:

node test-mcp-client.js

这将启动一个交互式测试客户端,允许您:

  1. 获取对话

  2. 获取回忆

  3. 创建对话

  4. 辞职

测试客户端对所有操作使用默认测试用户 ID ( test-user-123 )。

日志记录

MCP 服务器内置日志记录功能,可将日志写入控制台和日志文件。这对于调试和监控服务器活动非常有用。

日志文件位置

日志会写入项目目录下的logs/mcp-server.log文件。日志文件包含时间戳和以下详细信息:

  • 服务器启动和关闭

  • 所有 API 请求和响应

  • 错误消息和堆栈跟踪

  • 对 Omi 的 API 调用

  • 请求参数和响应数据

查看日志

您可以使用tail命令实时查看日志:

tail -f logs/mcp-server.log

这将向您显示服务器处理请求并与 Omi API 交互时的实时更新。

日志格式

每个日志条目都遵循以下格式:

[2024-03-21T12:34:56.789Z] Log message here

时间戳采用 ISO 8601 格式,可轻松关联事件和调试问题。

Install Server
A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fourcolors/omi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server