Pieces MCP 和长期记忆在开发者中流行
Pieces 工具推出 MCP 和长期记忆功能,提供隐私优先的 AI 辅助开发能力。适合关注开发工具进展的程序员。
Pieces 工具推出 MCP 和长期记忆功能,提供隐私优先的 AI 辅助开发能力。适合关注开发工具进展的程序员。
上下文一直是开发者与 AI 交互中缺失的那一环。在浏览器、IDE 和 LLM 对话窗口之间来回切换,往往会打断工作节奏。但如果你的工具能准确、安全地替你记住一切,而且不需要你在每个聊天窗口中反复复制粘贴脑海里的信息,会怎么样?
这正是 Pieces 通过集成 Model Context Protocol(MCP)与 Long-Term Memory(LTM)所实现的能力。
MCP 是由 Anthropic 开发的一项开放标准,它让 Large Language Models(LLMs)能够与外部数据源和工具通信,而无须为每一个数据源或工具分别开发自定义集成。
你可以这样理解:它是供 AI 获取上下文的 API,但相比普通 API,AI 使用起来更加容易。
如需更详细的指南,可以查看我们一位同事撰写的相关文章。
Pieces LTM 是一个先进的记忆引擎,能够:
如果你现在已经有所了解,就会发现:Long-Term Memory 基本上具备了打造更智能、更高效 AI 工作流所需要的一切。
如果想深入了解,可以查看实现 MCP server 的幕后细节。
我们使用 PiecesCLI,尝试从 LTM 中获取记忆。
bash
pip install pieces-cli
# OR
brew install pieces-cli
pieces mcp start
初始化连接:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"pieces-cli-user","version":"1.0.0"}}}
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"experimental":{},"tools":{"listChanged":false}},"serverInfo":{"name":"pieces-stdio-mcp","version":"0.1.0"}}}
向 MCP server 发送通知,告诉它我们已经准备好使用了。
{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}
通知不会收到响应;它就像是向 server 发送一条消息。
接下来列出 MCP server 所提供的工具。请求:
{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}
响应很长,但可以看到其中包含两个工具:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"tools": [
{
"name": "ask_pieces_ltm",
"description": "Ask Pieces a question to retrieve historical/contextual information from the user's environment.",
"inputSchema": {
// Schema defined to the llm model to follow when calling the tool //
}
},
{
"name": "create_pieces_memory",
"description": "Use this tool to capture a detailed, never-forgotten memory in Pieces. Agents and humans alike—such as Cursor, Claude, Perplexity, Goose, and ChatGPT—can leverage these memories to preserve important context or breakthroughs that occur in a project. Think of these as \"smart checkpoints\" that document your journey and ensure valuable information is always accessible for future reference. Providing thorough file and folder paths helps systems or users verify the locations on the OS and open them directly from the workstream summary.",
"inputSchema": {
// Schema defined here as wee
}
}
]
}
}
Pieces MCP server 暴露了两个主要工具:
用途:从你的开发环境中检索历史信息和上下文信息。
{
question: string; // Required: User's query
topics?: string[]; // Topical keywords for context
open_files?: string[]; // Currently open files in IDE
application_sources?: string[]; // Filter by apps (Chrome, VS Code, Discord, etc.)
chat_llm: string; // Required: LLM being used (e.g., "gpt-4o-mini")
related_questions?: string[]; // Supplementary questions
connected_client?: string; // Client name (Cursor, Claude, etc.)
}
用途:捕获详细记忆,供人类和 AI 日后查阅。
{
summary_description: string; // Required: 1-2 sentence summary
summary: string; // Required: Detailed markdown narrative
project?: string; // Absolute path to project root
files?: string[]; // Absolute file/folder paths
externalLinks?: string[]; // URLs to docs, repos, etc.
connected_client?: string; // Client creating the memory
}
{
"method": "tools/call",
"params": {
"name": "ask_pieces_ltm",
"arguments": {
"question": "what I was working on yesterday",
"topics": [
"cli",
"pieces-cli",
"pieces"
],
"open_files": [],
"application_sources": [
"Google Chrome",
],
"chat_llm": "gpt-4o-mini",
"related_questions": [],
"connected_client": "pieces-cli-user"
},
}
}
随后,Pieces LTM 返回了类似下面的响应:
{
"content": [
{
"type": "text",
"text": "" // Here went I was working on but in details
}
],
"isError": false
}
在调试和检查 MCP payload 时,一个非常实用的工具是 Inspector:npx @modelcontextprotocol/inspector。
Pieces LTM 不只是缓存或剪贴板历史记录,而是一套功能完整、数据存储在本地的记忆系统。它会实时捕获工作流数据,覆盖从 IDE、浏览器到文档工具的整个过程。所有内容都通过 PiecesOS 存储在本地,从而确保隐私、安全以及完全的控制权。
它的能力还不止于此:它可以追踪时间戳和应用来源,甚至能在时间维度上锚定上下文。因此,你可以提出与相对时间有关的问题,例如:“我昨天在调试什么?”
你无须手动整理这些记忆。它们已经过结构化处理、带有时间戳,并且可以通过语义查询进行检索。这开启了一种全新的生产力模式:工作流中的每一步都会被归档,并且可以随时访问,无论是用于调试、知识共享,还是从上次中断的地方继续工作。
这套架构最强大的特性之一,就是记忆的连续性。你可以在 Cursor 中开始一项任务,切换到 Slack 讨论某个问题,之后再回到 VS Code 中继续处理,而无须自己记住每一步操作或每一个细节。
你的 AI assistant 仍然能够掌握完整情况,因为 Pieces LTM 一直在跨越时间和应用,静默捕获你的上下文。
通常情况下,你要么必须在每个 prompt 中提供过量的上下文(“我昨天在调试 CLI 中的 auth module……”),要么就得承受模糊且没有帮助的结果(“帮我修一下这个错误”)。但有了 Pieces,你只需要说:“嘿,Cursor,修复我昨天遇到的那个错误。”assistant 就能获得足够的背景信息,理解你指的是什么。
这是一种全新的上下文可移植范式,而且它在本地运行、保护隐私,同时无缝衔接。
MCP 和 LTM 不只是让工作流更加顺畅,它们还重新定义了开发者与 AI 之间的关系。它们不只是工具,更是基础设施。当记忆永不遗忘、上下文始终与你同行时,过去花在解释、回忆或重新追溯步骤上的时间,现在都可以用于真正的构建工作。
上下文不再脆弱。它持久、易于访问,而且最重要的是,它属于你。