cnblogs WebMCP
Browser tool configuration for cnblogs
Tools (1)
cnblogs_search()
博客园技术文章搜索
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
const query = args.query;
if (!query) return {error: 'query is required'};
const page = args.page || 1;
const url = 'https://zzk.cnblogs.com/s?w=' + encodeURIComponent(query) + '&p=' + page;
const resp = await fetch(url, {credentials: 'include'});
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 items = doc.querySelectorAll('.searchItem');
const results = [];
items.forEach(item => {
const titleEl = item.querySelector('.searchItemTitle a');
if (!titleEl) return;
const title = (titleEl.textContent || '').trim();
if (!title) return;
const href = titleEl.getAttribute('href') || '';
const authorEl = item.querySelector('.searchItemInfo-userName a');
const author = authorEl ? (authorEl.textContent || '').trim() : '';
const snippetEl = item.querySelector('.searchCon');
const snippet = snippetEl ? (snippetEl.textContent || '').trim() : '';
const dateEl = item.querySelector('.searchItemInfo-publishDate');
const date = dateEl ? (dateEl.textContent || '').trim() : '';
const viewEl = item.querySelector('.searchItemInfo-views');
const views = viewEl ? (viewEl.textContent || '').trim() : '';
results.push({
title: title,
url: href,
author: author,
snippet: snippet.substring(0, 300),
date: date,
views: views
});
});
return {
query: query,
page: page,
count: results.length,
results: results
};
};
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.cnblogs.com/...
Third-party clients can use the same endpoint as mcp-chrome. Execute the returned JavaScript handler in your own browser page context.