For AI agents: the complete documentation index is available at https://rspress.rs/zh/llms.txt, the full documentation bundle is available at https://rspress.rs/zh/llms-full.txt, and this page is available as Markdown at https://rspress.rs/zh/guide/basic/webmcp.md.
close

WebMCP

Rspress 默认开启 webMcp,Agent 可以通过 WebMCP 搜索、阅读和浏览 Rspress 文档。更多内容参考 ChatGPT - 站点工具。

For your Agent
用你的 Agent 试试 WebMCP

把这段提示词发给 Codex 或其他 Agent,让它看看这个页面提供了哪些 WebMCP 工具。

rspress.config.ts
import { defineConfig } from '@rspress/core';

export default defineConfig({
  webMcp: true, // 默认值
});

设置 webMcp: false 可以关闭 Rspress 内置工具,仍可使用 useWebMcp hook 注册自定义工具。

内置工具

工具用途
get_site_info返回站点元信息、语言、版本、导航和当前侧边栏。
list_pages筛选和分页读取页面元信息,默认使用当前语言和版本,不依赖搜索。
get_page无需跳转即可读取已知路由的元信息、frontmatter、目录和 Markdown(启用 SSG-MD 时可用)。
get_current_page读取当前页面的元信息、frontmatter、目录和 Markdown(启用 SSG-MD 时可用)。
search_docs搜索当前语言和版本的本地文档索引(仅支持默认主题的本地搜索)。
navigate跳转到已知站内路由,等待页面提交后返回元信息、章节路由和前后页。
查看工具输入的 JSON Schema
toolInputSchemas.json
{
  "get_current_page": {
    "type": "object",
    "properties": {},
    "required": [],
    "additionalProperties": false
  },
  "get_page": {
    "type": "object",
    "properties": {
      "routePath": {
        "type": "string",
        "minLength": 1
      }
    },
    "required": ["routePath"],
    "additionalProperties": false
  },
  "get_site_info": {
    "type": "object",
    "properties": {},
    "required": [],
    "additionalProperties": false
  },
  "list_pages": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "minLength": 1
      },
      "lang": {
        "type": "string"
      },
      "version": {
        "type": "string"
      },
      "limit": {
        "type": "integer",
        "minimum": 1,
        "maximum": 100
      },
      "offset": {
        "type": "integer",
        "minimum": 0
      }
    },
    "required": [],
    "additionalProperties": false
  },
  "navigate": {
    "type": "object",
    "properties": {
      "routePath": {
        "type": "string",
        "minLength": 1
      }
    },
    "required": ["routePath"],
    "additionalProperties": false
  },
  "search_docs": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "minLength": 1
      },
      "limit": {
        "type": "integer",
        "minimum": 1,
        "maximum": 20
      }
    },
    "required": ["query"],
    "additionalProperties": false
  }
}

跨源 Agent

通过 webMcp.exposedTo 允许指定的安全来源发现工具。

自定义工具

通过 @rspress/core/runtime 导出的 useWebMcp,可以在自定义组件中注册工具,并在组件卸载时自动移除。