Token导航 LogoToken导航

MCP Server · 数据服务

Zerodb Python SDK

ZeroDB MCP Python Client SDK 是一个生产就绪的Python客户端,支持异步访问ZeroDB MCP Bridge API的所有60多个操作,包括向量、NoSQL表、文件存储和事件等功能。

stdio官方级别未说明来源级核验工具 0
向量数据库机器学习Python异步处理

快速开始

作者 / 组织
AINative-Studio
提供方
AINative-Studio

工具数量

0

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

0

仓库热度

收录来源

1 个

MCP World

选型结论

Zerodb Python SDK 属于数据服务类 MCP Server,公开资料标注 0 个工具,通过stdio 本地进程接入,客户端适配情况以官方文档为准,有可以直接复制的安装命令;接入前要先准备 会话凭据。

分类

数据服务

传输方式

stdio

认证方式

会话凭据

部署方式

公开资料未说明

安装与配置

安装命令

pip install zerodb-mcp

公开命令不是通用的启动方式,拼不出可靠配置示例;请在客户端 MCP 配置里按官方文档填写 command 和 args。

上手步骤

  1. 1

    准备运行环境

    stdio 服务在本地起进程,需要先装好 对应的运行时,再按安装命令拉取依赖。

  2. 2

    安装服务

    复制下面的安装命令执行;命令里带占位符的位置换成自己的密钥或路径。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 0 个工具,随便调一个只读工具确认能返回结果。

接入前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

详细介绍

ZeroDB MCP Python客户端SDK

用于ZeroDB MCP Bridge API的可用于生产的Python客户端。提供对所有60多种操作的全面异步访问,包括向量、TurboQuant向量压缩(PolarQuant+QJL)、NoSQL表、文件存储、事件、RLHF和管理功能。

特性

  • API全面覆盖:所有60+MCP网桥操作
  • 异步/等待支持:基于 httpx 用于高性能异步操作
  • 类型安全:完整的Pydantic模型验证
  • 自动检索:具有指数回退的智能重试逻辑
  • 错误处理:全面的异常层次结构
  • 速率限制:内置速率限制处理,支持后重试
  • 认证:API密钥和JWT令牌支持
  • 生产就绪:经过战斗测试,测试覆盖率超过90%

安装

pip install zerodb-mcp

开发安装

git clone https://github.com/ainative/zerodb-mcp-python.git
cd zerodb-mcp-python
pip install -e ".[dev]"

快速开始

使用ZeroDB云

import asyncio
from zerodb_mcp import ZeroDBClient

async def main():
    # Initialize client (cloud)
    client = ZeroDBClient(api_key="your_api_key")

    # Create a project
    project = await client.projects.create(
        name="My AI Project",
        tier="pro"
    )

    # Upsert vectors
    result = await client.vectors.upsert(
        project_id=project["project_id"],
        embedding=[0.1, 0.2, 0.3] * 512,  # 1536 dimensions
        document="Machine learning tutorial on neural networks",
        metadata={"category": "education", "language": "en"}
    )

    # Search vectors
    results = await client.vectors.search(
        project_id=project["project_id"],
        query_vector=[0.15, 0.25, 0.35] * 512,
        limit=10,
        threshold=0.7
    )

    for item in results["results"]:
        print(f"Document: {item['document']}")
        print(f"Similarity: {item['similarity']:.3f}\n")

    # Close client
    await client.close()

# Run async code
asyncio.run(main())

使用ZeroDB本地

import asyncio
from zerodb_mcp import ZeroDBClient

async def main():
    # Initialize client (local)
    client = ZeroDBClient(
        base_url="http://localhost:8000",  # Local ZeroDB instance
        api_key="local-dev-key"  # Any value works for local
    )

    # Same API as cloud - use all operations identically
    project = await client.projects.create(
        name="Local Development Project"
    )

    # Develop offline, sync when ready
    result = await client.vectors.upsert(
        project_id=project["project_id"],
        embedding=[0.1, 0.2, 0.3] * 512,
        document="Test document for local development"
    )

    await client.close()

asyncio.run(main())

了解更多: 看 ZeroDB本地快速入门 用于安装和设置。

认证

API密钥验证

# Method 1: Direct initialization
client = ZeroDBClient(api_key="your_api_key")

# Method 2: Environment variable
# Set ZERODB_API_KEY in .env file
from dotenv import load_dotenv
load_dotenv()

client = ZeroDBClient()  # Automatically loads from env

JWT令牌身份验证

