阿里妹导读
本文主要围绕AI技术的进步,特别是Anthropic的Claude 3.7 Sonnet模型在逻辑推理、代码生成和复杂任务执行方面的能力提升及其应用场景。
一、引言
-
Cursor 报告称其在实际编码任务中“再次成为最佳”,特别是在处理复杂代码库和高级工具使用方面。
-
Cognition 发现它在规划代码更改和处理全栈更新方面远超其他模型。
-
Vercel 强调其在复杂代理工作流中的“卓越精度”。
-
Replit 成功使用它从头构建复杂的网络应用程序和仪表板,而其他模型则停滞不前。
-
Canva 报告其生成的代码“生产就绪”,错误显著减少。


-
https://www.anthropic.com/news/claude-3-7-sonnet -
https://www.anthropic.com/claude/sonnet#customer-stories
二、Claude 3.7:技术突破与能力提升
模型概述
-
知识截止日期:截至 2024 年 10 月底,训练数据包括 2024 年 11 月之前的数据。 -
训练数据:使用专有混合数据,包括公共互联网、非公开第三方数据、数据标注服务和内部生成数据,不包括用户提示/输出数据,遵循 robots.txt 爬取规则,不访问密码保护或 CAPTCHA 页面。 -
训练重点:注重帮助性、无害性和诚实性,使用 Constitutional AI,并新增了从 Collective Constitutional AI 研究中得出的残疾权利原则。 -
扩展思考模式:通过令牌序列进行推理,允许用户通过系统提示指定最大思考令牌数,特别适用于数学、复杂分析和多步骤任务。
各种安全评估



-
自主网络操作:在现实评估中,Claude 3.7 Sonnet 在易任务中 1/1 成功(Pass@5),中任务 1/2 成功。 -
Cybench 基准:在 40 个 CTF 挑战中,成功 15/34 次,与 3.5 Sonnet (new) 的 14/34 比较。 -
破坏能力:评估未来 AI 系统可能破坏评估或影响开发者的行为,引用相关研究。
为什么这么多的安全评估?
案例
天气动画卡片
生成SVG图

设计风格对比(内容对比)

教学动画
-
坐标系:
-
绘制一个笛卡尔坐标系,x轴和y轴用白色标注。
-
x轴水平位于底部,标记点 0 和 1;y轴垂直位于左侧,标记点 0 和 1。
-
关键点:
-
用不同颜色的点标记并用白色文本标注以下位置:
-
点 A (0, 0):原点,用黄色点标记。
-
点 B (0, 1):y轴上,用红色点标记。
-
点 C (1, 1):右上角,用紫色点标记。
-
点 D (1, 0):x轴上,用黄色点标记。
-
矩形:
-
用浅蓝色线条连接 A、B、C、D 四点,形成一个正方形。
-
参数曲线:
-
在正方形内绘制一条黄色的半圆形曲线,向上拱起,表示参数曲线 ( x(t) ) 和 ( y(t) )。
-
阴影区域:
-
将曲线与x轴之间的区域用青色(teal)填充,表示待计算的面积。
-
公式展示:
-
在青色阴影区域内,用白色文本清晰显示面积计算公式:
1.从黑色背景开始,绘制并标注坐标系(x轴和y轴)。
2.逐一绘制并标注点 A、B、C、D,使用各自的颜色。
3.用浅蓝色线条连接四点,绘制矩形正方形。
4.缓慢绘制黄色半圆形曲线,强调其为参数曲线。
5.用青色填充曲线下的区域,突出显示待计算的面积。
6.在阴影区域内显示公式
-
采用数学插图常见的简洁精确风格。
-
使用黑色背景,搭配白色文本和彩色元素(点、线、阴影),增强视觉对比度。
-
确保所有元素(点、曲线、阴影)清晰可辨。
-
动画过渡需平滑,节奏适中,避免观众感到仓促。
-
可加入细微动态效果(如曲线逐渐绘制、阴影逐步填充),增加趣味性和吸引力。
小结
-
模型能力持续提升,效果都比以往更好,准确度更高;
-
我们还没有完全发挥这些模型的潜力,主要是缺乏想象力;
-
只要善用模型配置和写代码的能力,AI就能在日常工作中带来巨大的帮助。
-
数据分析
-
生成报告
-
日常自动化任务
-
尝试让模型和自身领域结合,掘出更多实用价值;
三、MCP:模型与现实世界的连接
什么是 MCP?

