Files
xiaohongshu-mcp/go.mod
T
zyandClaude Opus 5 9315948f74 chore(mcp): 升级 go-sdk 到 v1.4.0 并开启 Stateless (#771)
* chore(mcp): 升级 go-sdk 到 v1.4.0 并开启 Stateless

- go-sdk v0.7.0 -> v1.4.0,Go 源码零改动(本项目用到的 API 无破坏性变更)
- StreamableHTTPOptions 开启 Stateless:客户端可跳过 initialize 握手,
  单次 POST 直接调用工具,简化各类 MCP 客户端接入
- 保留 SDK v1.4.0 默认开启的 DNS rebinding 防护,不做旁路

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* test(mcp): 固定无握手单次 POST 的契约

开启 Stateless 后,客户端可以不走 initialize 握手、一发请求就调用工具。
这是对外的行为承诺,但它由一行配置支撑:删掉 Stateless、或 SDK 改了语义,
编译和现有单测都不会报错,承诺会静默消失。

只用 tools/list 断言:它不碰浏览器,测试保持 hermetic,而它恰好就是契约
丢失时的失败点——有状态模式下无 session 调用会被回以「握手前不允许调用」。
已验证把 Stateless 改回 false 时该测试确实失败。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(mcp): 收敛 Stateless 相关注释

三处问题:

一是把未经验证的推断写成了肯定句。原注释断言「将来要加进度推送或
elicitation,必须同时去掉 Stateless 和 JSONResponse」——后半句是从通知
路由规则推出来的,没有实测。留在代码里会被当成既有结论,删掉。

二是复述 SDK 文档。Stateless 是什么、有什么代价,上游文档里都有;注释
该写的是为什么选它、什么时候不能用。

三是位置和体量与既有风格不符:旁边都是行尾短注释,不该在函数调用上方
压一个四行块。改为贴在字段上。

测试的函数头注释同步收敛,去掉「只有这里能拦住」这种绝对表述。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-07-28 01:13:46 +08:00

59 lines
2.3 KiB
AMPL

module github.com/xpzouying/xiaohongshu-mcp
go 1.24.0
require (
github.com/avast/retry-go/v4 v4.7.0
github.com/gin-gonic/gin v1.10.1
github.com/go-rod/rod v0.116.2
github.com/h2non/filetype v1.1.3
github.com/modelcontextprotocol/go-sdk v1.4.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.11.1
github.com/ulikunitz/xz v0.5.15
github.com/xpzouying/headless_browser v0.4.0
)
require (
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-rod/stealth v0.4.9 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/jsonschema-go v0.4.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/segmentio/asm v1.1.3 // indirect
github.com/segmentio/encoding v0.5.3 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
github.com/ysmood/fetchup v0.2.3 // indirect
github.com/ysmood/goob v0.4.0 // indirect
github.com/ysmood/got v0.41.0 // indirect
github.com/ysmood/gson v0.7.3 // indirect
github.com/ysmood/leakless v0.9.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)