Token导航 LogoToken导航TokenDH.com
fusion (Yasinyaman) logo
数据服务stdio官方级别未说明来源级核验

fusion (Yasinyaman)

MCP Server

Fusion是一款基于DuckDB的内存分析引擎,支持通过LLM工具进行数据分析,适用于多数据库联合查询和实时分析场景。

工具数

10

提示词数

0

GitHub Stars

2

资源数

0
数据分析Python实时分析

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

yasinyaman

提供方

yasinyaman

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -e .

详细介绍

融合

DuckDB支持LLM工具的内存分析引擎。

Fusion通过以下方式连接到PostgreSQL/MySQL数据库 扭曲 REST API,将数据加载到DuckDB中进行快速柱状分析,并通过MCP和OpenAI函数调用为LLM公开10个工具。

特性

  • 10个LLM工具list_sources, describe_table, query_data, search_data, aggregate_data, create_view, list_views, refresh_view, load_table, cache_stats
  • 双格式 --MCP(模型上下文协议)和OpenAI函数调用格式中的工具定义
  • 3访问层 -MCP服务器(stdio)、REST API(FastAPI/HTTP)、Python SDK
  • 查询下推 --尽可能将查询直接路由到源数据库,避免不必要的数据传输
  • 懒加载 --仅在查询中实际引用时从源获取表数据
  • SQL护栏 --阻止破坏性SQL(DROP、DELETE、INSERT)以保护数据完整性
  • LRU缓存 --查询结果缓存,具有可配置的TTL,响应时间为毫秒
  • 物化视图 --具有计划自动刷新功能的预先计算的聚合表
  • 跨来源联盟 --在单个查询中跨多个数据库(PostgreSQL+MySQL)进行JOIN
  • 自动发现 --自动从Warp中发现所有数据库和表

建筑

┌─────────────────────────────────────────────────────────────────────────────┐
│  1. Data Source Layer                                                       │
│  ┌──────────────┐    REST     ┌─────────────────┐                          │
│  │ PostgreSQL   │ ──────────► │                 │                          │
│  │ MySQL        │             │ WarpConnector    │  auto-discovery           │
│  └──────────────┘             │ (query pushdown) │  pagination, schema       │
│       Warp REST API           └────────┬────────┘                          │
└────────────────────────────────────────┼──────────────────────────────────┘
                                          │
┌─────────────────────────────────────────▼──────────────────────────────────┐
│  2. DuckDB Core Layer                                                       │
│  ┌──────────────────────────────────────────────────────────────────────┐  │
│  │ OLAPEngine                                                            │  │
│  │  • DuckDB (in-memory, columnar)   • QueryCache (LRU + TTL)            │  │
│  │  • SchemaCatalog (multi-source)   • MaterializedViewManager           │  │
│  │  • FetchStrategy (lazy load)      • SQLGuardrails (SELECT only)       │  │
│  └──────────────────────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────┬──────────────────────────────────┘
                                          │
┌─────────────────────────────────────────▼──────────────────────────────────┐
│  3. LLM Tool Layer                                                          │
│  ┌─────────────┐  ┌──────────────────┐  ┌─────────────────┐                 │
│  │ ToolExecutor│  │ 10 tools         │  │ MCP / REST / SDK│                 │
│  │ (dispatch)  │─►│ query_data, etc. │─►│ → LLM → Result  │                 │
│  └─────────────┘  └──────────────────┘  └─────────────────┘                 │
└─────────────────────────────────────────────────────────────────────────────┘

安装

pip install -e .

可选依赖关系:

pip install -e ".[mcp]"     # MCP Server support
pip install -e ".[rest]"    # REST API (FastAPI + uvicorn)
pip install -e ".[dev]"     # Development (pytest, ruff, mypy)
pip install -e ".[all]"     # Everything

快速开始

开发包

from fusion import OLAPEngine

engine = OLAPEngine(memory_limit="4GB")
engine.connect_source("mydb", {
    "type": "warp",
    "base_url": "http://localhost:8000",
    "database": "mydb",
})

executor = engine.get_tool_executor()

# Discover available data
sources = executor.list_sources()

# Run an analytical query (auto-loads referenced tables)
result = executor.query_data("SELECT * FROM mydb.orders LIMIT 10")

