维基百科MCP服务器
用于维基百科API交互的MCP(模型上下文协议)服务器。
概述
该服务器提供了通过模型上下文协议与维基百科API交互的工具。它允许人工智能助手访问维基百科内容、搜索文章、获取历史事件和检索图像。
特性
服务器提供以下工具:
- 今天:获取特定日期发生的历史事件
- findPage:搜索与查询匹配的维基百科页面
- getPage:按标题获取维基百科页面的内容
- 获取页面图像:按标题从维基百科页面获取图像
安装
npm install @shelm/wikipedia-mcp-server发展:
git clone https://github.com/scotthelm/wikipedia-mcp-server.git
cd wikipedia-mcp-server
npm install
npm run build用法
运行服务器
npx @shelm/wikipedia-mcp-server这将启动MCP服务器,该服务器通过stdio进行通信。
程序化使用
您还可以在自己的项目中以编程方式使用该包:
import {
WikipediaServer,
isValidOnThisDayArgs,
isValidFindPageArgs,
isValidGetPageArgs,
isValidGetImagesForPageArgs,
} from "@shelm/wikipedia-mcp-server";
// Create a new server instance
const server = new WikipediaServer();
// Run the server
server.run().catch(console.error);
// Or use the validation functions and handlers directly
if (isValidOnThisDayArgs({ date: "2023-01-01" })) {
const result = await server.handleOnThisDay({ date: "2023-01-01" });
console.log(result);
}客户端示例
提供了一个示例客户端来演示如何与服务器交互:
node example-client.js这将:
- 启动服务器
- 查询可用工具
- 使用示例查询演示每个工具
- 在简单的web界面中显示结果http://localhost:3000
发展
建筑
npm run build以开发模式运行
npm run dev测试
可以使用示例客户端手动测试此项目:
node example-client.js这将通过示例查询演示所有可用的工具。
MCP服务器配置
要将此服务器与Claude或其他MCP兼容助手一起使用,请将其添加到MCP配置中:
{
"mcpServers": {
"wikipedia": {
"command": "npx",
"args": ["@shelm/wikipedia-mcp-server"],
"env": {}
}
}
}归因
如果没有创造这个世界的人们所做的伟大工作,这是不可能的 维基百科包
许可证
麻省理工学院