MCP怎么工作?
-
MCP客户端:嵌在AI应用里(比如Claude Desktop),负责跟服务器“聊天”,告诉服务器“我需要什么数据”或者“帮我干点儿啥”。 -
MCP服务器:一个轻量级的小程序,连接到具体的数据源或工具(比如你的本地文件、GitHub仓库、Slack频道),然后按照客户端的请求提供数据或者执行任务。
1.获取数据:比如从数据库里查东西、从文件里读内容。
2.执行操作:比如调用API发个消息、管理代码仓库。

MCP有什么好处?
1.标准化:就像USB-C成了通用接口,MCP让AI跟外部世界的连接有了统一标准,省去了重复开发的麻烦。
2.安全性:服务器管着访问权限,不用担心数据被乱用。
3.灵活性:不管是数据库、文件还是API,MCP都能支持,而且还能根据需要扩展。
MCP能干啥?
-
数据分析:AI可以直接查数据库,拿到最新数据帮你分析。
-
自动化任务:比如让AI调用API,在GitHub上创建issue,或者在Slack上发消息。
-
开发辅助:AI跟你的代码编辑器(IDE)连起来,帮你写代码、找bug。
如何开发MCP Server?
-
开发一个MCP Server需要使用Anthropic的Model Context Protocol(MCP),它是一个开源标准协议,帮助AI模型与外部数据源和工具无缝连接。
-
推荐使用Python SDK,通过uv或pip安装,创建简单的服务器文件,并使用mcp dev命令本地运行。
-
该服务器可以作为HTTP服务运行,通常监听默认端口(如3000),用户可以通过HTTP请求与服务器交互。
-
资源(Resources)资源是AI可以读取的数据,比如文件内容、数据库查询结果或API的响应。 例如,AI可能通过资源获取你的日历事件列表。
-
工具(Tools)工具是AI可以调用的函数,用于执行特定操作,比如添加新任务或发送邮件,使用工具时,通常需要用户先批准,以确保安全。
-
提示词(Prompts)提示词是服务器提供给AI的预写消息或模板,帮助AI理解如何使用资源和工具,例如,服务器可能告诉AI:“你可以添加任务,试试说‘添加任务:买牛奶’”,从而帮助用户更轻松地完成任务。提示词虽然直接提供给AI,但实际上是通过AI间接帮助用户,比如AI会根据提示词告诉用户如何操作。

安装与设置
-
使用uv(推荐,速度更快):运行uv add "mcp[cli]"。 uv是一个Rust编写的现代Python包管理器,相比传统pip更高效。
curl -LsSf https://astral.sh/uv/install.sh | sh
uv add "mcp[cli]"
-
使用pip:运行pip install mcp。
创建简单服务器
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Simple Server")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add两个数字"""
return a + b
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
"""获取个性化问候"""
return f"Hello, {name}!"
mcp dev server.py