# Aggregate data
agg = executor.aggregate_data(
    table="mydb.orders",
    group_by="status",
    agg_column="amount",
    agg_func="SUM",
)

# Create a materialized view
executor.create_view(
    name="daily_revenue",
    sql="SELECT status, SUM(amount) as total FROM mydb.orders GROUP BY status",
    refresh="hourly",
)

MCP服务器(克劳德桌面/光标)

fusion-mcp --warp-url http://localhost:8000 --database mydb

在中配置 claude_desktop_config.json:

{
  "mcpServers": {
    "fusion": {
      "command": "fusion-mcp",
      "args": ["--warp-url", "http://localhost:8000", "--database", "mydb"]
    }
  }
}

自动发现所有数据库:

fusion-mcp --warp-url http://localhost:8000 --auto-discover

REST API

fusion-rest --warp-url http://localhost:8000 --auto-discover --port 9000

Swagger用户界面位于 http://localhost:9000/docs.关键端点:

端点方法描述
/sourcesGET列出连接的源和表
/tables/{source.table}/schemaGET表架构详细信息
/queryPOST执行SQL分析查询
/searchPOST对表进行筛选搜索
/aggregatePOST按聚合分组
/viewsGET/POST列出或创建物化视图
/views/{name}/refreshPOST刷新物化视图
/tables/{source.table}/loadPOST显式加载表
/cache/statsGET缓存统计信息
/tools/{tool_name}POST通用工具调度

OpenAI函数调用

from fusion import get_openai_tools, OLAPEngine

engine = OLAPEngine()
engine.connect_source("mydb", {"type": "warp", "base_url": "http://localhost:8000"})
executor = engine.get_tool_executor()

# Get tool definitions for OpenAI Chat Completions API
tools = get_openai_tools()

# When the LLM makes a tool call:
result = executor.execute("query_data", {"sql": "SELECT ..."})

工具

工具说明
list_sources具有行数的连接源和表
describe_table表架构(列、类型、行数)
query_data在DuckDB上运行分析SQL(仅限SELECT,最多100行)
search_data对表进行筛选搜索(与%完全匹配或LIKE)
aggregate_data按聚合分组(总和、平均值、计数、最小值、最大值)
create_view从SELECT查询创建物化视图
list_views列出具有刷新计划的物化视图
refresh_view手动刷新物化视图
load_table将表从源显式加载到DuckDB中
cache_stats查询缓存命中率、条目计数、内存使用情况

扭曲设置

Fusion使用 扭曲 作为其数据源网关:

git clone https://github.com/yasinyaman/warp.git
cd warp
docker compose up -d

Warp提供了一个RESTneneneba API,用于联合对PostgreSQL和MySQL数据库的访问。

项目结构

fusion/
├── __init__.py              # Public API exports
├── engine.py                # OLAPEngine — main orchestration
├── cache.py                 # QueryCache (LRU + TTL)
├── catalog.py               # SchemaCatalog — multi-source metadata
├── guardrails.py            # SQLGuardrails — blocks destructive SQL
├── result.py                # QueryResult — format conversions
├── strategy.py              # FetchStrategy — smart table loading
├── exceptions.py            # Custom exception hierarchy
├── connectors/
│   ├── base.py              # BaseConnector (abstract)
│   └── warp.py              # WarpConnector (Warp REST API)
├── tools/
│   ├── definitions.py       # 10 tool schemas (OpenAI + MCP)
│   ├── executor.py          # ToolExecutor — routes tool calls
│   ├── mcp_server.py        # MCP Server (stdio transport)
│   └── rest_server.py       # REST API Server (FastAPI)
└── views/
    └── materialized.py      # MaterializedViewManager

发展

pip install -e ".[all]"
pytest tests/ -v           # 236 tests
ruff check fusion/         # Lint
python -m demo.demo        # Demo with synthetic data

需求

  • Python 3.10+
  • DuckDB 1.2+
  • 扭曲 (数据源网关)

许可证

Apache 2.0——请参阅 许可证 了解详情。

目录标签

目录标签

数据分析Python实时分析本地部署内存计算LLM工具数据库联邦

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

10

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

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

来源信息

继续浏览同类 MCP