id: f0c6d2a5bbe74f38a041f28c1185dbe1
parent_id: 
item_type: 1
item_id: a0a0376311a84914b520f220e269150f
item_updated_time: 1764345639639
title_diff: "[{\"diffs\":[[1,\"FastMCP + CherryStudio：手把手教你打造专属免费的“股票分析”助手！\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":44}]"
body_diff: "[{\"diffs\":[[1,\"<html>\\\r\\\n<head>\\\r\\\n  <title>FastMCP + CherryStudio：手把手教你打造专属免费的“股票分析”助手！</title>\\\r\\\n  <basefont face=\\\"微软雅黑\\\" size=\\\"2\\\" />\\\r\\\n  <meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html;charset=utf-8\\\" />\\\r\\\n  <meta name=\\\"exporter-version\\\" content=\\\"YXBJ Windows/608924 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;\\\"/>\\\r\\\n  <meta name=\\\"content-class\\\" content=\\\"yinxiang.peso.superNote\\\"/>\\\r\\\n  <meta name=\\\"application-data:yinxiang.noteLayout\\\" content=\\\"{\\\"lineSpace\\\":\\\"recommend\\\",\\\"paragraphSpace\\\":\\\"recommend\\\"}\\\"/>\\\r\\\n  <style>\\\r\\\n\\tbody, td {\\\r\\\n\\t  font-family: 微软雅黑;\\\r\\\n\\t  font-size: 12pt;\\\r\\\n\\t}\\\r\\\n  </style>\\\r\\\n</head>\\\r\\\n<body>\\\r\\\n<a name=\\\"45529\\\"></a>\\\r\\\n<h1>FastMCP + CherryStudio：手把手教你打造专属免费的“股票分析”助手！</h1>\\\r\\\n\\\r\\\n<div><span style=\\\"margin:0px;\\\"><div style=\\\"padding:8px 0px;margin:8px auto;max-width:700px;\\\"> <div><span></span></div>\\\n<p></p>\\\n<div style=\\\"--en-blockquote:true;box-sizing: border-box; padding-left: 19px; padding-top: 6px; padding-bottom: 6px; border-left: 3px solid #b4c0cc; background-position: initial initial; background-repeat: initial initial; margin-top: 6px\\\"><div>原文链接: <a href=\\\"https://mp.weixin.qq.com/s?__biz=MjM5NzM3NDcxMw==&amp;mid=2247483998&amp;idx=1&amp;sn=f29914443dd52337a7bc4adc8196fc3d&amp;chksm=a7badcffdd5ff4f02f15952b3a154bd6c0b571665f15b8f7b7a0561926e2af09434b7cf21af5&amp;mpshare=1&amp;scene=1&amp;srcid=0808JzkC1VQPjKbjajqOnAMF&amp;sharer_shareinfo=91e102872cdd4ab2d001fe0fd6b5c132&amp;sharer_shareinfo_first=91e102872cdd4ab2d001fe0fd6b5c132#rd\\\"><span>https://mp.weixin.qq.com/s?__biz=MjM5NzM3NDcxMw==&amp;mid=224748...</span></a></div></div>\\\n<p></p>\\\n<div><span></span></div>\\\n<div style=\\\"\\\"><div><div><h1 style=\\\"margin:0\\\"> FastMCP + CherryStudio：手把手教你打造专属免费的“股票分析”助手！</h1><div><span style=\\\"position:relative\\\">原创</span><span> John Wong </span><span><a style=\\\"position:relative\\\"> 鲲鹏Talk </a></span><span><em></em></span></div><div style=\\\";\\\"><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>想象一下，你的 AI 助手不仅能告诉你某只股票的实时价格，还能分析整个市场的涨跌情绪！我们的股票分析助手，就是这么酷炫：</span></span></p><ul style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:20px\\\"><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>📈 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>实时股票行情查询</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>：只需输入股票代码，AI 立即为你呈现最新价格、涨跌幅等核心数据！ </span></span><span style=\\\"color: rgb(31, 35, 41);font-style: italic;\\\"><span>[这里插入 CherryStudio 运行截图或 GIF，展示查询实时股价，例如输入“查询平安银行（000001）的实时股价”，AI 返回详细数据]</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>📊 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>市场情绪智能分析</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>：想知道今天大盘是涨是跌？市场情绪如何？AI 一句话告诉你！ </span></span><span style=\\\"color: rgb(31, 35, 41);font-style: italic;\\\"><span>[这里插入 CherryStudio 运行截图或 GIF，展示市场情绪分析，例如输入“分析一下当前 A 股市场的整体情绪”，AI 返回上涨/下跌股票数和情绪判断]</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>🔄 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>实时数据流支持</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>：基于先进的 SSE 协议，数据推送毫秒级响应，让你永远快人一步！</span></span></li></ul><div style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: center;margin-bottom: 12px;\\\"><img src=\\\":/ab052285686c4867ac2cb39cdf8b6747\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" alt=\\\"Image\\\" style=\\\"--en-marks:%7B%22align%22%3A%22center%22%7D;display: inline-block;max-width: 100%;height: auto;border-radius: 12px;\\\"/></div><h3 style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-weight:bold;color:rgb(31,35,41);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;letter-spacing:0.578px;margin-top:0;margin-bottom:8px;font-size:20px;padding-bottom:12px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>什么是 MCP？AI 世界的“万能插座”🔌</span></span></h3><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>MCP（Model Context Protocol，模型上下文协议）是由 Anthropic 公司（Claude 模型所在公司）推出的开放协议，它就像是 AI 世界的“万能插座”。它的核心目标是：</span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>让不同的大语言模型能够统一、低成本地连接各种外部工具和数据。</span></span></p><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>简单来说，MCP 让 AI 不再是“信息孤岛”，而是能通过标准化的方式，调用外部 API、查询数据库、读取文件等，从而极大地扩展 AI 的能力边界。</span></span></p><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>MCP 的核心能力：</span></span></p><ul style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:20px\\\"><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>Resource （资源）:</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 定义 AI 可以访问的数据源，比如 API 接口、数据库记录、文件内容等。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>Prompts （提示）:</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 预定义的交互模板，指导 AI 完成特定任务。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>Sampling （采样）:</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 根据条件生成或采样输出，可用于生成提示或操作确认。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>Roots （根）:</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 访问权限控制，限制 AI 对特定资源的访问范围。</span></span></li></ul><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>在本文中，我们主要关注如何通过 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>Resource</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 能力，让 AI 调用外部数据源（这里是 AKShare）</span></span></p><div style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: center;margin-bottom: 12px;\\\"><img src=\\\":/d3ca199b882344bda3a0141bd784696c\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" alt=\\\"Image\\\" style=\\\"--en-marks:%7B%22align%22%3A%22center%22%7D;display: inline-block;max-width: 100%;height: auto;border-radius: 12px;\\\"/></div><hr style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 24px 0px;border-style: solid;border-width: 1px 0px 0px;border-color: rgba(0, 0, 0, 0.1);\\\"/><h3 style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-weight:bold;color:rgb(31,35,41);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;letter-spacing:0.578px;margin-top:0;margin-bottom:8px;font-size:20px;padding-bottom:12px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>FastMCP：快速开发 AI 工具的利器 🚀</span></span></h3><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>开发 MCP 工具听起来很复杂？别担心！</span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>FastMCP</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 是一个基于 Python 的轻量级框架，它极大地简化了 MCP 工具的开发流程，让你用最少的代码，就能将普通函数封装成强大的 AI 工具。</span></span></p><hr style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 24px 0px;border-style: solid;border-width: 1px 0px 0px;border-color: rgba(0, 0, 0, 0.1);\\\"/><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>通过本教程，你将解锁以下超能力：</span></span></p><ul style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:20px\\\"><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>🚀 掌握 FastMCP 框架，轻松构建高性能 MCP 服务器</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>📈 集成 AKShare，实时获取海量金融数据</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>💻 在 CherryStudio 中玩转自定义工具，让 AI 更懂你</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>✨ 实现 SSE 协议，体验毫秒级的实时数据流</span></span></li></ul><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>准备好了吗？让我们一起开启 AI 量化投资的新篇章！</span></span></p><h3 style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-weight:bold;color:rgb(31,35,41);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;letter-spacing:0.578px;margin-top:0;margin-bottom:8px;font-size:20px;padding-bottom:12px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>实战：打造你的“股票数据查询”MCP 工具 📈</span></span></h3><h4 style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-weight:bold;color:rgb(31,35,41);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;letter-spacing:0.578px;margin-top:0;margin-bottom:8px;font-size:18px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>核心技术栈</span></span></h4><ul style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:20px\\\"><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>FastMCP</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>: 官方推荐的 MCP 服务器框架，高效稳定。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>Starlette</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>: 轻量级高性能异步 Web 框架，为服务器提供强大动力。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>AKShare</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>: 开源免费的金融数据接口，数据来源丰富可靠。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>SSE 协议</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>： 服务器发送事件，实现客户端与服务器的实时单向通信。</span></span></li></ul><h3 style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-weight:bold;color:rgb(31,35,41);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;letter-spacing:0.578px;margin-top:0;margin-bottom:8px;font-size:20px;padding-bottom:12px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>核心代码实现：揭秘 AI 大脑</span></span></h3><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>接下来，我们将一步步揭示 AI 助手的“大脑”是如何构建的。</span></span></p><ol style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;list-style:none;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:0\\\"><li><div><span>1. </span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>服务器主体代码：FastMCP</span></span></div></li></ol><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>这是我们 MCP 服务器的入口，基于 FastMCP 和 Starlette 构建，确保了高性能和协议兼容性。</span></span></p><div style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin-top: 12px;background-color: rgb(40, 44, 52);margin-bottom: 12px;border-radius: 5px;\\\"><div><span style=\\\"display: block;height: 30px;background-color: rgb(40, 44, 52);border-top-left-radius: 5px;border-top-right-radius: 5px;margin: 0px;color: rgb(0, 0, 0);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\\\"><span style=\\\"height: 30px;line-height: 30px;margin-left: 10px;display: block;background: none left center / auto 14px no-repeat;background-image: url(&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/MjOlxTUP22Ab4EGLukS1tnyBptPib5D5nLQDkcQZjIjveK0iazX2icdzmg0EAfvaMllGialTuzibKXKPR50hNpic5H5Q/640?wx_fmt=png&amp;from=appmsg&quot;);\\\"></span></span></div><pre style=\\\"margin: 0px;\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"color: rgb(92, 99, 112);font-style: italic;\\\"><span>#!/usr/bin/env python3&quot;&quot;&quot;</span></span><span><br/></span><span>股票分析SSE服务器 - 官方推荐方案最终版</span><span><br/></span><span>基于Starlette和mcp.py库内置的SseServerTransport，确保协议兼容性。</span><span><br/></span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;&quot;&quot;import json</span><span><br/></span><span>import logging</span><span><br/></span><span>import akshare as ak</span><span><br/></span><span>import uvicorn</span><span><br/></span><span>from datetime import datetime</span><span><br/></span><span>from mcp.server.fastmcp import FastMCP</span><span><br/></span><span>from mcp.server.sse import SseServerTransport</span><span><br/></span><span>from starlette.applications import Starlette</span><span><br/></span><span>from starlette.routing import Mount, Route</span><span><br/></span><span><br/></span><span># --- 配置 ---</span><span><br/></span><span>logging.basicConfig(level=logging.INFO)</span><span><br/></span><span>logger = logging.getLogger(__name__)# --- MCP服务器初始化 ---</span><span><br/></span><span>mcp = FastMCP(&quot;StockAnalysisServer&quot;) # 为你的服务器命名！</span></span></div></pre></div><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>代码解析</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>：我们导入了必要的库，并初始化了 FastMCP 服务器实例。</span></span><span style=\\\"color: rgb(31, 35, 41);padding: 1px 2px;background-color: rgb(245, 246, 247);border: 1px solid rgb(222, 224, 227);border-radius: 4px;margin: 0px 3px;\\\"><span>FastMCP(&quot;StockAnalysisServer&quot;)</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 定义了服务器的名称，方便后续识别。</span></span></p><ol style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;list-style:none;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:0\\\"><li><div><span>2. </span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>股票实时数据工具：AI 的“千里眼”</span></span></div></li></ol><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>这个工具让 AI 能够“看到”最新的股票行情。我们使用</span></span><span style=\\\"color: rgb(31, 35, 41);padding: 1px 2px;background-color: rgb(245, 246, 247);border: 1px solid rgb(222, 224, 227);border-radius: 4px;margin: 0px 3px;\\\"><span>@mcp.tool()</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>装饰器将其注册为 MCP 工具。</span></span></p><div style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin-top: 12px;background-color: rgb(40, 44, 52);margin-bottom: 12px;border-radius: 5px;\\\"><div><span style=\\\"display: block;height: 30px;background-color: rgb(40, 44, 52);border-top-left-radius: 5px;border-top-right-radius: 5px;margin: 0px;color: rgb(0, 0, 0);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\\\"><span style=\\\"height: 30px;line-height: 30px;margin-left: 10px;display: block;background: none left center / auto 14px no-repeat;background-image: url(&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/MjOlxTUP22Ab4EGLukS1tnyBptPib5D5nLQDkcQZjIjveK0iazX2icdzmg0EAfvaMllGialTuzibKXKPR50hNpic5H5Q/640?wx_fmt=png&amp;from=appmsg&quot;);\\\"></span></span></div><pre style=\\\"margin: 0px;\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"color: rgb(97, 174, 238);\\\"><span>@mcp.tool()async def get_stock_realtime_data(</span><span>symbol: </span><span style=\\\"color: rgb(230, 192, 123);\\\"><span>str</span></span><span>) -&gt; str:</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;&quot;&quot;</span><span><br/></span><span>    获取指定股票代码的实时行情数据。</span><span><br/></span><span>    :param symbol: 股票代码, 例如 '000001'</span><span><br/></span><span>    :return: JSON格式的股票数据字符串</span><span><br/></span><span>    &quot;&quot;&quot;</span></span></span><span><br/></span><span>    logger.info(</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>f&quot;执行工具 get_stock_realtime_data，参数: </span><span style=\\\"color: rgb(224, 108, 117);\\\"><span>{symbol}</span></span><span>&quot;</span></span><span>)</span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>try</span></span><span>:</span><span><br/></span><span>        df = ak.stock_zh_a_spot_em() </span><span style=\\\"color: rgb(92, 99, 112);font-style: italic;\\\"><span># 从AKShare获取A股实时行情</span></span><span><br/></span><span>        stock_data = df[df[</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>'代码'</span></span><span>] == symbol]</span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>if</span></span><span> stock_data.empty:</span><span><br/></span><span>            result = {</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;error&quot;</span></span><span>: </span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>f&quot;未找到股票代码 </span><span style=\\\"color: rgb(224, 108, 117);\\\"><span>{symbol}</span></span><span> 的数据&quot;</span></span><span>}</span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>else</span></span><span>:</span><span><br/></span><span>            data = stock_data.iloc[</span><span style=\\\"color: rgb(209, 154, 102);\\\"><span>0</span></span><span>]</span><span><br/></span><span>            result = {</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;股票代码&quot;</span></span><span>: symbol,</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;股票名称&quot;</span></span><span>: data[</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>'名称'</span></span><span>],</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;最新价&quot;</span></span><span>: </span><span style=\\\"color: rgb(230, 192, 123);\\\"><span>float</span></span><span>(data[</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>'最新价'</span></span><span>]),</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;涨跌幅&quot;</span></span><span>: </span><span style=\\\"color: rgb(230, 192, 123);\\\"><span>float</span></span><span>(data[</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>'涨跌幅'</span></span><span>]),</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;更新时间&quot;</span></span><span>: datetime.now().strftime(</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;%Y-%m-%d %H:%M:%S&quot;</span></span><span>)}</span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>return</span></span><span> json.dumps(result, ensure_ascii=</span><span style=\\\"color: rgb(86, 182, 194);\\\"><span>False</span></span><span>) </span><span style=\\\"color: rgb(92, 99, 112);font-style: italic;\\\"><span># 确保中文显示正常except Exception as e:</span></span><span><br/></span><span>        logger.error(</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>f&quot;获取实时数据失败: </span><span style=\\\"color: rgb(224, 108, 117);\\\"><span>{e}</span></span><span>&quot;</span></span><span>)</span><span><br/></span><span>        error_result = {</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;error&quot;</span></span><span>: </span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>f&quot;获取实时数据失败: </span><span style=\\\"color: rgb(224, 108, 117);\\\"><span>{</span><span style=\\\"color: rgb(230, 192, 123);\\\"><span>str</span></span><span>(e)}</span></span><span>&quot;</span></span><span>}</span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>return</span></span><span> json.dumps(error_result, ensure_ascii=</span><span style=\\\"color: rgb(86, 182, 194);\\\"><span>False</span></span><span>)</span></div></pre></div><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>代码解析</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>：</span></span><span style=\\\"color: rgb(31, 35, 41);padding: 1px 2px;background-color: rgb(245, 246, 247);border: 1px solid rgb(222, 224, 227);border-radius: 4px;margin: 0px 3px;\\\"><span>get_stock_realtime_data</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 函数接收股票代码，通过</span></span><span style=\\\"color: rgb(31, 35, 41);padding: 1px 2px;background-color: rgb(245, 246, 247);border: 1px solid rgb(222, 224, 227);border-radius: 4px;margin: 0px 3px;\\\"><span>akshare.stock_zh_a_spot_em()</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>获取 A 股实时数据，并筛选出指定股票的信息。数据以 JSON 格式返回，方便 AI 解析。</span></span></p><ol style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;list-style:none;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:0\\\"><li><div><span>3. </span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>市场情绪分析工具：AI 的“读心术”</span></span></div></li></ol><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>这个工具让 AI 能够分析整个市场的涨跌情况，判断当前的市场情绪。</span></span></p><div style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin-top: 12px;background-color: rgb(40, 44, 52);margin-bottom: 12px;border-radius: 5px;\\\"><div><span style=\\\"display: block;height: 30px;background-color: rgb(40, 44, 52);border-top-left-radius: 5px;border-top-right-radius: 5px;margin: 0px;color: rgb(0, 0, 0);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\\\"><span style=\\\"height: 30px;line-height: 30px;margin-left: 10px;display: block;background: none left center / auto 14px no-repeat;background-image: url(&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/MjOlxTUP22Ab4EGLukS1tnyBptPib5D5nLQDkcQZjIjveK0iazX2icdzmg0EAfvaMllGialTuzibKXKPR50hNpic5H5Q/640?wx_fmt=png&amp;from=appmsg&quot;);\\\"></span></span></div><pre style=\\\"margin: 0px;\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"color: rgb(97, 174, 238);\\\"><span>@mcp.tool()async def get_market_sentiment() -&gt; str:</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;&quot;&quot;</span><span><br/></span><span>    获取当前市场的整体情绪分析。</span><span><br/></span><span>    :return: JSON格式的市场情绪数据字符串</span><span><br/></span><span>    &quot;&quot;&quot;</span></span></span><span><br/></span><span>    logger.info(</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;执行工具 get_market_sentiment&quot;</span></span><span>)</span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>try</span></span><span>:</span><span><br/></span><span>        df_market = ak.stock_zh_a_spot_em() </span><span style=\\\"color: rgb(92, 99, 112);font-style: italic;\\\"><span># 再次获取全市场数据</span></span><span><br/></span><span>        up_count = </span><span style=\\\"color: rgb(230, 192, 123);\\\"><span>len</span></span><span>(df_market[df_market[</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>'涨跌幅'</span></span><span>] &gt; </span><span style=\\\"color: rgb(209, 154, 102);\\\"><span>0</span></span><span>])</span><span><br/></span><span>        down_count = </span><span style=\\\"color: rgb(230, 192, 123);\\\"><span>len</span></span><span>(df_market[df_market[</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>'涨跌幅'</span></span><span>] &lt; </span><span style=\\\"color: rgb(209, 154, 102);\\\"><span>0</span></span><span>])</span><span><br/></span><span>        total_count = </span><span style=\\\"color: rgb(230, 192, 123);\\\"><span>len</span></span><span>(df_market)</span><span><br/></span><span>        sentiment = </span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;乐观&quot;</span></span><span> </span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>if</span></span><span> up_count &gt; down_count </span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>else</span></span><span> </span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;悲观&quot;</span></span><span> </span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>if</span></span><span> down_count &gt; up_count </span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>else</span></span><span> </span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;中性&quot;</span></span><span><br/></span><span>        </span><span><br/></span><span>        result = {</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;上涨股票数&quot;</span></span><span>: up_count,</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;下跌股票数&quot;</span></span><span>: down_count,</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;市场情绪&quot;</span></span><span>: sentiment,</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;分析时间&quot;</span></span><span>: datetime.now().strftime(</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;%Y-%m-%d %H:%M:%S&quot;</span></span><span>)}</span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>return</span></span><span> json.dumps(result, ensure_ascii=</span><span style=\\\"color: rgb(86, 182, 194);\\\"><span>False</span></span><span>)</span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>except</span></span><span> Exception </span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>as</span></span><span> e:</span><span><br/></span><span>        logger.error(</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>f&quot;获取市场情绪失败: </span><span style=\\\"color: rgb(224, 108, 117);\\\"><span>{e}</span></span><span>&quot;</span></span><span>)</span><span><br/></span><span>        error_result = {</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>&quot;error&quot;</span></span><span>: </span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>f&quot;获取市场情绪失败: </span><span style=\\\"color: rgb(224, 108, 117);\\\"><span>{</span><span style=\\\"color: rgb(230, 192, 123);\\\"><span>str</span></span><span>(e)}</span></span><span>&quot;</span></span><span>}</span><span style=\\\"color: rgb(198, 120, 221);\\\"><span>return</span></span><span> json.dumps(error_result, ensure_ascii=</span><span style=\\\"color: rgb(86, 182, 194);\\\"><span>False</span></span><span>)</span></div></pre></div><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>代码解析</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>：</span></span><span style=\\\"color: rgb(31, 35, 41);padding: 1px 2px;background-color: rgb(245, 246, 247);border: 1px solid rgb(222, 224, 227);border-radius: 4px;margin: 0px 3px;\\\"><span>get_market_sentiment</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 函数统计了 A 股市场中上涨和下跌的股票数量，并据此判断出“乐观”、“悲观”或“中性”的市场情绪。</span></span></p><ol style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;list-style:none;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:0\\\"><li><div><span>4. </span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>SSE 服务器配置：实时通信的桥梁</span></span></div></li></ol><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>这是实现实时数据流的关键部分，我们利用</span></span><span style=\\\"color: rgb(31, 35, 41);padding: 1px 2px;background-color: rgb(245, 246, 247);border: 1px solid rgb(222, 224, 227);border-radius: 4px;margin: 0px 3px;\\\"><span>SseServerTransport</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>和 Starlette 来构建 SSE 端点。</span></span></p><div style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin-top: 12px;background-color: rgb(40, 44, 52);margin-bottom: 12px;border-radius: 5px;\\\"><div><span style=\\\"display: block;height: 30px;background-color: rgb(40, 44, 52);border-top-left-radius: 5px;border-top-right-radius: 5px;margin: 0px;color: rgb(0, 0, 0);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\\\"><span style=\\\"height: 30px;line-height: 30px;margin-left: 10px;display: block;background: none left center / auto 14px no-repeat;background-image: url(&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/MjOlxTUP22Ab4EGLukS1tnyBptPib5D5nLQDkcQZjIjveK0iazX2icdzmg0EAfvaMllGialTuzibKXKPR50hNpic5H5Q/640?wx_fmt=png&amp;from=appmsg&quot;);\\\"></span></span></div><pre style=\\\"margin: 0px;\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span style=\\\"color: rgb(92, 99, 112);font-style: italic;\\\"><span># --- SSE传输和Starlette应用设置 ---</span></span><span><br/></span><span>sse_transport = SseServerTransport(</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>'/messages/'</span></span><span>) </span><span style=\\\"color: rgb(92, 99, 112);font-style: italic;\\\"><span># 定义SSE消息路径async def sse_handler(request):&quot;&quot;&quot;处理初始SSE连接并运行MCP服务器会话。&quot;&quot;&quot;async with sse_transport.connect_sse(request.scope, request.receive, request._send) as streams:# 核心：将SSE连接与MCP服务器会话绑定await mcp._mcp_server.run(streams[0], streams[1], mcp._mcp_server.create_initialization_options())# 定义Starlette应用的路由</span></span><span><br/></span><span>app = Starlette(</span><span><br/></span><span>    debug=</span><span style=\\\"color: rgb(86, 182, 194);\\\"><span>True</span></span><span>,</span><span><br/></span><span>    routes=[</span><span><br/></span><span>        Route(</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>'/sse'</span></span><span>, endpoint=sse_handler), </span><span style=\\\"color: rgb(92, 99, 112);font-style: italic;\\\"><span># MCP主端点</span></span><span><br/></span><span>        Mount(</span><span style=\\\"color: rgb(152, 195, 121);\\\"><span>'/messages/'</span></span><span>, app=sse_transport.handle_post_message) </span><span style=\\\"color: rgb(92, 99, 112);font-style: italic;\\\"><span># SSE消息处理端点])</span></span></div></pre></div><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>代码解析</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>：</span></span><span style=\\\"color: rgb(31, 35, 41);padding: 1px 2px;background-color: rgb(245, 246, 247);border: 1px solid rgb(222, 224, 227);border-radius: 4px;margin: 0px 3px;\\\"><span>sse_transport</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 负责 SSE 协议的具体实现。</span></span><span style=\\\"color: rgb(31, 35, 41);padding: 1px 2px;background-color: rgb(245, 246, 247);border: 1px solid rgb(222, 224, 227);border-radius: 4px;margin: 0px 3px;\\\"><span>/sse</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 是 CherryStudio 连接服务器的主入口，而</span></span><span style=\\\"color: rgb(31, 35, 41);padding: 1px 2px;background-color: rgb(245, 246, 247);border: 1px solid rgb(222, 224, 227);border-radius: 4px;margin: 0px 3px;\\\"><span>/messages/</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 则用于处理 SSE 消息的推送。</span></span></p><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>启动项目</span></span></p><div style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin-top: 12px;background-color: rgb(40, 44, 52);margin-bottom: 12px;border-radius: 5px;\\\"><div><span style=\\\"display: block;height: 30px;background-color: rgb(40, 44, 52);border-top-left-radius: 5px;border-top-right-radius: 5px;margin: 0px;color: rgb(0, 0, 0);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\\\"><span style=\\\"height: 30px;line-height: 30px;margin-left: 10px;display: block;background: none left center / auto 14px no-repeat;background-image: url(&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/MjOlxTUP22Ab4EGLukS1tnyBptPib5D5nLQDkcQZjIjveK0iazX2icdzmg0EAfvaMllGialTuzibKXKPR50hNpic5H5Q/640?wx_fmt=png&amp;from=appmsg&quot;);\\\"></span></span></div><pre style=\\\"margin: 0px;\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span>uv run main.py</span></div></pre></div><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>看到类似以下输出，说明你的 MCP 服务已经成功启动，并监听在 </span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>http://127.0.0.1:8001/sse</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>：</span></span></p><div style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin-top: 12px;background-color: rgb(40, 44, 52);margin-bottom: 12px;border-radius: 5px;\\\"><div><span style=\\\"display: block;height: 30px;background-color: rgb(40, 44, 52);border-top-left-radius: 5px;border-top-right-radius: 5px;margin: 0px;color: rgb(0, 0, 0);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\\\"><span style=\\\"height: 30px;line-height: 30px;margin-left: 10px;display: block;background: none left center / auto 14px no-repeat;background-image: url(&quot;https://mmbiz.qpic.cn/sz_mmbiz_png/MjOlxTUP22Ab4EGLukS1tnyBptPib5D5nLQDkcQZjIjveK0iazX2icdzmg0EAfvaMllGialTuzibKXKPR50hNpic5H5Q/640?wx_fmt=png&amp;from=appmsg&quot;);\\\"></span></span></div><pre style=\\\"margin: 0px;\\\"><div style=\\\"--en-codeblock:true;--en-meta:{&quot;title&quot;:&quot;&quot;,&quot;lang&quot;:&quot;Plain Text&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;showLine&quot;:true,&quot;lineWrap&quot;:true};box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902); background-position: initial initial; background-repeat: initial initial; margin-top: 6px;\\\"><span>(base) jwangkundeMacBook-Pro-2:stock_mcp jwangkun$ python server.py</span><span><br/></span><span><br/></span><span>    ███████╗ █████╗ ███████╗████████╗███╗   ███╗ ██████╗██████╗ </span><span><br/></span><span>    ██╔════╝██╔══██╗██╔════╝╚══██╔══╝████╗ ████║██╔════╝██╔══██╗</span><span><br/></span><span>    █████╗  ███████║███████╗   ██║   ██╔████╔██║██║     ██████╔╝</span><span><br/></span><span>    ██╔══╝  ██╔══██║╚════██║   ██║   ██║╚██╔╝██║██║     ██╔═══╝ </span><span><br/></span><span>    ██║     ██║  ██║███████║   ██║   ██║ ╚═╝ ██║╚██████╗██║     </span><span><br/></span><span>    ╚═╝     ╚═╝  ╚═╝╚══════╝   ╚═╝   ╚═╝     ╚═╝ ╚═════╝╚═╝     </span><span><br/></span><span><br/></span><span>INFO:__main__:启动基于官方推荐方案的股票分析SSE服务器...</span><span><br/></span><span>INFO:__main__:服务器名称: 股票分析MCP服务器</span><span><br/></span><span>INFO:__main__:服务器版本: v1.0.0</span><span><br/></span><span>INFO:__main__:描述: 基于AKShare API的股票分析工具，支持SSE协议</span><span><br/></span><span>INFO:__main__:MCP主端点 (请在CherryStudio中配置此URL): http://127.0.0.1:8001/sse</span><span><br/></span><span>INFO:__main__:所有依赖包检查通过</span><span><br/></span><span>INFO:__main__:正在启动MCP服务器...</span><span><br/></span><span>INFO:     Started server process [76966]</span><span><br/></span><span>INFO:     Waiting for application startup.</span><span><br/></span><span>INFO:     Application startup complete.</span><span><br/></span><span>INFO:     Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit)</span></div></pre></div><hr style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 24px 0px;border-style: solid;border-width: 1px 0px 0px;border-color: rgba(0, 0, 0, 0.1);\\\"/><h3 style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-weight:bold;color:rgb(31,35,41);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;letter-spacing:0.578px;margin-top:0;margin-bottom:8px;font-size:20px;padding-bottom:12px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>连接 CherryStudio：让 AI 开口说话 🗣️</span></span></h3><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>CherryStudio 是一款强大的 LLM 客户端，类似于 Cursor、Claude Desktop。它能让你以自然语言的方式与 AI 交互，并无缝调用我们刚刚开发的 MCP 工具。</span></span></p><ol style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;list-style:none;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:0\\\"><li><div><span>1. </span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>添加 MCP 服务器</span></span></div></li></ol><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>打开 CherryStudio，进入 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>设置 （Settings）</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 页面。</span></span></p><ul style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:20px\\\"><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>选中 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>MCP 服务器 （MCP Servers）</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 选项。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>点击 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>添加服务器 （Add Server）</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>在类型中选中 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>SSE</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>填写对应的 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>URL 地址</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> http://127.0.0.1:8001/sse</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> （如果你在本地运行）。</span></span></li></ul><div style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: center;margin-bottom: 12px;\\\"><img src=\\\":/66e27b7982264a7bb127bcd4593486bf\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" alt=\\\"Image\\\" style=\\\"--en-marks:%7B%22align%22%3A%22center%22%7D;display: inline-block;max-width: 100%;height: auto;border-radius: 12px;\\\"/></div><ol style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;list-style:none;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:0\\\"><li><div><span>2. </span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>启用你的工具</span></span></div></li></ol><ul style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:20px\\\"><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>切换到 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>工具 （Tools）</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> Tab 页。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>在这里，你会看到我们刚才定义的工具 股票分析 SSE 工具。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>勾选</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span> 该工具，使其处于启用状态。</span></span></li></ul><ol style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;list-style:none;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:0\\\"><li><div><span>3. </span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>开始与 AI 对话！</span></span></div></li></ol><ul style=\\\"margin:0;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;font-size:15px;line-height:30px;padding-left:20px\\\"><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>回到 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>聊天界面 （Chat Interface）</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>在对话框下方，选择你刚刚添加的 </span></span><span style=\\\"color: rgb(31, 35, 41);font-weight: bold;\\\"><span>MCP 服务器</span></span><span style=\\\"color: rgb(31, 35, 41);\\\"><span>。</span></span></li><li style=\\\"text-align: left;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>现在，你可以尝试用自然语言提问了！</span></span><div style=\\\"text-align: center;margin-bottom: 12px;\\\"><img src=\\\":/ba6e660de1ec43c9b7629c39b92f5779\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" alt=\\\"Image\\\" style=\\\"--en-marks:%7B%22align%22%3A%22center%22%7D;display: inline-block;max-width: 100%;height: auto;border-radius: 12px;\\\"/></div></li><ul style=\\\"margin:0;color:rgb(20,86,240);font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;margin-top:0;font-size:15px;line-height:30px;margin-bottom:10px;padding-left:24px;text-align:left\\\"><li style=\\\"margin-bottom: 0px;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>“帮我查下贵州茅台（600519）的实时股价是多少？”</span></span></li><li style=\\\"margin-bottom: 0px;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>“查询一下中国平安（601318）的基本信息。”</span></span></li><li style=\\\"margin-bottom: 0px;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>“我想知道比亚迪（002594）今天的行情。”</span></span></li><li style=\\\"margin-bottom: 0px;\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>“给我看看招商银行（600036）的最新价格和总市值。”</span></span></li></ul></ul><div style=\\\"color: rgb(0, 0, 0);font-family: &quot;PingFang SC&quot;;font-size: medium;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-align: center;margin-bottom: 12px;\\\"><img src=\\\":/c8bd5a9ba94a45c4a0aff7651a35b217\\\" type=\\\"image/png\\\" data-filename=\\\"640.png\\\" alt=\\\"Image\\\" style=\\\"--en-marks:%7B%22align%22%3A%22center%22%7D;display: inline-block;max-width: 100%;height: auto;border-radius: 12px;\\\"/></div><p style=\\\"font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-indent:0;text-transform:none;widows:2;word-spacing:0;-webkit-text-stroke-width:0;white-space:normal;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;font-size:15px;line-height:2em;font-family:&quot;PingFang SC&quot;,system-ui,-apple-system,BlinkMacSystemFont,&quot;Helvetica Neue&quot;,&quot;Hiragino Sans GB&quot;,&quot;Microsoft YaHei UI&quot;,&quot;Microsoft YaHei&quot;,Arial,sans-serif;color:rgb(31,35,41);margin:0 0 4px;word-break:break-all;min-height:20px\\\"><span style=\\\"color: rgb(31, 35, 41);\\\"><span>AI 会根据你的提问，智能地识别并调用你开发的 MCP 工具，然后将工具返回的数据整合到对话中，实现 LLM 与外部数据源的无缝对接！</span></span></p><div><span><br/></span></div></div></div></div></div></div></span>\\\n</div></body></html>\\u0000\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":72199}]"
metadata_diff: {"new":{"id":"a0a0376311a84914b520f220e269150f","parent_id":"f67288c3a0be4374b5d532b5dcc3aabc","latitude":"0.00000000","longitude":"0.00000000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin-desktop","source_application":"net.cozic.joplin-desktop","application_data":"","order":1764348819074,"markup_language":2,"is_shared":0,"share_id":"","conflict_original_id":"","master_key_id":"","user_data":"","deleted_time":0},"deleted":[]}
encryption_cipher_text: 
encryption_applied: 0
updated_time: 2025-11-28T21:03:28.739Z
created_time: 2025-11-28T21:03:28.739Z
type_: 13