pypi WebMCP
Browser tool configuration for pypi
Tools (2)
pypi_package()
获取 Python 包详情
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
const name = args.name || args._text;
if (!name) return {error: 'Missing package name. Usage: bb-browser site pypi/package "PACKAGE_NAME"'};
const url = `https://pypi.org/pypi/${encodeURIComponent(name)}/json`;
const resp = await fetch(url);
if (!resp.ok) return {error: 'HTTP ' + resp.status};
const data = await resp.json();
const info = data.info || {};
return {
name: info.name,
version: info.version,
summary: info.summary,
author: info.author,
author_email: info.author_email,
license: info.license,
home_page: info.home_page,
project_url: info.project_url,
package_url: info.package_url,
requires_python: info.requires_python,
keywords: info.keywords,
classifiers: info.classifiers,
project_urls: info.project_urls,
requires_dist: info.requires_dist
};
};
return run(params || {});
}
pypi_search()
搜索 Python 包
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
const query = args.query || args._text;
if (!query) return {error: 'Missing query. Usage: bb-browser site pypi/search "QUERY"'};
const page = args.page || 1;
const url = `https://pypi.org/search/?q=${encodeURIComponent(query)}&page=${page}`;
const resp = await fetch(url);
if (!resp.ok) return {error: 'HTTP ' + resp.status};
const html = await resp.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const snippets = doc.querySelectorAll('a.package-snippet');
const packages = Array.from(snippets).map(el => ({
name: (el.querySelector('.package-snippet__name') || {}).textContent?.trim(),
version: (el.querySelector('.package-snippet__version') || {}).textContent?.trim(),
description: (el.querySelector('.package-snippet__description') || {}).textContent?.trim(),
url: el.href ? `https://pypi.org${el.getAttribute('href')}` : undefined
}));
return {query, page, count: packages.length, packages};
};
return run(params || {});
}
WebMCP clients
Use mcp-chrome, or fetch the same tools from the public API in your own browser automation runtime.
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.pypi.com/...
Third-party clients can use the same endpoint as mcp-chrome. Execute the returned JavaScript handler in your own browser page context.