Skip to main content

披沙(pisha)

铭文:披沙拣金,有时获宝 ——《史通·直书》 网络检索就是在沙里拣金。

轻量网络检索 MCP 服务器:六个工具代理到 Tavily API, 单文件、纯 Python 标准库、零第三方依赖。

独立重写自 tavily-ai/tavily-mcp v0.2.23(MIT), 无代码血缘:只提炼核心编排逻辑,代码由自己生成。

与上游的取舍

上游 tavily-mcp 披沙
语言/形态 TypeScript,npm 包 + 依赖树(axios、MCP SDK 等) 单文件 Python,纯标准库
代码量 1296 行 + 依赖树 1 文件约 550 行,17 KB
运行足迹 Node 进程,典型 80–150 MB 自身增量约 0.1 MB(进程峰值 21.7 MB,含解释器基线 21.6 MB)
工具 search / extract / crawl / map / research / feedback 同六个,描述精简
部署 npm install 拷一个文件

上游砍掉了什么:无前端、无本地抓取(extract/crawl/map 由 Tavily 服务端执行)、 无独立存储、无容器。

三处安全修复(相对上游)

  1. 凭据掩码全覆盖:上游工具结果错误路径未过掩码,API 回显 key 时会明文进模型上下文 (准入报告 L1,本地 PoC 实锤);披沙所有错误路径统一走 mask_keys。
  2. keyless 信封结构化透传:上游把 API 的 next_actions 渲染成面向 agent 的指令文本, 构成注入通道(L2);披沙原样结构化返回,不渲染指令。
  3. 默认参数只填缺省:上游 DEFAULT_PARAMETERS 会覆盖模型显式参数(L3); 披沙改为仅补缺省,模型说了算。

用法

# MCP stdio 服务(客户端配置)
# command: python3 /path/to/pisha.py
# env: TAVILY_API_KEY=tvly-xxx

# CLI 直跑
TAVILY_API_KEY=tvly-xxx python3 pisha.py search "量子计算 最新进展" --max 5
TAVILY_API_KEY=tvly-xxx python3 pisha.py extract "https://example.com"
TAVILY_API_KEY=tvly-xxx python3 pisha.py crawl "https://example.com" --max-depth 2
TAVILY_API_KEY=tvly-xxx python3 pisha.py map "https://example.com"
TAVILY_API_KEY=tvly-xxx python3 pisha.py research "开放性问题" --model mini

无 TAVILY_API_KEY 时进入 keyless 模式(受 Tavily 免费额度约束,错误信封结构化返回)。

如实边界

  • 仅代理 Tavily 官方 API,本机不做任何抓取;Tavily 不可用即不可用。
  • research 流式回退按行读 SSE,总时长上限与上游一致(pro 15 分钟 / mini 5 分钟), 但无上游的逐段超时中断语义。
  • 未实现上游的 OAuth 流程与 Smithery 配置装载;凭据只走环境变量。
  • 工具描述做了精简,上下文占用比上游小,但引导性弱于上游的长描述。

复刻哲学

功能可以复刻、架构可以复刻、逻辑可以复刻——代码算子由自己生成完善, 达到同样的功能与能力,而资源占用降低一个数量级。

致谢

  • 上游项目:tavily-ai/tavily-mcp(MIT), 本项目为其功能的独立重写实现,感谢其公开的工具设计与 API 编排思路。
  • API 服务:Tavily。

许可

MIT

Metadata

Release files for pisha 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pisha 0.1.0
File Size Uploaded Provenance Actions
pisha-0.1.0.tar.gz 11.7 kB Without provenance Details for pisha-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pisha 0.1.0
File Interpreter ABI Platform Actions
pisha-0.1.0-py3-none-any.whl Python 3 none any Details for pisha-0.1.0-py3-none-any.whl

Total release size: 23.5 kB

Release files / pisha-0.1.0.tar.gz

Download URL pisha-0.1.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
752be534fc20427da8ab9f647bfb4196dcbdaf9bcb5a01940a4a2a8e96a2c7b0
BLAKE2b-256 checksum
How to use checksums
c371c7d488f0e84d8a4df7a95afe1ca0caf3d7a40576512a94184d5147d804fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / pisha-0.1.0-py3-none-any.whl

Download URL pisha-0.1.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0557237eeda9fed1fa420b00f7d622e7932b4172a651149f78b4f0b26ec1e5db
BLAKE2b-256 checksum
How to use checksums
9e39be75c0e817774494a73ae2cbe8547341cfd6e86c553ccb71c11b65c54033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for pisha 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page