import sqlite3
from fastapi import HTTPException
from mcp.server.fastmcp import FastMCP
import atexit
db_conn = None
def init_db():
global db_conn
db_conn = sqlite3.connect("todo.db")
cursor = db_conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS tasks (id INTEGER PRIMARY KEY, description TEXT NOT NULL, completed INTEGER DEFAULT 0);")
db_conn.commit()
init_db()
def close_db():
if db_conn:
db_conn.close()
atexit.register(close_db)
mcp = FastMCP("To-Do List Server")
@mcp.tool()
def add_task(description: str) -> int:
if not description.strip():
raise ValueError("Task description cannot be empty")
cursor = db_conn.cursor()
cursor.execute("INSERT INTO tasks (description) VALUES (?);", (description,))
task_id = cursor.lastrowid
db_conn.commit()
return task_id
@mcp.tool()
def mark_task_completed(task_id: int) -> bool:
cursor = db_conn.cursor()
cursor.execute("UPDATE tasks SET completed=1 WHERE id=?;", (task_id,))
rows_affected = cursor.rowcount
db_conn.commit()
return rows_affected > 0
@mcp.tool()
def delete_task(task_id: int) -> bool:
cursor = db_conn.cursor()
cursor.execute("DELETE FROM tasks WHERE id=?;", (task_id,))
rows_affected = cursor.rowcount
db_conn.commit()
return rows_affected > 0
@mcp.tool()
def update_task_description(task_id: int, new_description: str) -> bool:
if not new_description.strip():
raise ValueError("Task description cannot be empty")
cursor = db_conn.cursor()
cursor.execute("UPDATE tasks SET description=? WHERE id=?;", (new_description, task_id))
rows_affected = cursor.rowcount
db_conn.commit()
return rows_affected > 0
@mcp.resource("tasks://all")
def get_all_tasks() -> list[dict]:
cursor = db_conn.cursor()
cursor.execute("SELECT id, description, completed FROM tasks;")
tasks = []
for row in cursor.fetchall():
tasks.append({"id": row[0], "description": row[1], "completed": bool(row[2])})
return tasks
@mcp.resource("task_status://{task_id}")
def get_task_status(task_id: int) -> dict:
cursor = db_conn.cursor()
cursor.execute("SELECT description, completed FROM tasks WHERE id=?;", (task_id,))
row = cursor.fetchone()
if row is None:
raise HTTPException(status_code=404, detail="Task not found")
return {"description": row[0], "completed": bool(row[1])}
@mcp.resource("task_counts://{dummy}")
def get_task_counts(dummy: str = "all") -> dict:
cursor = db_conn.cursor()
cursor.execute("SELECT COUNT(*) FROM tasks WHERE completed=0;")
incomplete_count = cursor.fetchone()[0]
cursor.execute("SELECT COUNT(*) FROM tasks WHERE completed=1;")
completed_count = cursor.fetchone()[0]
return {"incomplete": incomplete_count, "completed": completed_count}
@mcp.prompt()
def todo_list_prompt() -> str:
return """
You have access to a to-do list server. You can use the following tools and resources:
- Tool: add_task(description) -> int
- Adds a new task with the given description and returns the task ID.
- Tool: mark_task_completed(task_id) -> bool
- Marks the task with the given ID as completed and returns True if successful, False otherwise.
- Tool: delete_task(task_id) -> bool
- Deletes the task with the given ID and returns True if successful, False otherwise.
- Tool: update_task_description(task_id, new_description) -> bool
- Updates the description of the task with the given ID and returns True if successful, False otherwise.
- Resource: tasks://all
- Returns a list of all tasks, each with their ID, description, and completion status.
- Resource: task_status://{task_id}
- Returns the status of the task with the given ID, including its description and completion status.
- Resource: task_counts://{dummy}
- Returns a dictionary with the count of incomplete and completed tasks.
You can use these to manage your to-do list.
"""
调试服务器



部署MCP服务
-
部署MCP服务器可以选择本地运行、VPS或云平台,具体取决于使用场景。
-
确保服务器稳定、安全,并支持JSON-RPC和SSE协议。
-
使用mcp install server.py可为Claude Desktop安装服务器;对于通用部署,可用Uvicorn或Docker运行。
-
部署需配置HTTPS、限制访问,并设置监控和日志。
sudo mcp install server.py

问题与修复
2025-03-01T13:15:43.231Z [To-Do List Server] [info] Initializing server...
2025-03-01T13:15:43.246Z [To-Do List Server] [error] spawn uv ENOENT {"context":"connection","stack":"Error: spawn uv ENOENTn at ChildProcess._handle.onexit (node:internal/child_process:285:19)n at onErrorNT (node:internal/child_process:483:16)n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"}
2025-03-01T13:15:43.246Z [To-Do List Server] [error] spawn uv ENOENT {"stack":"Error: spawn uv ENOENTn at ChildProcess._handle.onexit (node:internal/child_process:285:19)n at onErrorNT (node:internal/child_process:483:16)n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"}
2025-03-01T13:15:43.248Z [To-Do List Server] [info] Server transport closed
2025-03-01T13:15:43.248Z [To-Do List Server] [info] Client transport closed
brew install uv

-
在运行 mcp install server2.py 时,使用 --with 选项指定所需的依赖包。例如:
mcp install server2.py --with fastapi
-
如果服务还依赖其他包(例如 uvicorn),可以用逗号分隔列出:
mcp install server2.py --with fastapi,uvicorn
-
运行后,MCP 会在隔离环境中自动安装这些包。
-
在你的服务代码 server2.py 中,使用 FastMCP 的 dependencies 参数指定依赖包。例如:
from fastmcp import FastMCP
mcp = FastMCP("To-Do List Server", dependencies=["fastapi", "uvicorn"])

如何集成MCP Server?
Claude Desktop
sudo mcp install server.py


Cursor&Windsurf

集成外部Mcp Server
-
mcp.so:社区驱动的平台,包含 1584 个服务器,适合发现和分享。 -
glama.ai/mcp/servers:列出 872 个开源 MCP 服务器,提供详细信息。 -
portkey.ai/mcp-servers:列出 42 个 MCP 服务器,专注于开源领域。 -
GitHub 仓库:punkpeye/awesome-mcp-servers

{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "@executeautomation/playwright-mcp-server"]
}
}
}


