Skip to main content
Glama

Documentation for your agent Website License npm version

Ref MCP

一个 ModelContextProtocol 服务器,让您的 AI 编码工具或代理能够访问 API、服务、库等的文档。它是您的一站式解决方案,以快速且节省 token 的方式让您的代理随时掌握最新文档。

更多信息请访问 ref.tools

为精准上下文提供的代理搜索

Ref 的工具旨在匹配模型的搜索方式,同时尽可能少地使用上下文,以减少 上下文腐烂 (context rot)。其目标是在使用最少 token 的同时,准确找到您的编码代理成功所需的上下文。

根据提示词的复杂程度,像 Claude Code 这样的 LLM 编码代理通常会进行一次或多次搜索,然后选择一些资源进行深入阅读。

对于关于 Figma Comment REST API 的简单查询,它会进行几次调用以获取所需内容:

SEARCH 'Figma API post comment endpoint documentation' (54 tokens)
READ https://www.figma.com/developers/api#post-comments-endpoint (385 tokens)

对于更复杂的情况,LLM 会在阅读结果时尝试优化其提示词。例如:

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 利用 MCP 会话来跟踪搜索轨迹并最小化上下文使用。还有很多想法正在酝酿中,但以下是我们目前已经实现的功能。

1. 过滤搜索结果

对于会话中重复的类似搜索,Ref 永远不会返回重复的结果。传统上,您通过翻页到下一个结果来深入挖掘搜索结果,但这种方法允许代理在翻页的同时调整提示词。

2. 获取页面中重要的部分

在阅读文档页面时,Ref 将使用代理的会话搜索历史记录来剔除不太相关的部分,并返回最相关的 5k 个 token。这有助于 Ref 避免标准 fetch() 网络抓取的一个大问题,即当它访问大型文档页面时,很容易最终将 20k+ 个 token 拉入上下文,而其中大部分是不相关的。

Related MCP server: graphpilot

为什么最小化文档上下文的 token 很重要?

1. 更多的上下文会让模型变笨

有充分的文献证明,截至 2025 年 7 月,随着您输入的 token 增加,模型会变得更笨。您可能听说过模型现在非常擅长处理长上下文,这在某种程度上是真的,但并非全貌。有关一些研究的快速入门,请观看 Chroma 团队的这段视频

2. Token 需要 $$$

想象一下,您正在使用 Claude Opus 作为后台代理,您首先让代理拉取文档上下文,假设它拉取了 10000 个 token 的上下文,其中 4000 个是相关的,6000 个是额外的噪音。按照 API 定价,那 6k 个 token 每步大约花费 $0.09。如果一个提示词最终需要 11 步才能完成,那么您就白白花费了 $1。

设置

有两种设置 Ref 作为 MCP 服务器的选项,即通过 streamable-http 服务器(推荐)或本地 stdio 服务器(旧版)。

此仓库包含旧版 stdio 服务器。

Streamable HTTP(推荐)

Install Ref MCP in Cursor

"Ref": {
  "type": "http",
  "url": "https://api.ref.tools/mcp?apiKey=YOUR_API_KEY"
}

stdio

Install Ref MCP in Cursor (stdio)

"Ref": {
  "command": "npx",
  "args": ["ref-tools-mcp@latest"],
  "env": {
    "REF_API_KEY": <sign up to get an api key>
  }
}

工具

Ref MCP 服务器为您代理的需求提供了所有与文档相关的工具。

ref_search_documentation

一个强大的搜索工具,用于检查技术文档。非常适合查找事实或代码片段。也可用于搜索网络上的公共文档或 GitHub,以及来自仓库和 PDF 等私有资源的文档。

参数:

  • query(必需):用于搜索相关文档的查询。这应该是一个完整的句子或问题。

ref_read_url

一个从 URL 获取内容并将其转换为 Markdown 以便使用 Ref 轻松阅读的工具。当与返回相关内容 URL 的 ref_search_documentation 工具结合使用时,此工具非常强大。

参数:

  • url(必需):要阅读的网页 URL。

OpenAI 深度研究支持

Ref 可用作深度研究的来源。OpenAI 需要特定的工具定义,因此当与 OpenAI 客户端一起使用时,Ref 将提供名称略有不同的相同工具。