# Method 1: Direct initialization
client = ZeroDBClient(jwt_token="your_jwt_token")

# Method 2: Environment variable
# Set ZERODB_JWT_TOKEN in .env file
client = ZeroDBClient()  # Automatically loads from env

核心业务

矢量运算(10次运算)

# 1. Upsert vector
result = await client.vectors.upsert(
    project_id="550e8400-e29b-41d4-a716-446655440000",
    embedding=[0.1, 0.2, ...],
    document="Text content",
    namespace="default",
    metadata={"key": "value"}
)

# 2. Batch upsert
vectors = [
    {"embedding": [0.1, ...], "document": "Doc 1", "metadata": {}},
    {"embedding": [0.2, ...], "document": "Doc 2", "metadata": {}}
]
result = await client.vectors.batch_upsert(project_id, vectors)

# 3. Search vectors
results = await client.vectors.search(
    project_id=project_id,
    query_vector=[0.15, 0.25, ...],
    limit=20,
    threshold=0.8
)

# 4. Delete vector
await client.vectors.delete(project_id, vector_id)

# 5. Get vector
vector = await client.vectors.get(project_id, vector_id)

# 6. List vectors
vectors = await client.vectors.list(project_id, limit=100, offset=0)

# 7. Vector statistics
stats = await client.vectors.stats(project_id)

# 8. Create index
await client.vectors.create_index(project_id, index_type="hnsw")

# 9. Optimize storage
result = await client.vectors.optimize_storage(project_id)

# 10. Export vectors
export = await client.vectors.export(project_id, format="json")

量子运算(6次运算)

ICLR 2026的TurboQuant矢量压缩(PolarQuant+QJL)。在0.9999余弦相似度下实现约3.5倍的压缩。

# 1. Compress vector using TurboQuant (PolarQuant + QJL)
result = await client.quantum.compress_vector(
    project_id=project_id,
    vector_id=vector_id,
    target_dimensions=128,
    backend="ionq"  # or "simulator", "braket"
)

# 2. Decompress vector
result = await client.quantum.decompress_vector(
    project_id=project_id,
    compressed_state=state,
    original_dimensions=1536
)

# 3. TurboQuant hybrid similarity search
results = await client.quantum.hybrid_similarity(
    project_id=project_id,
    query_vector=[0.1, 0.2, ...],
    top_k=10,
    quantum_weight=0.6,
    backend="ionq"
)

# 4. TurboQuant space optimization
result = await client.quantum.optimize_space(
    project_id=project_id,
    target_compression=0.5
)

# 5. TurboQuant feature mapping
result = await client.quantum.feature_map(
    project_id=project_id,
    vector_id=vector_id,
    feature_map_type="ZZFeatureMap"
)

# 6. TurboQuant kernel similarity
result = await client.quantum.kernel_similarity(
    project_id=project_id,
    vector_id_a=vec_a,
    vector_id_b=vec_b,
    kernel_type="fidelity"
)

表操作(8次操作)

# 1. Create table
table = await client.tables.create(
    project_id=project_id,
    table_name="users",
    schema_definition={
        "user_id": "string",
        "email": "string",
        "age": "integer"
    },
    indexes=["user_id", "email"]
)

# 2. Insert rows
result = await client.tables.insert_rows(
    project_id=project_id,
    table_name="users",
    rows=[
        {"user_id": "u1", "email": "user1@example.com", "age": 25},
        {"user_id": "u2", "email": "user2@example.com", "age": 30}
    ]
)

# 3. Query rows
results = await client.tables.query_rows(
    project_id=project_id,
    table_name="users",
    filters={"age": {"$gte": 18}},
    sort_by="age",
    order="desc"
)

# 4. Update rows
result = await client.tables.update_rows(
    project_id=project_id,
    table_name="users",
    filters={"age": {"$gte": 18}},
    updates={"verified": True}
)

# 5. Delete rows
result = await client.tables.delete_rows(
    project_id=project_id,
    table_name="users",
    filters={"active": False}
)

# 6. Get table
table = await client.tables.get(project_id, "users")

# 7. List tables
tables = await client.tables.list(project_id)

# 8. Delete table
await client.tables.delete(project_id, "users")

文件操作(6个操作)

# 1. Upload file from path
result = await client.files.upload(
    project_id=project_id,
    file_path="/path/to/document.pdf",
    metadata={"category": "legal"}
)

# 2. Upload file from bytes
content = b"Hello, World!"
result = await client.files.upload_bytes(
    project_id=project_id,
    content=content,
    file_name="hello.txt",
    content_type="text/plain"
)

