36kr WebMCP
Browser tool configuration for 36kr
Tools (1)
tool_36kr_newsflash()
36氪快讯
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
const count = Math.min(parseInt(args.count) || 20, 50);
// 36kr gateway API: POST with JSON body
const resp = await fetch('https://gateway.36kr.com/api/mis/nav/newsflash/flow', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
credentials: 'include',
body: JSON.stringify({
partner_id: 'web',
param: {siteId: 1, platformId: 2, pageSize: count, pageEvent: 0},
timestamp: Date.now()
})
});
if (!resp.ok) {
// Fallback: parse SSR page
const pageResp = await fetch('https://36kr.com/newsflashes', {credentials: 'include'});
if (!pageResp.ok) return {error: 'HTTP ' + pageResp.status, hint: 'Navigate to 36kr.com first'};
const html = await pageResp.text();
const match = html.match(/window\.initialState\s*=\s*(\{.*?\});?\s*<\/script/s);
if (!match) return {error: 'Failed to parse page data'};
try {
const state = JSON.parse(match[1]);
const list = state.newsflashCatalogData?.data?.newsflashList?.data?.itemList
|| state.newsflashCatalogData?.newsflashList?.itemList
|| [];
const items = list.slice(0, count).map((item, i) => {
const m = item.templateMaterial || {};
return {
rank: i + 1,
id: String(item.itemId),
title: m.widgetTitle || '',
description: (m.widgetContent || '').substring(0, 500),
timestamp: m.publishTime ? new Date(m.publishTime).toISOString() : null,
url: 'https://36kr.com/newsflashes/' + item.itemId
};
});
return {count: items.length, items, source: 'ssr_fallback'};
} catch (e) {
return {error: 'JSON parse failed: ' + e.message};
}
}
const data = await resp.json();
if (data.code !== 0) return {error: 'API error: ' + (data.msg || data.code)};
const list = (data.data && data.data.itemList) || [];
const items = list.slice(0, count).map((item, i) => {
const m = item.templateMaterial || {};
return {
rank: i + 1,
id: String(item.itemId),
title: m.widgetTitle || '',
description: (m.widgetContent || '').substring(0, 500),
timestamp: m.publishTime ? new Date(m.publishTime).toISOString() : null,
url: 'https://36kr.com/newsflashes/' + item.itemId
};
});
return {count: items.length, items};
};
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.36kr.com/...
Third-party clients can use the same endpoint as mcp-chrome. Execute the returned JavaScript handler in your own browser page context.