csdn WebMCP
Browser tool configuration for csdn
Tools (3)
csdn_search()
CSDN 技术文章搜索
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
if (!args.query) return {error: 'Missing argument: query'};
const page = parseInt(args.page) || 1;
const url = 'https://so.csdn.net/api/v3/search?q=' + encodeURIComponent(args.query)
+ '&t=all&p=' + page
+ '&s=0&tm=0&lv=-1&ft=0&l=&u=&ct=-1&pnt=-1&ry=-1&ss=-1&dct=-1&vco=-1&cc=-1&sc=-1&ald=-1&ep=&wp=0';
const resp = await fetch(url, {credentials: 'include'});
if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: 'Make sure so.csdn.net is accessible'};
const d = await resp.json();
const strip = (html) => (html || '').replace(/<[^>]+>/g, '').replace(/ /g, ' ')
.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&').trim();
const results = (d.result_vos || []).map((item, i) => ({
rank: (page - 1) * 20 + i + 1,
type: item.type,
title: strip(item.title || ''),
url: item.url || '',
description: strip(item.description || item.body || '').substring(0, 300),
author: item.nickname || item.author || '',
views: parseInt(item.view) || 0,
likes: parseInt(item.digg) || 0,
collections: parseInt(item.collections) || 0,
created: item.create_time ? new Date(parseInt(item.create_time)).toISOString() : null
}));
return {
query: args.query,
page: page,
total: d.total || 0,
count: results.length,
results: results
};
};
return run(params || {});
}
insert_article()
Insert content into CSDN article editor (Markdown)
Parameters
JavaScript Handler
(params) => {
// Set title
if (params.title) {
const titleInput = document.querySelector('.article-bar__title input') || document.querySelector('input[placeholder*="标题"]');
if (titleInput) {
titleInput.value = params.title;
titleInput.dispatchEvent(new Event('input', { bubbles: true }));
}
}
// Find editor (CSDN uses CodeMirror)
const cmElement = document.querySelector('.CodeMirror');
if (cmElement && cmElement.CodeMirror) {
cmElement.CodeMirror.setValue(params.content);
return { success: true, message: 'Content inserted into CSDN editor' };
}
// Fallback to textarea
const textarea = document.querySelector('.editor__inner textarea');
if (textarea) {
textarea.value = params.content;
textarea.dispatchEvent(new Event('input', { bubbles: true }));
return { success: true, message: 'Content inserted into CSDN editor' };
}
return { success: false, message: 'Editor not found. Open editor.csdn.net first' };
}
open_editor()
Navigate to CSDN Markdown editor
Parameters
No parameters
JavaScript Handler
() => {
window.location.href = 'https://editor.csdn.net/md/';
return { success: true, message: 'Opening CSDN editor...' };
}
🔌 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.csdn.com/...