# 3. Download file
content = await client.files.download(project_id, file_id)

# Save to file
await client.files.download(project_id, file_id, save_path="/path/to/save.pdf")

# 4. List files
files = await client.files.list(project_id, content_type="application/pdf")

# 5. Get file metadata
metadata = await client.files.get_metadata(project_id, file_id)

# 6. Generate presigned URL
url = await client.files.generate_presigned_url(
    project_id=project_id,
    file_id=file_id,
    expires_in=3600  # 1 hour
)

项目运营(7项运营)

# 1. Create project
project = await client.projects.create(
    name="My Project",
    tier="pro",
    settings={"enable_quantum": True}
)

# 2. Get project
project = await client.projects.get(project_id)

# 3. List projects
projects = await client.projects.list(tier="pro")

# 4. Update project
await client.projects.update(
    project_id=project_id,
    name="Updated Name"
)

# 5. Delete project
await client.projects.delete(project_id, confirm=True)

# 6. Get project stats
stats = await client.projects.get_stats(project_id)

# 7. Enable database
await client.projects.enable_database(
    project_id=project_id,
    database_type="postgres"
)

事件操作(5次操作)

# 1. Create event
event = await client.events.create(
    project_id=project_id,
    event_type="user.login",
    event_data={"user_id": "u123", "ip": "192.168.1.1"}
)

# 2. List events
events = await client.events.list(
    project_id=project_id,
    event_type="user.login",
    start_date="2025-01-01T00:00:00Z"
)

# 3. Get event
event = await client.events.get(project_id, event_id)

# 4. Subscribe to events
subscription = await client.events.subscribe(
    project_id=project_id,
    event_types=["user.login", "user.logout"]
)

# 5. Event statistics
stats = await client.events.stats(project_id)

RLHF作战(10次作战)

# 1. Collect interaction
interaction = await client.rlhf.collect_interaction(
    session_id="sess_123",
    project_id=project_id,
    interaction_type="query",
    user_input="What is AI?",
    agent_response="AI is...",
    context={"model": "gpt-4"}
)

# 2. Collect feedback
feedback = await client.rlhf.collect_agent_feedback(
    session_id="sess_123",
    project_id=project_id,
    interaction_id=interaction["interaction_id"],
    rating=5,
    feedback_text="Very helpful!"
)

# 3. Collect workflow feedback
await client.rlhf.collect_workflow_feedback(
    session_id="sess_123",
    project_id=project_id,
    workflow_id="search",
    success=True,
    duration_ms=250
)

# 4. Report error
await client.rlhf.collect_error_report(
    session_id="sess_123",
    project_id=project_id,
    error_type="ValidationError",
    error_message="Invalid input"
)

# 5-10. Status, summary, session management
status = await client.rlhf.get_status(project_id)
summary = await client.rlhf.get_summary(project_id)
session = await client.rlhf.start_collection(project_id, "sess_123")
await client.rlhf.stop_collection(project_id, "sess_123")
interactions = await client.rlhf.get_session_interactions(project_id, "sess_123")
await client.rlhf.broadcast_event(project_id, "feedback.received", {})

管理操作(5个操作)

需要管理员权限。

# 1. System statistics
stats = await client.admin.get_system_stats()

# 2. List all projects
projects = await client.admin.list_all_projects(tier="enterprise")

# 3. User usage
usage = await client.admin.get_user_usage("user_id")

# 4. System health
health = await client.admin.system_health()

# 5. Optimize database
result = await client.admin.optimize_database(vacuum=True, reindex=True)

错误处理

from zerodb_mcp import (
    ZeroDBError,
    AuthenticationError,
    RateLimitError,
    ValidationError,
    ResourceNotFoundError,
    QuotaExceededError
)

try:
    result = await client.vectors.upsert(...)
except AuthenticationError as e:
    print(f"Authentication failed: {e}")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except ValidationError as e:
    print(f"Validation error: {e.errors}")
except ResourceNotFoundError as e:
    print(f"Not found: {e.resource_type} {e.resource_id}")
except QuotaExceededError as e:
    print(f"Quota exceeded: {e.quota_type} {e.current}/{e.limit}")
except ZeroDBError as e:
    print(f"API error: {e}")

上下文管理器使用情况

async with ZeroDBClient(api_key="your_key") as client:
    project = await client.projects.create(name="Test Project")
    # Client automatically closes when exiting context

配置

环境变量