客户端SDK集成
#!/usr/bin/env python3
"""
简单的 MCP 客户端示例
连接到 server2.py 并演示 MCP 的基本功能
"""
import asyncio
import os
import json
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
from typing import Optional, List, Dict, Any
# 创建连接到 server2.py 的参数
server_params = StdioServerParameters(
command="python",
args=[os.path.join(os.path.dirname(os.path.abspath(__file__)), "server2.py")],
env=None # 使用当前环境变量
)
async def run():
"""演示 MCP 客户端功能的主函数"""
print("正在连接到 MCP 服务器...")
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
# 1. 初始化连接
await session.initialize()
print("✓ 已成功初始化连接")
# 2. 获取可用的提示词
try:
prompts = await session.list_prompts()
print(f"可用的提示词: {prompts}")
if prompts and prompts.prompts:
# 3. 获取提示词内容
try:
prompt = await session.get_prompt(prompts.prompts[0].name)
print(f"n服务器提示词:n{prompt}n")
except Exception as e:
print(f"获取提示词内容时出错: {e}")
except Exception as e:
print(f"获取提示词列表时出错: {e}")
# 4. 列出可用资源
try:
resources = await session.list_resources()
print(f"可用的资源: {resources}")
except Exception as e:
print(f"获取资源列表时出错: {e}")
resources = []
# 5. 列出可用工具
try:
tools = await session.list_tools()
print(f"可用的工具: {tools}")
except Exception as e:
print(f"获取工具列表时出错: {e}")
tools = []
if __name__ == "__main__":
try:
asyncio.run(run())
except KeyboardInterrupt:
print("n程序已被用户中断")
except Exception as e:
print(f"n发生错误: {e}")
finally:
print("演示完成")

四、MCP 的未来畅想
-
开发者不再需要从零开始写复杂的代码,只用几行配置就能快速搭出一个 AI 驱动的应用。比如,一个程序员想做一个“智能日程助手”,通过 MCP 直接调用日历服务和 AI 模型,半天就能上线。 -
普通用户甚至都不用会编程。就像点外卖一样,他们只需要在 Claude Desktop 上输入几行简单的指令,比如“帮我买点东西”,AI 就能通过 MCP 连接到购物服务,几分钟搞定。 -
服务商也能轻松转型。过去的老牌公司,比如物流商或银行,只需开放一个标准的 MCP 接口,AI 模型就能直接集成,用户点点鼠标就能用上服务,省去了繁琐的定制开发。
-
购物:你说:“帮我买一箱牛奶和一些新鲜水果。” AI 通过 MCP 连接到电商平台,自动筛选最佳商品、下单、支付,甚至根据你的偏好安排次日送达。 -
健康管理:你说:“我最近睡眠不好。” AI 立刻调用健康服务,分析你的睡眠数据,推荐调整作息的建议,或者直接帮你预约睡眠专家。 -
旅行规划:你说:“我想下个月去意大利玩十天。” AI 会自动搜索最优机票、预订特色酒店、规划经典景点路线,还能根据天气预报提醒你带上雨伞。 -
美食体验:你说:“今晚我想吃中餐,但不想出门。” AI 迅速连接外卖平台,推荐附近评分最高的中餐厅,帮你点好菜送到家门口。 -
教育与工作:你说:“我需要准备明天的会议PPT。” AI 不仅能整理资料、生成幻灯片,还能根据你的风格润色内容;学生说:“我不会解二次方程。” AI 则会调用教育平台,提供步骤讲解和互动练习。
五、总结
-
Spark AI 官网:https://aispark.alibaba-inc.com/
-
AI应用搭建平台:https://appbuilder.alibaba-inc.com/
-
https://www.anthropic.com/news/claude-3-7-sonnet
-
https://www.anthropic.com/claude/sonnet#customer-stories
-
https://assets.anthropic.com/m/785e231869ea8b3b/original/claude-3-7-sonnet-system-card.pdf
-
https://modelcontextprotocol.io/clients
-
https://github.com/modelcontextprotocol/python-sdk
-
mcp.so:社区驱动的平台,包含 1584 个服务器,适合发现和分享。
-
glama.ai/mcp/servers:列出 872 个开源 MCP 服务器,提供详细信息。
-
portkey.ai/mcp-servers:列出 42 个 MCP 服务器,专注于开源领域。
-
GitHub 仓库:punkpeye/awesome-mcp-servers
构建高性能秒杀系统
秒杀活动因其高流量和用户参与度,已成为电商平台的重要营销方式。本方案详细介绍如何利用阿里云产品构建高性能秒杀系统,以实现高并发处理,确保系统稳定和快速响应,从而为用户提供流畅的抢购体验。
点击阅读原文查看详情。