
帮助编码代理在使用公共或私人库时,绝不会犯错,否则会浪费上下文窗口。
概览
一个ModelContextProtocol服务器,为你的AI编码工具或代理提供API、服务、库等文档访问权限。它是你快速且高效的方式,让你的代理随时掌握文档最新信息。 Ref 的工具设计得符合模型的搜索方式,同时尽可能少使用上下文,以减少上下文腐烂。目标是准确找到编码代理成功所需的上下文,同时使用最少的令牌。 根据提示的复杂程度,像Claude Code这样的LLM编码代理通常会进行一次或多次搜索,然后选择几个资源进行深入阅读。 对于关于Figma的Comment REST API的简单查询,它会调用几次,以获得它所需的准确信息: 对于更复杂的情况,LLM会在读取结果时尝试细化提示。例如: Ref 利用 MCP 会话跟踪搜索轨迹并减少上下文使用。
概述(AI 翻译)
一个ModelContextProtocol服务器,为你的AI编码工具或代理提供API、服务、库等文档访问权限。它是你快速且高效的方式,让你的代理随时掌握文档最新信息。
更多信息请参见 ref.tools
能动性寻找恰到好处的语境
Ref 的工具设计得符合模型的搜索方式,同时尽可能少使用上下文,以减少上下文腐烂。目标是准确找到编码代理成功所需的上下文,同时使用最少的令牌。
根据提示的复杂程度,像Claude Code这样的LLM编码代理通常会进行一次或多次搜索,然后选择几个资源进行深入阅读。
对于关于Figma的Comment REST API的简单查询,它会调用几次,以获得它所需的准确信息:
对于更复杂的情况,LLM会在读取结果时尝试细化提示。例如:
Ref 利用 MCP 会话来追踪搜索轨迹,减少上下文使用。还有很多想法在酝酿中,但目前我们已经实现了这些。
1.筛选搜索结果
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Ref MCP
A ModelContextProtocol server that gives your AI coding tool or agent access to documentation for APIs, services, libraries etc. It’s your one-stop-shop to keep your agent up-to-date on documentation in a fast and token-efficient way.
For more see info ref.tools
Agentic search for exactly the right context
Ref’s tools are designed to match how models search while using as little context as possible to reduce context rot. The goal is to find exactly the context your coding agent needs to be successful while using minimum tokens.
Depending on the complexity of the prompt, LLM coding agents like Claude Code will typically do one or more searches and then choose a few resources to read in more depth.
For a simple query about Figma’s Comment REST API it will make a couple calls to get exactly what it needs:
SEARCH 'Figma API post comment endpoint documentation' (54 tokens)
READ https://www.figma.com/developers/api#post-comments-endpoint (385 tokens)
For more complex situations, the LLM will try to refine it’s prompt as it reads results. For example:
SEARCH 'n8n merge node vs Code node multiple inputs best practices' (126)
READ https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.merge/#merge (4961)
READ https://docs.n8n.io/flow-logic/merging/#merge-data-from-multiple-node-executions (138)
SEARCH 'n8n Code node multiple inputs best practices when to use' (107)
READ https://docs.n8n.io/code/code-node/#usage (80)
SEARCH 'n8n Code node access multiple inputs from different nodes' (370)
SEARCH 'n8n Code node $input access multiple node inputs' (372)
READ https://docs.n8n.io/code/builtin/output-other-nodes/#output-of-other-nodes (2310)
Ref takes advantage of MCP sessions to track search trajectory and minimize context usage. There’s a lot more ideas cooking but here’s what we’ve implemented so far.
1. Filtering search results
For repeated similar searches in a session, Ref will never return repeated results. Traditionally, you dig farther in to search results by paging to the next result but this approach allows the agent to page AND adjust the prompt at the same time.
2. Fetching the part of the page that matters
安装
npx ref-tools-mcp@latest