创建一个 .env 文件:

ZERODB_API_KEY=your_api_key_here
# OR
ZERODB_JWT_TOKEN=your_jwt_token_here

自定义基本URL

client = ZeroDBClient(
    api_key="your_key",
    base_url="https://custom-api.example.com"
)

超时配置

client = ZeroDBClient(
    api_key="your_key",
    timeout=60.0,  # seconds
    max_retries=5,
    retry_delay=2.0
)

高级用法

并行操作

import asyncio

# Execute multiple operations in parallel
results = await asyncio.gather(
    client.vectors.search(project_id, query1),
    client.vectors.search(project_id, query2),
    client.vectors.search(project_id, query3)
)

批处理

# Process large datasets in chunks
from zerodb_mcp.utils import chunk_list

documents = [...]  # Large list
embedding_function = ...  # Your embedding function

for chunk in chunk_list(documents, chunk_size=100):
    vectors = [
        {
            "embedding": embedding_function(doc),
            "document": doc,
            "metadata": {}
        }
        for doc in chunk
    ]

    await client.vectors.batch_upsert(project_id, vectors)

测试

# Run tests
pytest

# Run tests with coverage
pytest --cov=zerodb_mcp --cov-report=html

# Run specific test file
pytest tests/test_vectors.py

发展

# Install dev dependencies
pip install -e ".[dev]"

# Format code
black zerodb_mcp/
isort zerodb_mcp/

# Type checking
mypy zerodb_mcp/

# Linting
flake8 zerodb_mcp/

贡献

  1. 分叉存储库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

MIT许可证-请参阅 许可证 文件以获取详细信息。

ZeroDB集成:免费嵌入+完整RAG

🎉 新增:与LangChain兼容的ZeroDB嵌入

保存 每月100美元以上 免费嵌入HuggingFace,同时获得与OpenAI/Cohere相同的质量!

from zerodb_mcp import ZeroDBClient, ZeroDBEmbeddings

# Initialize FREE embeddings
embeddings = ZeroDBEmbeddings(
    api_key="your-api-key",
    model="BAAI/bge-small-en-v1.5"  # 384 dims, very fast
)

# Embed documents (FREE!)
docs = ["Machine learning tutorial", "Python guide", "Database optimization"]
doc_embeddings = embeddings.embed_documents(docs)

print(f"Generated {len(doc_embeddings)} embeddings")
print(f"Cost: $0.00 (FREE!)")

# Embed query
query = "How to optimize databases?"
query_emb = embeddings.embed_query(query)

# Search vectors
results = await client.vectors.search(
    project_id=project_id,
    query_vector=query_emb,
    limit=5
)

成本比较

提供者嵌入成本矢量存储每月总计
ZeroDB0.00美元(免费)$0-29$0-29
OpenAI+松果100美元70美元170美元
Cohere+Qdrant100美元50美元150美元

每月储蓄:120-150美元 使用ZeroDB!

可用模型

# Fast & Small (384 dimensions, DEFAULT)
embeddings = ZeroDBEmbeddings(model="BAAI/bge-small-en-v1.5")

# Fast & Balanced (384 dimensions)
embeddings = ZeroDBEmbeddings(model="sentence-transformers/all-MiniLM-L6-v2")

# Higher Quality (768 dimensions)
embeddings = ZeroDBEmbeddings(model="sentence-transformers/all-mpnet-base-v2")

完整的RAG示例(5分钟)

import asyncio
from zerodb_mcp import ZeroDBClient, ZeroDBEmbeddings

async def rag_example():
    # Initialize
    client = ZeroDBClient(api_key="your-key")
    embeddings = ZeroDBEmbeddings(api_key="your-key")

    # Create project
    project = await client.projects.create(
        project_name="rag_demo",
        tier="free"  # FREE tier for <100K vectors
    )
    project_id = project["project_id"]

    # Knowledge base
    knowledge = [
        "Python is a versatile programming language used for web, AI, and data science",
        "Machine learning is a subset of AI that learns from data",
        "Neural networks are inspired by biological neurons"
    ]

    # Generate embeddings (FREE!)
    knowledge_embeddings = embeddings.embed_documents(knowledge)

    # Store vectors
    vectors = [
        {
            "embedding": emb,
            "document": doc,
            "metadata": {"index": i}
        }
        for i, (emb, doc) in enumerate(zip(knowledge_embeddings, knowledge))
    ]

    await client.vectors.batch_upsert(
        project_id=project_id,
        vectors=vectors,
        namespace="knowledge"
    )

    # Query
    query = "What programming languages are good for AI?"
    query_emb = embeddings.embed_query(query)

    results = await client.vectors.search(
        project_id=project_id,
        query_vector=query_emb,
        namespace="knowledge",
        limit=3
    )

    print("\nSearch Results:")
    for r in results["results"]:
        print(f"- {r['document']}")
        print(f"  Score: {r['similarity_score']:.2f}\n")

