@elementor/wp-search-mcp (英语)
允许AI代理搜索并读取已发布的WordPress内容的MCP服务器,然后在一个内置的MCP App UI中给出答案.
概览
WpSearchMcpServer 将 WordPress REST API 包起来,并曝光出三个 MCP 工具:
| 工具 | 目的 |
|---|---|
search | 按关键词查找已发布内容 |
read | 为所选文章获取已完全完成的 HTML |
response | 在内置的UI卡(markdown, media, source link)中渲染最后的答案 |
服务器还注册了 MCP App 指令,通过一个 search → read → response 工作流程.
所需资源
- 启用 REST API 的 WordPress 站点
- 核心内容
/wp/v2/search已配置的员额类型可用的端点 - 支持的 MCP 主机 MCP 应用程序 (对
response工具 UI )
安装
npm install @elementor/wp-search-mcp
# or
pnpm add @elementor/wp-search-mcp
依赖性 : @modelcontextprotocol/sdk ^1.29.0 (作为过渡性依赖自动安装).
快开始
import { WpSearchMcpServer } from '@elementor/wp-search-mcp';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const wpSearch = new WpSearchMcpServer({
url: 'https://example.com',
server: {
name: 'my-wp-search',
title: 'My Site Docs',
},
});
const transport = new StdioServerTransport();
await wpSearch.server.connect(transport);
过 wpSearch.server 到任何 MCP 传输您的主机用途( stdio, SSE, 可流的 HTTP等) .
配置
type WpSearchMcpConfig = {
/** WordPress site root URL, e.g. https://example.com */
url: string;
/**
* Maps search subtype → REST collection segment.
* Defaults to { post: 'posts' }.
*/
postTypes?: Record<string, string>;
server?: {
name?: string; // default: 'wp-search'
version?: string; // default: '1.0.0'
title?: string; // default: 'WordPress Search'
};
};
员额类型
postTypes 控制搜索 WordPress 内容类型以及如何搜索 read 解决 REST 路径.
const wpSearch = new WpSearchMcpServer({
url: 'https://example.com',
postTypes: {
post: 'posts',
page: 'pages',
},
});
键被传递到 /wp/v2/search 作为 subtype[] 数值。 值是 REST 收集部分 /wp/v2/{segment}/{id}。 。 。 .
工具
search
使用一个或多个关键词搜索所发布的内容.
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
keywords | string[] | —— 说 | 1至3个关键字的变式 |
perPage | number | 5 | 每个关键词的结果(最多100个) |
JSON回归: [{ id, title, type }, ...]
read
获取最多三篇文章的完整内容 .
| 参数 | 类型 | 说明 |
|---|---|---|
articles | { id: number; type: string }[] | 1至3篇搜索结果 |
JSON回归: [{ title, content, link }, ...]
type 必须是配置在 postTypes。 。 。 .
response
代理工作流程的最后一步. 在聊天上方的一行MCP App卡中渲染答案.
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
response | string | —— 说 | 标记下回答文本 |
mediaUrls | { url, type }[] | [] | 图像、视频或YouTube嵌入 |
sourceLinks | { title, url }[] | [] | 归属链接 |
type 用于媒体: 'image' | 'video' | 'youtube'
代理工作流程
服务器会注射指示,指示代理商:
- 搜索 - 从用户的问题中得出2至3个单词关键词的变体(如有需要,翻译成英文)
- 读取 获取最相关的1至3篇文章
- 回应 ——用平分标记、媒体URL和源链接合成一个答案
打电话后 response,代理回复时应当用一短句指向答题卡(如"参见以上步骤").
许可证
麻省理工学院