Wikipedia MCP Server

Wikipedia MCP Server

site icon
2025.04.06 1
HTMLWikipedia API 交互内容检索内容生成
Wikipedia MCP Server 是一个基于 Model Context Protocol (MCP) 的服务器,用于与 Wikipedia API 进行交互。它允许 AI 助手访问 Wikipedia 内容,搜索文章,获取历史事件和检索图片。
View on GitHub

Overview

基本能力

产品定位

Wikipedia MCP Server 是一个基于 Model Context Protocol (MCP) 的服务器,用于与 Wikipedia API 进行交互。

核心功能

  • onThisDay: 获取特定日期发生的历史事件
  • findPage: 搜索匹配查询的 Wikipedia 页面
  • getPage: 通过标题获取 Wikipedia 页面的内容
  • getImagesForPage: 通过标题获取 Wikipedia 页面的图片

适用场景

  • AI 助手需要访问 Wikipedia 内容
  • 需要搜索 Wikipedia 文章
  • 需要获取特定日期的历史事件
  • 需要获取 Wikipedia 页面的图片

工具列表

  • onThisDay: 获取特定日期发生的历史事件
  • findPage: 搜索匹配查询的 Wikipedia 页面
  • getPage: 通过标题获取 Wikipedia 页面的内容
  • getImagesForPage: 通过标题获取 Wikipedia 页面的图片

常见问题解答

使用教程

使用依赖

需要安装 Node.js 和 npm。

安装教程

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

以编程方式使用

import {
  WikipediaServer,
  isValidOnThisDayArgs,
  isValidFindPageArgs,
  isValidGetPageArgs,
  isValidGetImagesForPageArgs,
} from "@shelm/wikipedia-mcp-server";

// 创建新的服务器实例
const server = new WikipediaServer();

// 运行服务器
server.run().catch(console.error);

// 或直接使用验证函数和处理程序
if (isValidOnThisDayArgs({ date: "2023-01-01" })) {
  const result = await server.handleOnThisDay({ date: "2023-01-01" });
  console.log(result);
}

示例客户端

node example-client.js

开发

构建

npm run build

开发模式运行

npm run dev

测试

node example-client.js

MCP 服务器配置

{
  "mcpServers": {
    "wikipedia": {
      "command": "npx",
      "args": ["@shelm/wikipedia-mcp-server"],
      "env": {}
    }
  }
}

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。