asyncio.run(rag_example())

输出:

Search Results:
- Python is a versatile programming language used for web, AI, and data science
  Score: 0.87

- Machine learning is a subset of AI that learns from data
  Score: 0.72

- Neural networks are inspired by biological neurons
  Score: 0.65

📚 示例工作流程

常见用例的现成示例:

  1. RAG工作流程 -使用免费嵌入构建生产RAG
  2. 代理内存 -持续对话历史
  3. 文件处理 -上传PDF、提取文本、搜索
  4. NoSQL模式 -灵活的元数据存储
  5. 高级工作流 -多组件系统

🚀 快速入门指南

⚡ 演出

  • 嵌入生成:约100条短信/秒(免费!)
  • 向量搜索:对于100K矢量(使用HNSW),\<50ms
  • NoSQL查询:\<20ms(带索引)
  • 文件上传:约500 KB/秒

看 性能基准 查看详细指标。

🔗 集成测试

完整的集成测试可在 tests/integration/test_zerodb_integration.py:

  • ✅ RAG工作流程(单次+批量)
  • ✅ 代理内存工作流
  • ✅ 文件处理管道
  • ✅ 多组件工作流
  • ✅ 错误处理和边缘情况

运行测试:

cd tests/integration
ZERODB_API_KEY="your-key" pytest test_zerodb_integration.py -v

支持

  • 文档:https://docs.ainative.studio/sdk/python
  • 问题:https://github.com/ainative/zerodb-mcp-python/issues
  • 电子邮件:support@ainative.studio
  • 不一致:https://discord.gg/ainative

更新日志

1.0.0 (2025-01-14)

  • 首次生产发布
  • 60+MCP操作
  • 完全异步支持
  • 全面的错误处理
  • Pydantic的类型安全
  • 90%+测试覆盖率

工具与能力

工具数量

0

资源数量

0

提示词数量

0

能力标签

向量数据库Python本地部署NoSQL异步处理文件存储机器学习

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

用自然语言查库

不用手写 SQL,直接问数据,让模型组织查询语句。

数据巡检

定期拉指标、做对比,把异常项整理成一段说明。

打通业务数据

把数据库、数仓和接口接进同一个上下文,减少导出再上传。

选择建议

值得选的地方

  • 只提供 0 个工具,职责集中,接入后不容易误操作。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 公开说明写得比较完整,接入前能看清能力边界。

先想清楚的地方

  • stdio 方式要求本地装好 运行环境,换机器要重新装一遍。
  • 需要自备会话凭据,没有凭据没法直接试。
  • 第三方目录整理,版本更新和行为细节以官方仓库为准。

更适合

  • 需要在数据服务场景里让模型直接调用外部能力的人。
  • 想先快速试一下、能接受在本地跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 暂时拿不到会话凭据的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
Zerodb Python SDK

MCP World · 本页

0stdio有1 个2026-05-17
Memory 9d25f64e

MCP World

9未说明未标注1 个2026-05-17
Prisma MCP Server

MCP World

0stdio有3 个2026-05-17
Astr Bot

MCP World

0stdio有1 个2026-05-17
Getzep MCP

MCP World

9stdio有1 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

Zerodb Python SDK 怎么安装?

公开资料给出的安装命令是 pip install zerodb-mcp,运行环境为 未标注。装完后按客户端要求写进 MCP 配置,重启客户端生效。

Zerodb Python SDK 怎么在 Claude Desktop、Cursor 里配置?

它是stdio 本地进程,客户端配置里要写启动命令和参数,运行环境是 未标注;保存后完全退出客户端再打开,配置才会生效。

Zerodb Python SDK 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Zerodb Python SDK 需要 API Key 吗?

公开资料标注的认证方式是会话凭据,也就是要先拿到凭据才能连上;凭据只填在自己本地的配置里,不要写进公开仓库。

Zerodb Python SDK 支持哪些客户端?

公开资料没有标注具体客户端;能配置本地 MCP 命令的客户端都能接,配置方式参照官方文档。

来源信息

继续浏览同类 MCP