Agent Data Bridge logo

Agent Data Bridge

Community
AriaScarlet132

本项目的 MCP Server 默认监听 0.0.0.0:9000(可通过 MCPHOST/MCPPORT 修改),并使用 SSE 传输:

PublisherAriaScarlet132
Repositorysandbox_mcp
LanguagePython
Forks
1
Stars
0
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    Agent Data Bridge exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    0 stars and 1 forks from the linked repository.

Agent Data Bridge

一个面向 Agent 的“数据桥接 + 轻量沙盒执行”服务,提供两种对外形态:

  • FastAPI HTTP API:用于手工/系统直接调用。
  • MCP Server(SSE Transport):把能力以 Tool 的形式暴露给支持 MCP 的客户端。

目前实际实现包含:

  • 通过两步 OAuth2(token -> query)调用 Spring Boot 接口获取数据(见 src/app/services/springboot_client.py)。
  • 将返回结果中的首个 Markdown 表格解析为 DataFrame;小数据直接返回表格,大数据保存为 parquet 到沙盒目录并返回摘要(见 src/app/main.py)。
  • 提供一个简易 Python “沙盒执行”入口:在指定的沙盒目录中运行脚本,支持超时与输出长度截断(见 src/app/services/sandbox.py)。

运行要求

快速开始

  1. 安装依赖
  • uv sync
  1. 启动 HTTP API(FastAPI)
  • uv run -- uvicorn app.main:app --reload --app-dir src

默认监听 http://127.0.0.1:8000。

如果希望“一条命令同时启动 REST + MCP”,可使用:

  • uv run -- python -m app.run_all

1.(可选)启动 MCP Server(SSE)

本项目的 MCP Server 默认监听 0.0.0.0:9000(可通过 MCP_HOST/MCP_PORT 修改),并使用 SSE 传输:

  • SSE 端点:GET /sse
  • 消息端点:POST /messages/

启动命令:

  • Windows(PowerShell,推荐):
powershell
$env:PYTHONPATH = "src"
uv run -- python -m app.mcp_server
  • 或者切换到 src 目录运行(一次性):
powershell
pushd src
uv run -- python -m app.mcp_server
popd
  • macOS/Linux:
bash
PYTHONPATH=src uv run -- python -m app.mcp_server

配置(.env)

复制 .env.example 为 .env 后按需修改。

当前代码实际会用到的配置(与 .env.example 保持一致):

  • REST_HOST / REST_PORT:REST(FastAPI) 监听地址(用于 Docker 启动与一键启动脚本)。
  • MCP_HOST / MCP_PORT:MCP(SSE) 监听地址。
  • APP_ID / APP_SECRET:Spring Boot OAuth2 client credentials(默认 agent/agent)。

说明:

  • SPRING_BOOT_BASE_URL / SPRING_BOOT_API_PATH 目前在代码中未被使用;/api/fetch 与 MCP 的 fetch_data 都会直接使用传入的 host 参数作为目标地址(见 src/app/services/springboot_client.py)。

HTTP API

健康检查

  • GET /health

返回:{"status":"ok"}

拉取数据并返回摘要

  • POST /api/fetch

请求体:

json
{
  "host": "http://192.168.10.21:3000",
  "userid": "Admin",
  "sql": "select ...",
  "dataset": "demo"
}

行为(与实现一致,见 src/app/main.py):

  • 解析返回结果中的 data.markdown(Markdown 表格)。
  • Rows <= 15:直接返回完整 Markdown 表格。
  • Rows > 15:保存为 parquet 到 SANDBOX_DIR,并返回字段预览 + 前 5 行。

响应:

json
{ "message": "..." }

示例(curl):

bash
curl -X POST http://127.0.0.1:8000/api/fetch \
  -H "Content-Type: application/json" \
  -d '{"host":"http://192.168.10.21:3000","userid":"Admin","sql":"select 1","dataset":"demo"}'

运行沙盒脚本

  • POST /api/sandbox/run

方式 A:JSON

json
{ "filename": "anything.py", "code": "print(123)" }

方式 B:multipart/form-data

  • 上传字段名 file(.py 文件)
  • 或者传 code / filename

返回(与实现一致,见 src/app/services/sandbox.py):

json
{
  "filename": "script_xxx.py",
  "exit_code": 0,
  "stdout": "...",
  "stderr": "..."
}

MCP Tools

MCP Server 目前提供以下 tools(见 src/app/mcp_server.py):

  • fetch_data(host, userid, sql, dataset) -> str
  • sandbox_run(code, filename=None) -> dict
  • sandbox_list_files() -> str

常见用法:先 fetch_data 生成 parquet 文件名,再用 sandbox_run 执行 Python 读取:

python
import pandas as pd
df = pd.read_parquet("<file_name>")
print(df.head())

目录说明

  • sandbox_storage/:默认沙盒数据目录(可通过 SANDBOX_DIR 覆盖)。
  • sandbox_storage/_scripts/:沙盒执行时写入的临时脚本目录(自动创建)。

安全与限制

  • 沙盒执行不是强隔离:只是把工作目录固定到 SANDBOX_DIR,并加了超时与输出截断;请勿在不可信输入场景直接暴露到公网。
  • Spring Boot 的 client_id/client_secret 已改为从 .env 读取(APP_ID/APP_SECRET,默认 agent/agent)。

Docker

同时启动 REST + MCP(推荐使用 compose,并把沙盒目录挂载到宿主机):

bash
docker compose up --build

端口:

  • REST: http://127.0.0.1:${REST_PORT:-8000}
  • MCP(SSE): http://127.0.0.1:${MCP_PORT:-9000}/sse

数据卷:

  • ./sandbox_storage -> /app/sandbox_storage

常见问题

Windows 下 ModuleNotFoundError: No module named 'app'

使用 PowerShell 运行 MCP Server 时,请先设置:

powershell
$env:PYTHONPATH = "src"
uv run -- python -m app.mcp_server

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "agent-data-bridge": {
      "command": "uvx",
      "args": [
        "agent-data-bridge-mcp"
      ],
      "env": {
        "MCP_HOST": "0.0.0.0",
        "MCP_PORT": "9000",
        "SANDBOX_DIR": "sandbox_storage",
        "APP_ID": "agent",
        "APP_SECRET": "agent"
      }
    }
  }
}

Use Agent Data Bridge MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Agent Data Bridge is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Agent Data Bridge as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Agent Data Bridge MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "agent-data-bridge": {
      "command": "npx",
      "args": [
        "-y",
        "agent-data-bridge-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Agent Data Bridge MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Agent Data Bridge MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Agent Data Bridge to help me with this task?
Agent Data Bridge
Sure. I read it.
Here is what I found using Agent Data Bridge.

Frequently asked questions

What is the Agent Data Bridge MCP server used for?

Agent Data Bridge is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Agent Data Bridge MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Agent Data Bridge with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Agent Data Bridge MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Agent Data Bridge connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Agent Data Bridge MCP to TypingMind?

Agent Data Bridge runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Agent Data Bridge MCP provide in TypingMind?

Agent Data Bridge exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Agent Data Bridge MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Agent Data Bridge requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