wikipedia WebMCP
Browser tool configuration for wikipedia
Tools (2)
wikipedia_search()
搜索维基百科
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
const query = args.query || args._input;
if (!query) return {error: 'Missing query parameter'};
const count = args.count || 10;
const url = `https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=${encodeURIComponent(query)}&format=json&origin=*&srlimit=${count}`;
const resp = await fetch(url);
if (!resp.ok) return {error: 'HTTP ' + resp.status};
const data = await resp.json();
const results = data.query?.search || [];
return {count: results.length, results: results.map(r => ({
pageid: r.pageid,
title: r.title,
snippet: r.snippet?.replace(/<[^>]*>/g, ''),
wordcount: r.wordcount,
url: `https://en.wikipedia.org/wiki/${encodeURIComponent(r.title.replace(/ /g, '_'))}`
}))};
};
return run(params || {});
}
wikipedia_summary()
获取维基百科页面摘要
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
const title = args.title || args._input;
if (!title) return {error: 'Missing title parameter'};
const url = `https://en.wikipedia.org/api/rest_v1/page/summary/${encodeURIComponent(title)}`;
const resp = await fetch(url);
if (!resp.ok) return {error: 'HTTP ' + resp.status};
const data = await resp.json();
return {
title: data.title,
description: data.description,
extract: data.extract,
thumbnail: data.thumbnail?.source,
url: data.content_urls?.desktop?.page,
timestamp: data.timestamp
};
};
return run(params || {});
}
🔌 Chrome MCP Server Extension
Use these tools with Claude, ChatGPT, and other AI assistants.
How to Use WebMCP
WebMCP tools are designed for browser extensions or automation frameworks. The browser extension matches the current URL against the pattern and executes the JavaScript handler when the tool is invoked.
API Endpoint:
GET /api/webmcp/match?url=https://www.wikipedia.com/...