ai_search_csdn
Search CSDN technical blogs and Q&A content to find programming solutions and development insights. Returns search URLs that can be accessed to retrieve actual results.
Instructions
📝 CSDN搜索 - 搜索CSDN技术博客和问答
【重要】此工具会返回CSDN搜索URL,Claude Code应该使用WebFetch工具访问该URL以获取真实搜索结果。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | 搜索关键词 | |
| type | No | 搜索类型 | all |
Input Schema (JSON Schema)
{
"properties": {
"query": {
"description": "搜索关键词",
"type": "string"
},
"type": {
"default": "all",
"description": "搜索类型",
"enum": [
"blog",
"ask",
"all"
],
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- mcp_server_node.js:167-178 (schema)Defines the tool metadata, description, and input schema for 'ai_search_csdn' including query (required) and type (blog/ask/all) parameters.{ name: 'ai_search_csdn', description: '📝 CSDN搜索 - 搜索CSDN技术博客和问答\n\n【重要】此工具会返回CSDN搜索URL,Claude Code应该使用WebFetch工具访问该URL以获取真实搜索结果。', inputSchema: { type: 'object', properties: { query: { type: 'string', description: '搜索关键词' }, type: { type: 'string', enum: ['blog', 'ask', 'all'], description: '搜索类型', default: 'all' } }, required: ['query'] } },
- mcp_server_node.js:252-254 (registration)Registers the 'ai_search_csdn' tool (and all others in AI_TOOLS) to be discoverable via ListToolsRequestSchema.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: AI_TOOLS, }));
- mcp_server_node.js:824-939 (handler)Implements the execution logic for 'ai_search_csdn'. Normalizes query, constructs CSDN-specific search URL, provides platform info, generates detailed response markdown with WebFetch usage instructions, and saves results to file.case 'ai_search_csdn': case 'ai_search_juejin': case 'ai_search_segmentfault': case 'ai_search_cnblogs': case 'ai_search_oschina': case 'ai_search_aliyun_docs': case 'ai_search_tencent_docs': { const rawQuery = normalizeString(args.query); if (!rawQuery) { throw new Error('搜索关键词不能为空'); } const searchUrls = { ai_search_csdn: `https://so.csdn.net/so/search?q=${encodeURIComponent(rawQuery)}`, ai_search_juejin: `https://juejin.cn/search?query=${encodeURIComponent(rawQuery)}`, ai_search_segmentfault: `https://segmentfault.com/search?q=${encodeURIComponent(rawQuery)}`, ai_search_cnblogs: `https://zzk.cnblogs.com/s?w=${encodeURIComponent(rawQuery)}`, ai_search_oschina: `https://www.oschina.net/search?scope=all&q=${encodeURIComponent(rawQuery)}`, ai_search_aliyun_docs: `https://help.aliyun.com/search?spm=a2c4g.11186623.0.0&k=${encodeURIComponent(rawQuery)}`, ai_search_tencent_docs: `https://cloud.tencent.com/search?s=doc&keyword=${encodeURIComponent(rawQuery)}` }; const platformInfo = { ai_search_csdn: { name: 'CSDN', icon: '📝', description: '中国最大的IT社区和服务平台', tips: ['博客文章', '技术问答', '代码片段', '下载资源'], homepage: 'https://www.csdn.net/', toolKey: 'csdn-search' }, ai_search_juejin: { name: '掘金', icon: '💎', description: '面向开发者的技术内容分享平台', tips: ['前端开发', '后端开发', 'Android', 'iOS', '人工智能'], homepage: 'https://juejin.cn/', toolKey: 'juejin-search' }, ai_search_segmentfault: { name: 'SegmentFault', icon: '🔧', description: '中文技术问答社区', tips: ['技术问答', '技术文章', '活动沙龙', '编程挑战'], homepage: 'https://segmentfault.com/', toolKey: 'sf-search' }, ai_search_cnblogs: { name: '博客园', icon: '📚', description: '开发者的网上家园', tips: ['.NET', 'C#', 'Java', 'Python', '数据库'], homepage: 'https://www.cnblogs.com/', toolKey: 'cnblogs-search' }, ai_search_oschina: { name: '开源中国', icon: '🌐', description: '中国最大的开源技术社区', tips: ['开源项目', '技术资讯', '代码托管', '协作翻译'], homepage: 'https://www.oschina.net/', toolKey: 'oschina-search' }, ai_search_aliyun_docs: { name: '阿里云文档', icon: '☁️', description: '阿里云产品文档中心', tips: ['ECS', 'OSS', 'RDS', 'SLB', '容器服务'], homepage: 'https://help.aliyun.com/', toolKey: 'aliyun-docs' }, ai_search_tencent_docs: { name: '腾讯云文档', icon: '☁️', description: '腾讯云产品文档中心', tips: ['CVM', 'COS', 'CDN', 'SCF', '数据库'], homepage: 'https://cloud.tencent.com/document/product', toolKey: 'tencent-docs' } }; const info = platformInfo[name]; const searchUrl = searchUrls[name]; const detailsContent = `${info.icon} ${info.name} 搜索\n\n` + `**搜索关键词**: ${rawQuery}\n` + `**平台介绍**: ${info.description}\n\n` + `---\n\n` + `🔗 **搜索链接**: ${searchUrl}\n\n` + `⚠️ **请使用 WebFetch 工具获取搜索结果**:\n` + `\`\`\`javascript\n` + `WebFetch({\n` + ` url: "${searchUrl}",\n` + ` prompt: "提取前10条搜索结果(标题、作者、发布时间、摘要、链接)"\n` + `})\n` + `\`\`\`\n\n` + `---\n\n` + `💡 **${info.name} 热门主题**:\n` + info.tips.map(tip => `• ${tip}`).join(' | ') + `\n\n🏠 **平台首页**: ${info.homepage}\n\n` + `📌 **搜索建议**:\n` + `• 使用精确关键词获得更好的结果\n` + `• 结合多个平台搜索可获得更全面的信息\n` + `• 关注文章的发布时间,优先查看最新内容`; const filepath = await saveSearchResult(info.toolKey, rawQuery, detailsContent); return makeTextResponse( `${info.icon} **${info.name}搜索**\n\n` + `**关键词**: ${rawQuery}\n` + `**搜索链接**: ${searchUrl}\n\n` + `✅ 详细信息已保存至: ${filepath || '保存失败'}\n` + `💡 使用 WebFetch 工具访问搜索链接获取结果` ); }
- mcp_server_node.js:54-71 (helper)Helper function used by ai_search_csdn handler to save detailed search instructions and results to a markdown file in .search-results directory.const saveSearchResult = async (toolName, query, details) => { try { const resultsDir = join(process.cwd(), '.search-results'); if (!existsSync(resultsDir)) { await mkdir(resultsDir, { recursive: true }); } const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5); const filename = `${toolName}-${timestamp}.md`; const filepath = join(resultsDir, filename); await writeFile(filepath, details, 'utf-8'); return filepath; } catch (error) { console.error('Failed to save search result:', error); return null; } };