维基百科数据协议服务

提供维基百科文章搜索、内容检索、摘要、分类、链接、图片、语言版本和外部引用等功能的MCP协议服务器。

  • by msilverblatt
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 msilverblatt/wiki-mcp

使用说明

维基mcp

维基百科的MCP(模型上下文协议)服务器。提供搜索文章、检索内容、摘要、类别、链接、图像、语言版本和外部参考的工具。

特性

  • 9维基百科工具 获取全面的文章访问权限
  • 适用于所有API响应的正确TypeScript类型
  • 请求超时处理
  • 处理信息性消息时出错
  • 模块化架构

工具

工具 说明
wiki_search 在维基百科中搜索与查询匹配的文章
wiki_get_article 获取文章的全文内容
wiki_get_summary 获取文章的简短摘要
wiki_random 获取随机维基百科文章
wiki_get_categories 获取文章所属的类别
wiki_get_links 从文章中获取维基百科内部链接
wiki_get_images 获取文章中使用的图像
wiki_get_languages 获取文章的可用语言版本
wiki_get_references 从文章中获取外部参考/链接

安装

快速安装(推荐)

bunx wiki-mcp install

这会自动将wiki-mcp添加到Claude Desktop和Claude Code中。

手动安装

# Or install globally
bun add -g wiki-mcp
npm install -g wiki-mcp

通过史密瑟里

npx @smithery/cli install wiki-mcp

来源

git clone https://github.com/msilverblatt/wiki-mcp.git
cd wiki-mcp
bun install

用法

使用克劳德桌面

添加到您的Claude Desktop配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):

{
  "mcpServers": {
    "wikipedia": {
      "command": "bunx",
      "args": ["wiki-mcp"]
    }
  }
}

使用克劳德代码

添加到您的Claude Code MCP设置中(~/.claude/settings.json):

{
  "mcpServers": {
    "wikipedia": {
      "command": "bunx",
      "args": ["wiki-mcp"]
    }
  }
}

独立

bun run index.ts

服务器使用MCP协议通过stdio进行通信。

工具示例

维基搜索

搜索文章:

{
  "query": "artificial intelligence",
  "limit": 5
}

退货:

[
  {
    "title": "Artificial intelligence",
    "snippet": "Artificial intelligence (AI) is the intelligence of machines...",
    "pageid": 1234
  }
]

wiki_get_tarticle

获取完整文章内容:

{
  "title": "JavaScript"
}

返回纯文本文章内容。

wiki_get_summary

获取文章摘要:

{
  "title": "TypeScript"
}

退货:

{
  "title": "TypeScript",
  "description": "Programming language",
  "extract": "TypeScript is a strongly typed programming language...",
  "url": "https://en.wikipedia.org/wiki/TypeScript"
}

wiki_get_classes

获取文章类别:

{
  "title": "Python (programming language)",
  "limit": 10
}

退货:

{
  "title": "Python (programming language)",
  "categories": ["Programming languages", "Scripting languages", "..."]
}

wiki_get-links

获取内部链接:

{
  "title": "Machine learning",
  "limit": 50
}

退货:

{
  "title": "Machine learning",
  "links": ["Artificial intelligence", "Data science", "..."]
}

wiki_get-images

获取文章图片:

{
  "title": "Solar System",
  "limit": 20
}

退货:

{
  "title": "Solar System",
  "images": [
    {
      "title": "Solar System.jpg",
      "url": "https://en.wikipedia.org/wiki/File:Solar_System.jpg"
    }
  ]
}

wiki_get-languages

获取可用翻译:

{
  "title": "Albert Einstein"
}

退货:

{
  "title": "Albert Einstein",
  "languageCount": 200,
  "languages": [
    {
      "language": "Deutsch",
      "code": "de",
      "title": "Albert Einstein",
      "url": "https://de.wikipedia.org/wiki/Albert_Einstein"
    }
  ]
}

wiki_get-references

获取外部引用:

{
  "title": "Climate change",
  "limit": 30
}

退货:

{
  "title": "Climate change",
  "references": ["https://www.ipcc.ch/", "..."]
}

wiki_random

获取随机文章:

{
  "count": 3
}

退货:

[
  { "title": "Random Article 1", "id": 12345 },
  { "title": "Random Article 2", "id": 67890 }
]

发展

# Run tests
bun test

# Type check
bun run typecheck

# Start server
bun run start

项目结构

wiki-mcp/
├── index.ts              # Entry point
├── src/
│   ├── api.ts            # Wikipedia API client
│   ├── server.ts         # MCP server setup
│   ├── types.ts          # TypeScript interfaces
│   └── tools/
│       ├── index.ts      # Tool registration
│       ├── search.ts     # wiki_search
│       ├── article.ts    # wiki_get_article
│       ├── summary.ts    # wiki_get_summary
│       ├── random.ts     # wiki_random
│       ├── categories.ts # wiki_get_categories
│       ├── links.ts      # wiki_get_links
│       ├── images.ts     # wiki_get_images
│       ├── languages.ts  # wiki_get_languages
│       └── references.ts # wiki_get_references
└── tests/
    ├── api.test.ts       # API helper tests
    └── tools.test.ts     # Tool integration tests

许可证

麻省理工学院