ref_search_documentation(query) -> search(query)
ref_read_url(url) -> fetch(id)

开发

npm install
npm run dev

使用 Inspector 运行

出于开发和调试目的,您可以使用 MCP Inspector 工具。Inspector 为测试和监控 MCP 服务器交互提供了一个可视化界面。

访问 Inspector 文档 获取详细的设置说明。

要使用 Inspector 在本地进行测试:

npm run inspect

或者同时运行 watcher 和 inspector:

npm run dev

本地开发

  1. 克隆仓库

  2. 安装依赖:

npm install
  1. 构建项目:

npm run build
  1. 进行自动重建的开发:

npm run watch

许可证

MIT

Available Tools

2 tools
ref_read_urlAInspect

Read the content of a url as markdown. The entire exact URL from a Ref 'ref_search_documentation' result should be passed to this tool to read it.

ParametersJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL of the webpage to read.

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool reads content and converts it to markdown, but lacks details on error handling, rate limits, authentication needs, or output format. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and well-structured in two sentences. The first sentence states the core purpose, and the second provides usage context. There is no wasted language, making it front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (reading and converting web content) and lack of annotations or output schema, the description is adequate but incomplete. It covers purpose and basic usage but omits behavioral details like error cases or output specifics, leaving room for improvement in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the parameter 'url' documented as 'The URL of the webpage to read.' The description adds minimal value beyond this by specifying that the URL should come from 'ref_search_documentation' results, but does not provide additional syntax or format details. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Read the content of a url as markdown.' It specifies the verb ('Read') and resource ('content of a url'), making the action explicit. However, it does not explicitly distinguish this tool from its sibling 'ref_search_documentation', which likely searches rather than reads content, so it misses full differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: 'The entire exact URL from a Ref 'ref_search_documentation' result should be passed to this tool to read it.' This implies usage after obtaining a URL from the sibling tool, offering a workflow guideline. However, it does not specify when not to use it or alternatives, keeping it from a perfect score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ref_search_documentationBInspect

Search for documentation on the web or github as well from private resources like repos and pdfs. Use Ref 'ref_read_url' to read the content of a url.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesQuery for documentation. Should include programming language and framework or library names. Searches public only docs by default, include ref_src=private to search a user's private docs.

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only mentions searching capabilities and a related tool. It fails to disclose critical behavioral traits like whether this is a read-only operation, potential rate limits, authentication needs for private resources, or what the search results look like (e.g., format, pagination).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences that directly state the tool's function and a usage tip. It's front-loaded and avoids unnecessary words, though it could be slightly more structured for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a search tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., search results format), how private resources are accessed, or error handling, leaving significant gaps for an AI agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% coverage, fully describing the single 'query' parameter with details on including language/framework names and the 'ref_src=private' option. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as searching for documentation across web, GitHub, and private resources, which is specific and actionable. However, it doesn't explicitly differentiate from its sibling 'ref_read_url', which is for reading URL content rather than searching, so it misses full sibling distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning 'ref_read_url' for reading content, suggesting a workflow, but lacks explicit guidance on when to use this tool versus alternatives or any exclusions. It provides some context but no clear when/when-not rules.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A3.5/5.0
Disambiguation5/5

The two tools have clearly distinct purposes: ref_search_documentation finds documentation resources, while ref_read_url reads the content of specific URLs. There is no overlap or ambiguity between searching and reading operations.

Naming Consistency5/5

Both tools follow a consistent 'ref_verb_noun' naming pattern with snake_case. The prefix 'ref_' provides clear namespace identification, and the verb-noun structure (search_documentation, read_url) is uniform and predictable.

Tool Count3/5

With only two tools, the server feels minimal but functional for its documentation search/read purpose. While it covers core workflows, the count is borderline thin—additional tools for filtering, saving, or managing searches might enhance completeness without overcomplication.

Completeness4/5

The tool set covers the essential documentation workflow: searching and reading. However, there are minor gaps, such as no tools for saving results, filtering searches, or managing cached content, which agents might need to work around for advanced use cases.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

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/ref-tools/ref-tools-mcp'

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