mcp-redshift

mcp-redshift

MCP server that integrates Microsoft Copilot with Amazon Redshift, enabling catalog search, query template retrieval, and query execution with end-to-end user identity propagation.

Category
访问服务器

README

MCP Redshift — Copilot + Entra ID + Propagated Identity

MCP server that integrates Microsoft Copilot, Entra ID, DataZone (catalog), DynamoDB (query templates) and Amazon Redshift, propagating the real user's identity end to end (OBO + native IdP federation).

Documentation

Reference (the "what")

Document Content
Architecture Overview, components, Entra ID, Redshift native IdP, AWS infra, risks
Tools Spec Contracts for the 5 tools, error envelope, security invariants, acceptance criteria
Setup & Local Dev Setup runbook (Entra/Redshift/Copilot) and dev guide with the real components

Execution (the "how" and "when")

Document Content
Implementation Roadmap Development phases, tasks, deliverables and acceptance criteria
ADRs Architecture decisions (Python version, Docker-only, dependency emulation, stack, driver choice, stateless sessions, Terraform, templates as files, OBO credential, delivery pipeline)
CLAUDE.md Code conventions: typing, docstrings, tests, coverage

Development principles

  1. 100% containerized — no code runs directly on the local machine; build, execution and tests happen via Docker Compose (ADR-0002).
  2. Local-first — no access to the real components (Entra, Redshift, DataZone, AWS DynamoDB) at this stage; every external dependency sits behind an interface (port) with a local emulator/fake (ADR-0003).
  3. Typing and documentation are mandatory — every function with complete type hints (inputs and output) and a docstring; enforced by mypy --strict in CI.
  4. Test coverage as a gatepytest --cov with a coverage floor that fails the build.

Quick start

Requirements: Docker (with Compose) and git — nothing else.

docker compose up -d postgres dynamodb mock-idp     # start the local emulators
docker compose run --rm test python scripts/seed_dynamodb.py   # seed the templates table
docker compose run --rm test                        # full test suite with coverage gate
docker compose run --rm test sh scripts/ci.sh       # everything CI runs (format, lint, mypy, secrets, tests)

With make installed the same commands are make up, make seed, make test and make ci.

Running the MCP server locally

docker compose up -d --build mcp-server                        # emulators + server on :8080
docker compose run --rm test python scripts/seed_dynamodb.py   # seed templates (dynamodb-local is in-memory)

Every MCP route requires a Bearer JWT — mint one at the mock-idp:

curl -s -X POST http://localhost:8081/mint | jq -r .access_token

Query templates

Templates live in templates/ as YAML and are published to DynamoDB by the pipeline (ADR-0009). Git is the source of truth; the table is a projection of it.

docker compose run --rm test python -m mcp_redshift.template_source check

check needs no AWS and runs in CI: it parses every file, matches declared parameters against the placeholders the SQL binds, applies the catalog denylist and refuses duplicates — so a broken template is a red build rather than a conversation that fails in front of a user. See templates/README.md for the format, the optional-filter pattern and how publishing treats a template the validation job marked broken.

Validating templates against the schema

Stored templates drift as the schema evolves. The validation job parses every template, compares its tables and columns against information_schema and reports what no longer resolves — so the drift is found by an operator instead of by a user mid-conversation.

docker compose run --rm -e VALIDATION_DB_USER=admin -e VALIDATION_DB_PASSWORD=admin test python -m mcp_redshift.validation

It prints a JSON report and exits 1 when it finds drift (the signal a scheduled task turns into an alarm). Add --apply to mark the affected templates broken, which makes them refuse to execute and appear flagged in listings. Templates that start matching the schema again are reported but never reactivated automatically — a template may have been broken on purpose.

The job needs a database user that sees the whole schema (information_schema only exposes what the connected user has rights on) and runs outside the MCP runtime, whose task role has no write access to the template table.

Validating with MCP Inspector

  1. npx @modelcontextprotocol/inspector
  2. Transport: Streamable HTTP, URL: http://localhost:8080/mcp.
  3. Add a custom header Authorization: Bearer <token from /mint>.
  4. Connect and run the smoke sequence: search_catalogsearch_query_templatesget_query_templaterun_query_template (dates like 2026-01-01/2026-12-31). Every response is the standard envelope; executed_as must show aad:user-a@company.com.

Requests without a token (including initialize) are rejected with 401 by design.

Pointing at the real services (phase 7)

Everything above runs against the Docker emulators. Switching to real Entra, Redshift and AWS is a configuration change and nothing else — no code path, no build argument, no import differs (ADR-0003, asserted by tests/unit/test_wiring.py).

cp .env.real.example .env.real   # fill from docs/phase7-values.md
docker compose --profile real up mcp-server-real
docker compose --profile real run --rm test-real

Three variables are omitted from .env.real.example on purpose: MOCK_IDP_URL, CATALOG_FIXTURE_PATH and DYNAMODB_ENDPOINT_URL. Any one of them left set in a real deployment silently restores a local stand-in — including a password connection instead of the user's token, which is identity propagation gone with everything still green.

Current status

All locally-testable phases (0–6) are complete: foundation, domain core, authentication, data layer, execution with the identity-isolation CI gate, the MCP server with the 4 main tools, and the flag-gated ad-hoc query with guardrails.

Everything phases 7 and 8 allowed to be built without access has been built too: the versioned Redshift DDL, the values worksheet and checklist, the self-skipping tests/real/ suite, the Terraform stack with alarms and a dashboard, the deploy pipeline, the template validation job and the operations runbook.

What remains genuinely needs the real thing: applying any of it, confirming token_type on the driver, the real AADSTS surface, DataZone's actual forms shape, and Copilot's refresh behavior past ~75 minutes. See the roadmap and the security review.

To enable the optional 5th tool locally: set ADHOC_ENABLED: "true" in docker-compose.yml and restart mcp-server.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选