Skip to content

Add mcp server#308

Merged
morishin merged 7 commits intobdash-app:masterfrom
asonas:add-mcp-server
Feb 20, 2026
Merged

Add mcp server#308
morishin merged 7 commits intobdash-app:masterfrom
asonas:add-mcp-server

Conversation

@asonas
Copy link
Copy Markdown
Contributor

@asonas asonas commented Feb 18, 2026

Motivation

When writing SQL queries for data analysis, we often need to look up schema information and column details manually, then pass that context to AI assistants like Claude. By integrating MCP, Bdash can directly provide schema, table, and query information to AI tools — enabling faster, more efficient analysis workflows.

This change focuses on MCP-based interaction only (reading schema, writing queries). Query execution remains a human action and is intentionally out of scope.

Summary

  • Add MCP (Model Context Protocol) server that enables AI coding tools like Claude Code to interact with Bdash's data sources, queries, and schema
  • Add polling mechanism to Query page so changes made via MCP server are reflected in the UI in near real-time
  • Add MCP Server configuration section to Settings page with a copyable JSON snippet for easy setup

Details

MCP Server (src/mcp/)

A standalone Node.js MCP server that reads Bdash's SQLite database and connects to configured data sources. Provides the following tools:

Tool Description
list_datasources List all configured data sources
list_queries List all saved queries
get_query Get query details by ID
write_query Write SQL to a query's editor
create_query Create a new query
list_tables List tables for a data source
get_table_schema Get column definitions for a table

Bundled into the packaged app via electron-builder's extraResources.

Query polling

Since MCP server writes directly to the SQLite database, the renderer process needs to detect those changes. Added 1-second polling that checks getCount and getUpdatedAt to refresh the query list and editor content when external changes are detected.

Settings page

Added an MCP Server section at the bottom of Settings that displays a JSON configuration snippet with the correct server path. Users can copy it to their MCP client config with one click.

You can test this locally

gh pr checkout <this PR number>

# Install MCP server dependencies and build
yarn mcp:install
yarn mcp:build

# Build and start the app
yarn build
yarn start

Then add the MCP server configuration to your Claude Code settings (.claude.json). You can get the JSON snippet from Settings > MCP Server section in the app and copy it with one click.

CleanShot 2026-02-18 at 18 36 22

Note: In the development environment, the MCP server path will point to the Electron binary inside node_modules (e.g. .../node_modules/electron/dist/Electron.app/Contents/Resources/mcp/server.js). In a production build, it will point to the installed application path (e.g. /Applications/Bdash.app/Contents/Resources/mcp/server.js).

Once configured, try asking Claude Code to list your data sources or write a query — changes should appear in the Bdash UI within a few seconds.

@morishin
Copy link
Copy Markdown
Collaborator

便利な機能追加ありがとうございます!

ポーリングですが、mcp サーバーを使っているかどうかに関わらず Bdash.app を起動している間はずっと SQLite DB に差分があるか毎秒チェックし続けていますよね。
気にするほどの負荷ではないはずですがちょっと嫌なので、ポーリングをやめて単にアプリウィンドウがアクティブになった時にリフレッシュするぐらいではダメでしょうか?

Comment thread src/mcp/src/tools/get-query.ts
@asonas
Copy link
Copy Markdown
Contributor Author

asonas commented Feb 19, 2026

気にするほどの負荷ではないはずですがちょっと嫌なので、ポーリングをやめて単にアプリウィンドウがアクティブになった時にリフレッシュするぐらいではダメでしょうか?

フォーカスがあたったら更新する、というほううが良さそうなのでそのようにしたいと思います!

Copy link
Copy Markdown
Collaborator

@morishin morishin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

動作確認できました!ちょっと僕の方で修正したものがあるのですが、それはこれのマージ後に PR にします。

@morishin morishin merged commit d932b39 into bdash-app:master Feb 20, 2026
2 checks passed
@morishin morishin mentioned this pull request Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants