askDB
askDB MCP
自然言語のデータ質問を、LLMがSQLを書くために必要なスキーマコンテキストに変換するMCPサーバーです。データベースには接続せず、SQL自体も生成しません。Pineconeインデックスから適切なテーブル定義を取得し、質問しているモデル(Claude Code、Claude Desktop、ChatGPT、Cursor)に渡します。
user question
│
▼
Claude Code / ChatGPT ──calls──► askDB MCP ──semantic search──► Pinecone (ask-db)
│ │
│ relevant DDL + guardrails ◄─┘
▼
generated SQLツール
ツール | モデルが使用するタイミング | 入力 |
| テキストからSQLへのリクエストの最初の呼び出し |
|
| 既知のテーブルのすべての列が必要な場合 |
|
| 全体像の把握、または検索結果が空の場合 |
|
すべてのレスポンスには、返されたテーブルと列のみを使用するようにモデルに指示する命令が埋め込まれているため、名前を捏造することはありません。
Related MCP server: Vanna AI MCP Server
セットアップ
npm install
npm run setup # creates .env from the template
# → then put your PINECONE_API_KEY in .env
npm run doctor # verify connection, field mapping and retrieval quality他の人と共有しますか? SETUP.md を送ってください。ローカルでの実行とホスト型インスタンスへの接続の両方をカバーしています。
npm run doctor が重要なステップです。インデックス設定、レコードが実際に使用しているメタデータフィールド、サンプル検索を出力するため、クライアントに接続する前にサーバーが正しいフィールドを読み取っていることを確認できます。
npm run doctor # connectivity + retrieval sanity check
npm run smoke # drive the stdio server with a real MCP client
npm run smoke:http # same over Streamable HTTP, with bearer authクライアントを接続する
Claude Code
CLI、デスクトップアプリ、IDE拡張機能はすべて同じ設定を共有するため、これにより3つすべてに対してサーバーが登録されます。
# from the repo root — records an absolute path, so it works in any folder
claude mcp add askdb --scope user -- node "$PWD\src\server.js"claude mcp list(askdb: ... ✓ Connected)で確認してから、デスクトップアプリまたはIDEウィンドウを再起動してください。MCPサーバーは起動時に読み込まれます。
ユーザースコープは意図的です。目的は、他のリポジトリで作業しながらデータベースの質問をすることです。プロジェクトスコープの.mcp.jsonは、Claude Codeがこのリポジトリのルートで起動された場合にのみ解決され、両方のスコープでaskdbを定義すると、Claude Codeが重複について警告します。
Claude Desktop / Cursor
claude_desktop_config.json(またはCursorのMCP設定)に追加します:
{
"mcpServers": {
"askdb": {
"command": "node",
"args": ["D:\\working-directory\\AI\\askDB-mcp\\src\\server.js"]
}
}
}認証情報はサーバーの隣にある.envから取得されるため、クライアント設定にキーは含まれません。
ChatGPT
ChatGPTコネクタはローカルプロセスを起動できません。HTTP上のリモートMCPのみを話します。HTTPトランスポートを実行して公開してください:
# set MCP_AUTH_TOKEN first: this endpoint serves your whole schema
MCP_AUTH_TOKEN=some-long-random-string npm run start:http次に、Authorization: Bearer <token>ヘッダーを付けてコネクタをhttps://<your-host>/mcpに向けます。簡単な試用にはトンネル(cloudflared tunnel --url http://localhost:3000)を使い、長期的なものには適切にホストしてください。DEPLOY.mdはNetlifyをエンドツーエンドでカバーしています。GET /healthはロードバランサーのチェック用に認証不要です。MCP_AUTH_TOKENが設定されている場合、/mcpはベアラートークンを必要とします。
HTTPトランスポートはステートレスです。リクエストごとに1つのサーバーインスタンスが存在するため、スティッキーセッションなしでロードバランサーの背後でスケールします。
ホスティング
2つのNetlify Functionsとしてデプロイされます。netlify.tomlにビルド設定が含まれているため、リポジトリをインポートしてPINECONE_API_KEYとMCP_AUTH_TOKENを設定するだけです。ステップバイステップ: DEPLOY.md
これはトランスポートの書き換えなしで機能します。MCP SDKのWebStandardStreamableHTTPServerTransportはRequestを受け取ってResponseを返すため、Netlify Functions v2のシグネチャと一致し、netlify/functions/mcp.mjsはsrc/mcp.jsを変更せずにインポートします。同じファイルはCloudflare Workers、Deno、Bunでも動作します。src/http.jsはコンテナとVMをカバーします。
GET /healthはトークンを必要とせず、必要な環境変数が設定されているかどうかを報告します(値ではなく存在のみ)。これは起動ログを読むためのサーバーレス代替です。/mcpはフェイルクローズです。MCP_AUTH_TOKENが設定されていない場合、スキーマをインターネットに公開するのではなく503を返します。
起動すれば、チームメイトは何もインストールする必要はありません。URLとトークンだけです(SETUP.md、ルートA)。
設定
APIキー以外はすべてオプションです。.env.exampleを参照してください。
変数 | デフォルト | 備考 |
| — | 必須 |
|
| |
| (既定の名前空間) | |
|
| 検索あたりのスキーマチャンク数 |
|
| アップサートに使用したモデルと一致している必要があります |
| (オフ) | 例: |
| (すべて) | すべてのルックアップを1つのデータベースに限定する |
|
| モデルにヒントとして渡されます |
|
| 候補となるメタデータキー。順番に試行されます |
|
|
|
サーバーはレコードが使用するメタデータフィールドと、インデックスが統合埋め込みを持つかどうかを自動検出するため、通常はデフォルトのままで動作します。
知っておくべき2つのこと
埋め込みモデルは一致している必要があります。 EMBED_MODELがスキーマのアップサートに使用したモデルではない場合、すべてのスコアがほぼゼロに落ち込み、結果はノイズになります。ベクトルは互いに対して事実上ランダムです。npm run doctorでは、無関係なテーブルが0.8ではなく0.01前後のスコアで返ってくることで確認できます。このインデックスはmultilingual-e5-largeで構築されました。
インデックスに複数の環境が含まれる場合はDEFAULT_DATABASEを設定してください。 同じスキーマが*_liveと*_testとして存在する場合、スコープ未指定の検索ではすべてのテーブルの2つのコピーが返され、top_kスロットの半分を重複で消費し、モデルが1つのクエリで環境を混在させる可能性があります。
構成
ファイル | 役割 |
ツール定義 — MCPサーフェス | |
取得: 検索、正確なフェッチ、フィールド検出、リランク | |
ヒットをモデルが読むスキーマブロックにレンダリング | |
stdioエントリポイント | |
ストリーミング可能HTTPエントリポイント | |
環境変数の読み込みとデフォルト | |
接続性と取得の診断 | |
サーバーレスエントリポイント — | |
Netlifyのビルドとルーティング設定 | |
ホスティングガイド |
Available Tools
3 toolsget_table_schemaGet schema for specific tablesARead-only
Fetch the full stored DDL for one or more tables by exact name. Use after search_schema when you need every column of a table, or when the user named the table.
| Name | Required | Description | Default |
|---|---|---|---|
| tables | Yes | Exact table names, e.g. ["tbl_account", "tbl_order"]. | |
| database | No | Restrict to one database/schema — omit to search all of them. | |
| namespace | No | Pinecone namespace override. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare the tool as read-only and open-world, so the behavioral burden is lower. The description clarifies that DDL is returned for exact table names, but does not add details like pagination limits, error handling for missing tables, or performance traits beyond what annotations signal.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise—two short sentences that immediately convey purpose and usage context. There is no wasted wording, and every sentence adds value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity, strong annotations, and complete schema, the description is largely complete. It could optionally mention that the output is raw DDL (though implicit), but lack of output schema does not diminish clarity given the straightforward fetch operation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already thoroughly documents all three parameters. The description adds no extra semantics beyond what the schema provides, so a baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool fetches 'full stored DDL for one or more tables by exact name', using specific verbs and resources. It also distinguishes itself from sibling tool 'search_schema' by indicating when to use this tool after that one.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit guidance on when to use this tool ('after search_schema when you need every column') and references the user naming a table. However, it does not explicitly state when not to use it or mention any alternatives like 'list_tables'.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_tablesList available tablesARead-only
Inventory of every table in the schema index, grouped by database, plus the index configuration. Use it to orient yourself, or when search_schema comes back empty.
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | Restrict to one database/schema — omit to search all of them. | |
| namespace | No | Pinecone namespace override. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint=true and openWorldHint=true, covering safety and scope. The description adds beyond annotations by stating that results are grouped by database and include index configuration. No behavioral traits (like performance impact or pagination) are discussed, but for a read-only inventory tool this is adequate.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences with zero wasted words. The first sentence defines the core functionality, and the second provides usage guidance. It is front-loaded and every part earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple list tool with no output schema, the description gives a sufficient mental model: inventory, grouping by database, and inclusion of index configuration. Could be slightly more explicit about the return structure (e.g., whether it's flat or nested), but fine given the tool's simplicity and the presence of sibling context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with clear descriptions for both optional parameters (database filter and namespace override). The description does not elaborate further on parameter semantics beyond what the schema provides, so it meets the baseline expected when schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool provides an 'Inventory of every table in the schema index, grouped by database, plus the index configuration.' It uses specific verbs and nouns, and distinguishes itself from sibling tools like search_schema by indicating when to use it (when search_schema returns empty).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly says 'Use it to orient yourself, or when search_schema comes back empty,' providing clear usage context. It does not mention when to avoid this tool or use get_table_schema, but the positive guidance is strong and helps an agent decide between siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_schemaSearch database schemaARead-only
Semantic search over the database schema stored in Pinecone. Call this FIRST for any text-to-SQL request: pass the user question verbatim and you get back the relevant tables, columns, types and relationships to write the query against.
| Name | Required | Description | Default |
|---|---|---|---|
| top_k | No | How many schema chunks to retrieve (default 8). | |
| tables | No | Restrict the search to these table names, when you already know them. | |
| database | No | Restrict to one database/schema — omit to search all of them. | |
| question | Yes | The natural-language data question, e.g. "top 10 accounts by transaction volume last month". | |
| namespace | No | Pinecone namespace override. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already provide readOnlyHint=true and openWorldHint=true, so the description's disclosure burden is lower. The description adds context about the Pinecone vector store and the first-step pipeline role, which is valuable beyond annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, no wasted words. The first sentence defines the tool, the second provides usage instruction. Front-loaded and efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
No output schema, but the description indicates what is returned (relevant tables, columns, types, relationships). For a semantic search tool, this is sufficient. The tool is moderately complex (5 params, no nested objects) and the description covers its role adequately.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so all 5 parameters are documented in the schema. The description reinforces the 'question' parameter by saying 'pass the user question verbatim' but does not add new semantics beyond what the schema provides for other parameters. Baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it performs semantic search over the database schema stored in Pinecone, explicitly for text-to-SQL requests. It distinguishes from siblings by positioning itself as the first step and mentioning retrieval of tables, columns, types, and relationships.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly says 'Call this FIRST for any text-to-SQL request', providing clear context for when to use. It doesn't explicitly exclude alternatives like get_table_schema or list_tables, but the 'first step' instruction implies the workflow.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v1.0.0- First observed
get_table_schema - First observed
list_tables - First observed
search_schema
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: search_schema for semantic discovery, get_table_schema for exact DDL retrieval, and list_tables for inventory. There is no overlap or ambiguity between them.
All tool names follow a consistent verb_noun pattern in snake_case (search_schema, get_table_schema, list_tables), making them predictable and easy to understand.
Three tools is minimal but appropriate for the focused domain of database schema exploration. Each tool earns its place and covers the essential operations without being overly sparse.
The tool set fully covers schema discovery: semantic search, exact schema lookup, and table listing. For the stated purpose of enabling text-to-SQL by providing schema info, there are no obvious gaps.
Maintenance
Related MCP Connectors
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Draxlr's remote MCP server connects AI assistants to your SQL databases and dashboards. Explore schemas, run read-only queries, manage saved queries and dashboards, and export results, all with row-level security so each user sees only their own data.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP-Server from your Database optimized for LLMs and AI-Agents. Supports PostgreSQL, MySQL, ClickHouse, Snowflake, MSSQL, BigQuery, Oracle Database, SQLite, ElasticSearch, DuckDB547Apache 2.0
- FlicenseNot gradedqualityDmaintenanceAn MCP server that allows AI assistants to query databases using natural language by leveraging Vanna AI. It supports secure SSH tunneling, model training on database schemas, and persistent storage of SQL patterns via ChromaDB.2-
- FlicenseAqualityDmaintenanceAn MCP server that connects LLMs to SQL databases for development assistance, enabling query execution, schema exploration, and data manipulation while providing safety controls against destructive operations.5-
- FlicenseNot gradedqualityAmaintenanceAn MCP server that exposes relational databases (PostgreSQL/MySQL) to AI agents with natural language to SQL query support.19-