Skip to main content
Glama

db-kb-mcp-server

A static, read-only MCP server that exposes a database knowledge base (schema, relationships, workflows, and reasoning patterns) so Claude Code / Copilot can reason about a database it has no live connection to.

No DB connection required — the schema is assumed stable, and all content lives in kb/ as Markdown files.

Folder structure

kb/
  schema/         one file per table — columns, types, PK/FK, business meaning
  relationships/  FK-enforced and logical (non-enforced) relationships, grouped by subsystem
  workflows/      one file per customizable workflow — intents, tables touched, invariants
  patterns/       reusable reasoning recipes (e.g. reordering ordinal columns)
  glossary/       domain term definitions
server/
  src/            MCP server implementation (Node + TypeScript, @modelcontextprotocol/sdk)

Related MCP server: Oracle DB MCP

Tools exposed

Tool

Purpose

get_context

Call this first, once per session. Returns hard rules, doc inventory, and what to call next.

get_context_for_query

Preferred per-query context bundle: given the user's request, returns relevant tables + required docs (schema/workflow/relationships/patterns/glossary) and execution order in one response.

resolve_tables_for_query

Call this second, with the user's request verbatim. Fans out across workflows/patterns/relationships/schema and returns a ranked, reasoned list of which tables are actually relevant, plus matching docs and concrete next steps — this is what lets an agent go from "user asked X" to "these are the tables to work on" without guessing table names from general domain knowledge.

list_kb_docs

List all docs, optionally filtered by category

get_table_schema

Full schema doc for a table

get_relationships

FK + logical relationships, optionally filtered to a table

get_workflow

Workflow doc: intents, tables touched, invariants

get_reasoning_pattern

Reasoning recipe (e.g. reordering, choosing-column-values)

search_kb

Full-text search across all docs

get_glossary_term

Domain term lookup

