MCP Guide Schema Query

MCP Guide Schema Query

Enables AI tools to understand a database, inspect schema, and run safe SELECT queries with SQL guardrails, plus optional codebase reading.

Category
Visit Server

README

MCP Guide Schema Query

Reusable read-only MCP server for projects that need AI tools to understand a database, inspect schema, and run safe SELECT queries.

It exposes three MCP tools:

  • database-guide
  • database-schema
  • database-select

Optional codebase tools can be enabled per project:

  • codebase-map
  • codebase-read

The package includes:

  • OAuth flow compatible with Claude Web custom connectors.
  • Static token support for Codex or curl.
  • Streamable HTTP MCP endpoint handlers.
  • PostgreSQL read-only adapter with SQL guardrails.

Install

npm install github:BaoNgoThien18/mcp-guide-schema-query

Environment

Use the same values across projects if you want the same Claude connector credentials:

MCP_WEB_TOKEN=
MCP_OAUTH_CLIENT_ID=
MCP_OAUTH_CLIENT_SECRET=
MCP_OAUTH_SIGNING_KEY=
MCP_OAUTH_CODE_TTL=300
MCP_OAUTH_TOKEN_TTL=3600
MCP_QUERY_DEFAULT_LIMIT=200
MCP_QUERY_MAX_LIMIT=1000
DATABASE_URL=

Next.js App Router Usage

Create a shared server file:

// lib/mcp.ts
import { createMcpServer, createPostgresAdapter } from "@bugmedia/mcp-guide-schema-query";

export const mcp = createMcpServer({
  serverName: "Finance Database",
  path: "/mcp/finance",
  webToken: process.env.MCP_WEB_TOKEN ?? "",
  oauthClientId: process.env.MCP_OAUTH_CLIENT_ID ?? "",
  oauthClientSecret: process.env.MCP_OAUTH_CLIENT_SECRET ?? "",
  oauthSigningKey: process.env.MCP_OAUTH_SIGNING_KEY ?? process.env.JWT_SECRET ?? "",
  guideText: "Describe your system and important joins here.",
  codebase: {
    rootDir: process.cwd(),
    maxFiles: 300,
    maxReadBytes: 120000,
  },
  database: createPostgresAdapter({
    connectionString: process.env.DATABASE_URL ?? "",
    defaultLimit: Number(process.env.MCP_QUERY_DEFAULT_LIMIT ?? "200"),
    maxLimit: Number(process.env.MCP_QUERY_MAX_LIMIT ?? "1000"),
  }),
});

MCP route:

// app/mcp/finance/route.ts
import { mcp } from "@/lib/mcp";

export const runtime = "nodejs";
export const dynamic = "force-dynamic";

export const GET = mcp.get;
export const POST = mcp.post;
export const DELETE = mcp.delete;

OAuth routes:

// app/.well-known/oauth-protected-resource/[[...path]]/route.ts
import { mcp } from "@/lib/mcp";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export const GET = mcp.protectedResource;
// app/.well-known/oauth-authorization-server/[[...path]]/route.ts
import { mcp } from "@/lib/mcp";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export const GET = mcp.authorizationServer;
// app/oauth/mcp/register/route.ts
import { mcp } from "@/lib/mcp";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export const POST = mcp.register;
// app/oauth/mcp/authorize/route.ts
import { mcp } from "@/lib/mcp";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export const GET = mcp.authorize;
// app/oauth/mcp/token/route.ts
import { mcp } from "@/lib/mcp";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export const POST = mcp.token;

Claude Web

Use:

Remote MCP server URL: https://your-domain.com/mcp/finance
OAuth Client ID: MCP_OAUTH_CLIENT_ID
OAuth Client Secret: MCP_OAUTH_CLIENT_SECRET

Codex

Static token URL:

codex mcp add finance --url 'https://your-domain.com/mcp/finance?token=...'

Safety

database-select:

  • Rejects multiple statements.
  • Blocks DDL/DML/admin commands.
  • Runs in BEGIN READ ONLY.
  • Applies statement timeout.
  • Adds a limit to plain SELECT/WITH queries without one.

codebase-read:

  • Reads only files under the configured rootDir.
  • Blocks .env*, .git, node_modules, build output, and dependency/vendor folders.
  • Applies a read budget so large files cannot flood context.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured