内容
<p align="center">
<img src=".github/banner.png" alt="文档记忆" width="100%" />
</p>
<p align="center">
<strong>文档记忆代理可以证明。</strong><br/>
PDF 及网址 → 引用的答案 · 证据包 · 链上证明
</p>
<p align="center">
<a href="https://www.npmjs.com/package/docimprint"><img src="https://img.shields.io/npm/v/docimprint?color=0ea5e9&labelColor=0a0a0a" alt="npm 版本" /></a>
<a href="https://www.npmjs.com/package/docimprint"><img src="https://img.shields.io/npm/dm/docimprint?color=0ea5e9&labelColor=0a0a0a" alt="npm 下载量" /></a>
<a href="https://pypi.org/project/docimprint/"><img src="https://img.shields.io/pypi/v/docimprint?color=0ea5e9&labelColor=0a0a0a" alt="PyPI 版本" /></a>
<a href="https://pypi.org/project/docimprint/"><img src="https://img.shields.io/pypi/dm/docimprint?color=0ea5e9&labelColor=0a0a0a" alt="PyPI 下载量" /></a>
<a href="https://smithery.ai/servers/@sawftware-apps/docimprint"><img src="https://img.shields.io/badge/Smithery-listed-0ea5e9?labelColor=0a0a0a" alt="Smithery" /></a>
<a href="https://glama.ai/mcp/servers/docimprint"><img src="https://img.shields.io/badge/Glama-listed-0ea5e9?labelColor=0a0a0a" alt="Glama" /></a>
<a href="https://api.docimprint.com/mcp"><img src="https://img.shields.io/badge/MCP-streamable--http-0ea5e9?labelColor=0a0a0a" alt="MCP" /></a>
<a href="https://api.docimprint.com/openapi.json"><img src="https://img.shields.io/badge/OpenAPI-spec-0ea5e9?labelColor=0a0a0a" alt="OpenAPI" /></a>
<a href="https://docimprint.com/docs"><img src="https://img.shields.io/badge/docs-docimprint.com-0ea5e9?labelColor=0a0a0a" alt="文档" /></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-0ea5e9?labelColor=0a0a0a" alt="MIT 许可证" /></a>
<a href="https://github.com/sawftware-apps/docimprint-sdk/stargazers"><img src="https://img.shields.io/github/stars/sawftware-apps/docimprint-sdk?color=0ea5e9&labelColor=0a0a0a" alt="GitHub 明星" /></a>
</p>
---
## 目录
- [概览](#概览)
- [选择您的集成](#选择您的集成)
- [查看您获得的内容](#查看您获得的内容)
- [工作原理](#工作原理)
- [为什么不使用普通的 OCR 或 RAG?](#为什么不使用普通的ocr或rag)
- [用例](#用例)
- [安装](#安装)
- [快速入门](#快速入门)
- [功能](#功能)
- [为什么选择 DocImprint?](#为什么选择docimprint)
- [代理原生功能](#代理原生功能)
- [CrewAI 集成](#crewai集成)
- [MCP 服务器](#mcp服务器)
- [API 参考](#api参考)
- [错误处理](#错误处理)
- [身份验证](#身份验证)
- [TypeScript](#typescript)
- [定价](#定价)
- [社区](#社区)
- [链接](#链接)
---
## 概览
DocImprint 将任何 PDF 或网址转换为**防篡改证据包** — 结构化数据、AI 引用的答案和您的代理可以独立验证的加密证明。
| | |
|---|---|
| **输入** | PDF 或网址 |
| **输出** | `ev_...` 证据包 — 引用的答案、工件哈希、EIP-191 签名 |
| **验证** | `client.verify()` — 免费,无需身份验证;可选的 Base L2 记账凭证 via EAS |
---
## 选择您的集成
| 路径 | 最适合 | 开始使用 |
|---|---|---|
| **TypeScript SDK** | Node 代理,类型化应用 | [快速入门](#快速入门) |
| **Python SDK** | CrewAI,脚本 | [快速入门](#快速入门) · [CrewAI](#crewai-integration) |
| **MCP 服务器** | Claude,Cursor | [MCP 服务器](#mcp服务器) |
| **x402 USDC** | 自主代理,无需账户 | [x402 USDC 支付](#x402-usdc-payments) |
---
## 查看您获得的内容
每个响应都包含一个可验证的包 ID、清单哈希和与确切来源引用的答案。
```json
{
"bundle_id": "ev_01jqv8k3m2x",
"manifest_sha256": "a3f2c1d8e9b0476f8a2b1c0d9e8f7a6b5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f",
"signature": {
"signature": "0x8f4e2a1b9c3d5e7f0a2b4c6d8e0f1a3b5c7d9e1f3a5b7c9d1e3f5a7b9c1d3e5f71c",
"signer_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0EbE",
"algorithm": "secp256k1-eip191"
},
"answer_cited": {
"value": "第 4.2 节不允许单方面终止而不提供 90 天的书面通知。",
"citations": [
{
"quote": "任一方不得单方面终止本协议,除非提前 ninety (90) 天向另一方提供书面通知。",
"paragraphs": [42],
"page": 4,
"confidence": "high"
}
]
},
"artifacts": {
"markdown": { "sha256": "b4e5f6a79876543210fedcba9876543210fedcba9876543210fedcba9876543210ab" },
"manifest": { "sha256": "a3f2c1d8e9b0476f8a2b1c0d9e8f7a6b5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f" }
}
}
```
<p align="center">
<img src=".github/readme/api-response-provenance.png" alt="带有出处和引用的 API 响应" width="90%" />
</p>
<p align="center">
<img src=".github/readme/manifest-json.png" alt="证据包清单解剖" width="90%" />
</p>
---
## 工作原理
```mermaid
flowchart LR
source[PDF 或网址] --> extract[提取 / 质量保证 / 检查声明]
extract --> bundle[证据包 ev_...]
bundle --> artifacts[工件 + 清单 SHA-256]
bundle --> citations[引用的答案和引用]
artifacts --> verify[验证 - 免费]
verify --> notarize[记账凭证 - 可选]
```
<p align="center">
<img src=".github/readme/merkle-flow-diagram.png" alt="Merkle 引用证明流程" width="90%" />
</p>
---
## 为什么不使用普通的 OCR 或 RAG?
| | 普通 OCR | 向量 RAG | DocImprint |
|---|---|---|---|
| 确切的来源引用 | 否 | 近似 | 是的,带有段落引用 |
| 防篡改证据 | 否 | 否 | SHA-256 清单 + EIP-191 签名 |
| 独立验证 | 否 | 否 | `verify()` 无需 API 密钥 |
| 链上证明 | 否 | 否 | Base L2 上的 EAS |
| 代理审计轨迹 | 否 | 否 | 出处 + 移交(Python) |
---
## 用例
| 场景 | 方法 | 结果 |
|---|---|---|
| **合同问答** | `client.qa()` | 引用的答案和置信度评分 |
| **声明验证** | `client.checkClaims()` | 每个声明的判决:`supported` / `contradicted` / `not_found` |
| **发票接收** | `client.extract({ mode: 'invoice' })` | 结构化商家、行项目、总计 — 全部引用 |
| **合规存档** | `legal_hold: true` + `notarize()` | 不变的链上记录,阻止删除 |
---
## 安装
```bash
npm install docimprint # TypeScript / Node.js
```
```bash
pip install docimprint # Python REST 客户端
pip install "docimprint[crewai]" # + 10 个 CrewAI 工具和 ProvenanceTracker
```
Python 源代码位于 [`python/`](python/)。PyPI: [docimprint](https://pypi.org/project/docimprint/)。
---
## 快速入门
在 [docimprint.com](https://docimprint.com) 获取 API 密钥 — 免费层可用,无需信用卡。
**TypeScript**
```typescript
import { DocImprintClient } from 'docimprint'
const client = new DocImprintClient({ apiKey: 'dr_live_...' })
const result = await client.extract({
source: 'https://example.com/contract.pdf',
include: ['markdown', 'summary'],
})
console.log(result.bundle_id) // ev_01j...
console.log(result.summary) // AI 生成的摘要
console.log(result.manifest_sha256) // 防篡改哈希
console.log(result.key_points_cited[0].citations[0].quote)
```
**Python**
```python
from docimprint import DocImprintClient
client = DocImprintClient(api_key="dr_live_...")
result = client.extract(
url="https://example.com/contract.pdf",
include=["markdown", "summary"],
)
print(result["bundle_id"]) # ev_01j...
print(result["summary"]) # AI 生成的摘要
print(result["manifest_sha256"]) # 防篡改哈希
```
**REST API(cURL)
```bash
curl -X POST https://api.docimprint.com/v1/extract \
-H "Authorization: Bearer dr_live_..." \
-H "Content-Type: application/json" \
-d '{"source": "https://example.com/contract.pdf", "include": ["markdown", "summary"]}'
```
---
## 功能
| 能力 | 方法 / 模式 | 描述 |
|---|---|---|
| **提取** | `extract()` | 完整的证据包 — markdown, 摘要,引用的关键点,工件,清单 SHA-256 |
| **发票解析** | `mode: 'invoice'` | 结构化 `InvoiceResult`: 商家,日期,行项目,子总计,税,总计 — 全部引用 |
| **文档比较** | `mode: 'compare'` | 差异两个文档;提供 `previous_bundle_id` 跟踪更改 |
| **结构化提取** | `mode: 'extract-structured'` | 提取使用调用者定义的 JSON 模式的键入字段 |
| **总结** | `summarize()` | 散文摘要 + 关键点,每个都有引用的段落引用 |
| **问答** | `qa()` | 单个问题的答案,带有内联引用和置信度评分 |
| **声明检查** | `checkClaims()` | 每个声明的判决:`supported` / `contradicted` / `not_found` |
| **翻译** | `translate()` | 来源引用的翻译到任何语言 |
| **描述** | `describe()` | AI 对图像或 PDF 页面内容的描述 |
| **集合** | `createCollection()` + `searchCollection()` + `askCollection()` | 语义搜索 + 跨文档 RAG 问答多个包 |
| **验证** | `verify()` | 加密完整性检查 — 清单哈希,EIP-191 签名,工件哈希。免费,无需身份验证 |
| **记账凭证** | `notarize()` | 将清单 SHA-256 写入 Base L2 via EAS — 永久,不变证明 |
| **MCP 服务器** | 20 工具 · 2 提示 | 原生 MCP,用于 Claude,Cursor 和任何 MCP 兼容的客户端 |
| **x402** | REST `X-Payment` header | 按调用支付 USDC — 无需账户 |
---
## 为什么选择 DocImprint?
- 🔏 **X-Payment` 标头 | 按需支付 USDC — 无需账户,无需注册,无需 API 密钥。您的代理可以自主调用 API,无需人类管理的凭证。
---
## 代理原生功能
DocImprint 专为自主代理工作流设计,而不仅仅是同步 API 调用。
```typescript
// 火箭发射异步提取 — 立即返回 job_id
const job = await client.extract({
source: 'https://example.com/large-report.pdf',
async: true,
webhook: 'https://your-agent.io/callback',
idempotency_key: 'report-2025-q4',
legal_hold: true,
})
const status = await client.getJob(job.job_id)
// { status: 'complete', bundle_id: 'ev_...', progress_pct: 100 }
// 监控 URL 变化 — 获取通知时发生差异
await client.extract({
source: 'https://example.com/terms.html',
monitor: { webhook: 'https://your-agent.io/changes', mode: 'diff' },
})
```
**Python:出处跟踪和多代理交接**
```python
client.log_provenance(bundle_id="ev_...", agent_id="agent-research", action="extracted")
client.handoff(bundle_id="ev_...", from_agent="agent-research", to_agent="agent-legal", note="ready for claim check")
```
---
## CrewAI 集成
10 个适用于 CrewAI 代理的预制工具,分为预设组。
```python
from docimprint.crewai import DocImprintToolkit
toolkit = DocImprintToolkit(
api_key="dr_live_...",
collection_id="col_...", # required for collection tools
)
toolkit.research_tools() # extract, summarize, qa, check_claims
toolkit.legal_tools() # check_claims, verify, notarize
toolkit.collection_tools() # search, ask, add_to_collection
toolkit.all_tools() # all 10 tools
```
| 工具 | 功能 |
|------|---|
| `ExtractEvidenceTool` | 完整的证据包,带有引用和清单哈希 |
| `SummarizeTool` | 关键点,带有引用的段落引用 |
| `QATool` | 引用的答案,带有置信度评分 |
| `CheckClaimsTool` | 每个声明的判决:支持 / 矛盾 / 未找到 |
| `TranslateTool` | 来源引用的翻译 |
| `VerifyBundleTool` | 加密完整性检查 — 清单,哈希,签名 |
| `NotarizeTool` | Base L2 上的链上 EAS 证明 |
| `SearchCollectionTool` | 文档集合的语义向量搜索 |
| `AskCollectionTool` | 跨文档 RAG 问答,带有来源引用 |
| `AddToCollectionTool` | 将包添加到集合并触发异步索引 |
**ProvenanceTracker** 包装所有工具,以便自动记录代理操作和包交接。
```python
from docimprint.crewai import DocImprintToolkit, ProvenanceTracker
tracker = ProvenanceTracker(client=toolkit.client)
trackable = toolkit.trackable_tools()
```
**DocImprintKnowledgeSource** 与 CrewAI 的知识系统集成,用于检索增强的代理。
---
## MCP 服务器
DocImprint 公开了一个原生 MCP 服务器,供 Claude,Cursor 和任何 MCP 兼容的客户端使用。
**通过 Smithery 安装(一步到位):**
```bash
npx @smithery/cli install docimprint --client claude
```
**手动配置:**
```json
{
"mcpServers": {
"docimprint": {
"type": "streamable-http",
"url": "https://api.docimprint.com/mcp",
"headers": {
"Authorization": "Bearer dr_live_..."
}
}
}
}
```
传输:`streamable-http` · 认证:Bearer token · [Listed on Smithery](https://smithery.ai/servers/@sawftware-apps/docimprint) · [Listed on Glama](https://glama.ai/mcp/servers/docimprint)
### MCP 工具
**URL 工具** — 精简模式,无需存储包:
| 工具 | 描述 |
|------|---|
| `extract_url` | 获取 URL → 文本 + 元数据 |
| `summarize_url` | 获取 URL → 散文摘要 + 关键点 |
| `qa_url` | 获取 URL → 引用的答案 |
| `translate_url` | 获取 URL → 翻译内容 |
**文档工具** — 接受 base64 PDF 或图像:
| 工具 | 描述 |
|------|---|
| `extract_text` | 从 PDF / 图片中提取纯文本 |
| `extract_tables` | 从 PDF / 图片中提取表格为 Markdown |
| `parse_invoice` | 结构化发票字段:商家,行项目,总计 + 引用 |
| `summarize_document` | 散文摘要 + 引用关键点 |
| `check_claims` | 每个声明的判决,带有证据引用 |
| `extract_structured` | 使用调用者定义的模式提取键入字段 |
**包和集合:**
| 工具 | 描述 |
|------|---|
| `verify_bundle` | 加密完整性检查 |
| `get_bundle` | 包元数据和记账凭证状态 |
| `notarize_bundle` | Base L2 上的链上 EAS 证明 |
| `create_collection` | 创建一个命名文档集合 |
| `list_collections` | 列出您的集合 |
| `add_document_to_collection` | 添加包 + 触发异步索引 |
| `search_collection` | 语义向量搜索 |
| `ask_collection` | 跨文档 RAG 问答 |
| `get_job_status` | 轮询异步作业(提取,索引,批处理) |
| `get_quota` | 检查信用余额和计划状态 |
**引导式提示:** `claim_check_workflow` · `invoice_intake`
**资源:** `bundle://{bundle_id}` — 直接读取包元数据
---
## API 参考
完整的类型化参考: [docimprint.com/docs](https://docimprint.com/docs) · [OpenAPI](https://api.docimprint.com/openapi.json)
| 类别 | 方法 |
|---|---|
| **核心** | `extract`, `verify`, `download`, `notarize`, `deleteBundle` |
| **聚焦** | `summarize`, `qa`, `translate`, `checkClaims`, `describe` |
| **提取模式** | `invoice`, `extract-structured`, `compare`, `store: false`(精简) |
| **集合** | `createCollection`, `listCollections`, `addToCollection`, `searchCollection`, `askCollection` |
| **作业** | `getJob`, `listJobs`, `getQuota` |
---
## 错误处理
```typescript
import { DocImprintClient, DocImprintError } from 'docimprint'
try {
const result = await client.extract({ source: 'https://example.com/doc.pdf' })
} catch (err) {
if (err instanceof DocImprintError) {
console.error(err.message) // 人类可读的错误
console.error(err.status) // HTTP 状态码
console.error(err.requestId) // x-request-id 用于支持
}
}
```
---
## 身份验证
### API 密钥
每月信用额度通过 Stripe — 在 [docimprint.com](https://docimprint.com) 注册,免费层可用:
```typescript
const client = new DocImprintClient({ apiKey: 'dr_live_...' })
```
### x402 USDC 支付
DocImprint 支持 [x402 开放标准](https://x402.org) — 在 Base 上使用 USDC 支付每个调用,无需账户,无需注册,无需 API 密钥。您的代理可以自主调用 API,无需人类管理的凭证。
API 是 x402 原生的:它返回一个标准的 `402 Payment Required` 响应,包含链上支付详细信息,您的客户端结算 USDC,请求自动完成。从 $0.01 / 调用。
**使用 `@x402/fetch`(自动支付处理):**
```typescript
import { wrapFetchWithPayment } from '@x402/fetch'
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { base } from 'viem/chains'
const account = privateKeyToAccount('0x...')
const wallet = createWalletClient({ account, chain: base, transport: http() })
const fetchWithPayment = wrapFetchWithPayment(fetch, wallet)
const res = await fetchWithPayment('https://api.docimprint.com/v1/summarize', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ source: 'https://example.com/report.pdf' }),
})
const data = await res.json()
```
**所有权路由的身份标识:** 对于需要所有权的 `GET`/`DELETE` 操作(例如,获取您的包),请传递来自先前支付响应的 `payment-signature` 头,以便 API 可以在不进行单独登录的情况下验证您的钱包地址。
---
## TypeScript
所有请求和响应类型均已导出:
```typescript
import type {
ExtractRequest,
ExtractResponse,
Citation,
CitedField,
InvoiceResult,
Job,
Collection,
SearchResult,
} from 'docimprint'
```
---
## 定价
免费层可用 — 无需信用卡。每月信用额度计划通过 Stripe,或通过 x402 以 USDC 支付。 [查看定价 →](https://docimprint.com/pricing)
---
## 社区
问题,集成和公告: [GitHub Discussions](https://github.com/sawftware-apps/docimprint-sdk/discussions)。
---
## 链接
- [文档](https://docimprint.com/docs)
- [API 参考](https://api.docimprint.com/openapi.json)
- [证据包](https://docimprint.com/evidence-bundles)
- [x402 支付](https://docimprint.com/x402)
- [定价](https://docimprint.com/pricing)
MCP 配置
以下是此 MCP Server 的配置信息,可直接复制到 Cursor 或其他 MCP 客户端中使用。
mcp.json
连接信息
猜你喜欢
暂无推荐服务器