Every doc is also exposed as an MCP resource (kb://<category>/<id>).

Running locally (stdio — simplest, per-user)

npm install
npm run build

By default, the server auto-loads kb/ from the repository root (resolved relative to server/dist/index.js, not the shell's current working directory). Override with KB_ROOT only when you want to point to another KB folder.

Then add to Claude Code:

claude mcp add db-kb -- node D:/Tasks/GTech_MCPServer/server/dist/index.js

Or set KB_ROOT to point at a KB folder elsewhere:

KB_ROOT=/path/to/kb node server/dist/index.js

Integration checklist (what users need on their machine)

Local stdio integration

Required on each user machine:

  • Node.js 18+ (recommended current LTS)

  • A local copy of:

    • server/dist/index.js (or full repo + build output)

    • kb/ folder (the knowledge base content)

Typical MCP config (example .mcp.json snippet):

{
  "mcpServers": {
    "db-kb": {
      "command": "node",
      "args": ["D:\\Tasks\\GTech_MCPServer\\server\\dist\\index.js"]
    }
  }
}

Optional when kb/ lives elsewhere:

{
  "mcpServers": {
    "db-kb": {
      "command": "node",
      "args": ["D:\\Tasks\\GTech_MCPServer\\server\\dist\\index.js"],
      "env": {
        "KB_ROOT": "D:\\MyKb"
      }
    }
  }
}

Hosted HTTP integration

Required on user machine:

  • Only the MCP server URL (no local kb/ copy needed)

Client should use:

  • transport: http

  • URL: https://<host>:<port>/mcp (include /mcp)

Running as a hosted server (HTTP — pluggable via URL for everyone)

MCP_TRANSPORT=http PORT=8787 npm start

Deploy this anywhere (small VM, container, internal server). Then each teammate adds the URL once:

claude mcp add --transport http db-kb https://your-host:8787/mcp

No cloning, no file sync — everyone always gets the current KB content.

The HTTP server keeps one McpServer/transport pair per MCP session (keyed by the mcp-session-id the SDK assigns on initialize), not per HTTP request — sessions span many requests, so a naive "new server per request" implementation breaks the handshake (tools/call fails with "Server not initialized" on the very next request). Verified end-to-end with a manual initialize → notifications/initialized → tools/call sequence over curl.

Updating the knowledge base

  1. Edit/add Markdown files under kb/.

  2. If running the hosted HTTP variant, redeploy/restart the server — it loads kb/ once at startup (schema is assumed static; restart to pick up doc changes).

  3. Use kb/schema/_TEMPLATE.md as the starting point for new tables.

Live read-only SQL access (Oracle SQLcl MCP Server)

Alongside the static KB server, this project bundles Oracle's official SQLcl (v26.2, downloaded to tools/sqlcl/) running in MCP mode — for verifying live schema/data against the actual Oracle instance. This is a separate, more sensitive server from db-kb: it needs real DB credentials and should not be shared as broadly as the KB server.

One-time setup (per machine, not committed to the repo)

  1. Save a connection using SQLcl's own encrypted connection store. Run -nolog first, then type the connect command at the interactive prompt (or pipe it via stdin) — passing connect ... as command-line arguments gets misparsed as a script filename. Also pass -thin — on Windows, SQLcl defaults to OCI/thick mode and fails with no ocijdbc23 in java.library.path unless a full Oracle Instant Client is on the path; thin mode needs no native client at all:

    tools/sqlcl/bin/sql -thin -nolog
    SQL> connect -save mydb -savepwd myuser/mypassword@myhost:1521/myservice

    Credentials are stored locally under ~/.dbtools (SQLcl's own encrypted store) — never commit this directory or put credentials in .mcp.json.

  2. Use a read-only DB account for myuser — grant only SELECT on the relevant schemas. This is the real enforcement boundary; SQLcl's own restrict levels are a second layer, not a substitute for DB-level permissions.

  3. Verify the saved connection actually works: connect -name mydb then select 1 from dual;.

Already wired into .mcp.json

"oracle-sqlcl": { "command": "tools/sqlcl/bin/sql", "args": ["-thin", "-mcp"] }

MCP mode defaults to restrict level 4 (most restrictive) unless overridden with -R. It exposes 5 core tools: list-connections, connect, disconnect, run-sql, run-sqlcl. The connect tool only accepts a saved connection name (from step 1 above) — it never accepts raw credentials over MCP, so nothing sensitive passes through the AI session itself.

Auditing

Every session is logged: V$SESSION.MODULE records the MCP client, V$SESSION.ACTION records the calling LLM, and SQLcl creates a DBTOOLS$MCP_LOG table recording every interaction/SQL statement executed — useful for reviewing what was actually run against the live DB.

Division of responsibility with the KB server

  • db-kb (this repo's server/) — static schema/workflow knowledge, safe to share broadly, no DB connection.

  • oracle-sqlcl — live queries against the real instance, needs a read-only DB account, keep access scoped to people authorized to query production/test data.

Adding a new workflow doc

Copy the structure in kb/workflows/approval-chain-workflow.md:

  • List common user intents mapped to concrete table/column changes.

  • List invariants that must hold after any change.

  • Link to relevant schema docs and reasoning patterns with [[slug]] (informal — for human navigation; the tools don't resolve these automatically yet).

Available Tools

10 tools
get_contextGTech Networks DB: get oriented before doing anything elseA

[GTech / Hexagon HxGN NetWorks Core (G/Technology) database only] ALWAYS call this first, but ONLY if the user's request concerns the GTech / Hexagon HxGN NetWorks Core (G/Technology) database — its G3E_* schema, feature/component model, workflows, legends, styles, or placement configurations. If it's not clear whether the request relates to this specific system (as opposed to some other database, application, or MCP server you have access to), ASK THE USER to confirm before calling this or any other tool from this server — do not assume. Once confirmed relevant, this returns the KB's purpose, hard rules (read-only/advisory, never fabricate, always propose not execute), and an inventory of what's documented, so you know what's available before searching for anything specific.

Inputs: no named parameters.

get_context_for_queryGTech Networks DB: get complete context bundle for one user queryA

[GTech / Hexagon HxGN NetWorks Core (G/Technology) database only] Only call this for requests already confirmed to concern the GTech/NetWorks Core database. This is a one-shot context pack for an agent: it resolves relevant tables and returns the required docs (schema/workflow/relationships/patterns/glossary) plus hard rules and execution order so the next reasoning step has all required context.

Inputs: query (required), limit, include_full_docs.

get_glossary_termGTech Networks DB: get glossary termA

[GTech / Hexagon HxGN NetWorks Core (G/Technology) database only] Look up a GTech/NetWorks Core domain term's definition (e.g. Feature, Component, Legend).

Inputs: term (required).

get_reasoning_patternGTech Networks DB: get reasoning/insertion patternA

[GTech / Hexagon HxGN NetWorks Core (G/Technology) database only] Get a documented reasoning recipe for a class of change in the GTech/NetWorks Core schema — e.g. how to insert a new row so it renders correctly, how to reorder/renumber ordinal columns, how to pick which column value to set for a given user intent.

Inputs: topic (required).

get_relationshipsGTech Networks DB: get relationships for a tableA

[GTech / Hexagon HxGN NetWorks Core (G/Technology) database only] Get documented relationships (FK-enforced and logical/non-enforced) involving a GTech/NetWorks Core table.

Inputs: table.

get_table_schemaGTech Networks DB: get table schema docA

[GTech / Hexagon HxGN NetWorks Core (G/Technology) database only] Get the full schema documentation for a specific table in the GTech/NetWorks Core (G3E_*) schema: columns, types, PK/FK, and business-meaning notes (e.g. which column drives display order). Do not use for tables belonging to any other database/system.

Inputs: table (required).

get_workflowGTech Networks DB: get workflow docB

[GTech / Hexagon HxGN NetWorks Core (G/Technology) database only] Get the documentation for a specific GTech/NetWorks Core workflow: purpose, tables/rows touched, insertion patterns, and invariants.

Inputs: name (required).

list_kb_docsGTech Networks DB: list knowledge base documentsA

[GTech / Hexagon HxGN NetWorks Core (G/Technology) database only] List all documents in the GTech/NetWorks Core knowledge base, optionally filtered by category (schema, relationships, workflows, patterns, glossary). Not relevant to any other database or system.

Inputs: category.

resolve_tables_for_queryGTech Networks DB: resolve which tables/docs are relevant to a user queryA

[GTech / Hexagon HxGN NetWorks Core (G/Technology) database only] Only call this for requests already confirmed to concern the GTech/NetWorks Core database (see get_context). Given a natural-language user request (e.g. 'add a new approval step', 'change the order components display in'), returns a ranked list of relevant tables with reasons, plus matching workflow/pattern/relationship docs and concrete next steps. Call this after get_context and before fetching any specific table schema — it tells you WHICH schema docs to fetch instead of guessing.

Inputs: query (required), limit.

search_kbGTech Networks DB: search the knowledge baseA

[GTech / Hexagon HxGN NetWorks Core (G/Technology) database only] Full-text search across all GTech/NetWorks Core knowledge base docs (schema, relationships, workflows, patterns, glossary). Only useful for requests already confirmed to concern this specific database — irrelevant to other systems.

Inputs: query (required), limit.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 10 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose, from overall context retrieval to specific schema, glossary, and workflow lookups. The detailed descriptions eliminate ambiguity.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun snake_case pattern (e.g., get_glossary_term, list_kb_docs), making them predictable and easy to use.

    Tool Count5/5

    10 tools is well-scoped for a knowledge base query server. Each tool serves a specific function without overlapping or being superfluous.

    Completeness5/5

    The tool set covers all necessary aspects of interacting with the KB: context, schema, relationships, workflows, patterns, glossary, and search. No obvious gaps for its read-only purpose.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      A read-only MCP server that exposes dbt project artifacts and data quality result tables (BigQuery/Postgres) to LLM clients, enabling deep introspection, run-history analysis, source freshness, test coverage, and lineage walks.
      27
      76 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Read-only MCP server that lets coding AI agents inspect Oracle Database schema through live metadata.
      ISC
    • A
      license
      A
      quality
      D
      maintenance
      A read-only MCP server that provides AI coding tools with database schema structure (tables, columns, keys, relationships) without exposing row data.
      3
      Apache 2.0
    • A
      license
      B
      quality
      D
      maintenance
      Read-only MCP server for exploring and analyzing SQL Server objects (tables, views, triggers, stored procedures) from Claude Code.
      8
      1,129 npm
      MIT