Relay MCP Server

Relay MCP Server

An AI operations agent that reads from your own PostgreSQL database and policy documents, provides grounded answers with citations, and exposes read-only tools to external MCP clients while keeping writes behind a human approval gate.

Category
访问服务器

README

<div align="center">

Relay

An AI operations agent that answers from your own data, cites your own policies, and stops for a human before it spends a cent.

Next.js AI SDK PostgreSQL TypeScript Self-hosted

1 orchestrator · 2 specialists · 9 tools · 1 human-gated write

</div>


Operations teams live in a gap. The answer to "why hasn't this customer's order arrived, and do we owe them money?" sits in two places at once: the order database, and a policy document nobody has read since onboarding. Closing that gap by hand is most of what a support agent does all day.

Relay closes it — and shows its work while it does.

The Relay console mid-request


What makes this different from a chatbot

It reads your systems, not the internet. Nine tools query a live PostgreSQL database. The model is forbidden from stating any fact that did not come from a tool result, and every call is visible on screen with its real latency.

It renders product, not prose. Ask what is running late and you get a table with status badges and days late. Ask for an overview and you get a dashboard. The model chooses the tool; the frontend owns how the result looks, so the output is always well-formed no matter what the model does.

It cites your policies. Upload a PDF and it is chunked, embedded and searchable in seconds. Retrieval is hybrid — vector similarity for meaning, Postgres full-text for exact terms like an SKU — fused with reciprocal rank. Embeddings are computed in-process, so document contents never leave your server.

It cannot spend your money. Exactly one tool writes. It sits on the orchestrator, behind a human approval gate, capped at the order total and idempotent. No specialist can move money, and no amount of delegation can route around the gate. That is a property of the topology, not a setting.

It plugs into what you already use. Relay is also an MCP server. Point Claude Desktop, Cursor or another agent at /api/mcp and its read tools become available there — the same tools, against the same data. The write tool is deliberately not exposed: the approval gate lives in Relay's interface, so federating the write would hand an external client a way around it.

You can see how it is wired, live. The architecture view is not a diagram — nodes light up along the path a request actually took, with each specialist listing the tools it called and how long they took.

The live architecture view


The agents

Agent Owns Tools
Relay (orchestrator) Routes the request, synthesises the answer, owns the write path 2 delegations + 1 write
Operations specialist Orders, shipments, customers, tickets, operational overview 7 read
Knowledge specialist The document library, through hybrid retrieval 1 read

Delegation is not for speed — it costs latency. It buys reliable tool selection (six related tools beat fourteen unrelated ones), clean per-specialist context, and a structurally isolated write path.

The tools

Tool Effect What it does
find_delayed_orders read Orders past their estimated delivery date and not delivered
search_orders read Orders by status, customer or recency
get_order read One order in full: items, shipment, tickets, refunds
track_shipment read Where a shipment is, whether it is late and by how many days
search_tickets read Support tickets by status, priority or category
get_customer read One customer with order and ticket history
get_operations_summary read Counts by status, delays by carrier, 14-day volume trend
search_knowledge read Hybrid retrieval over uploaded documents
issue_refund write Issues a refund. Human approval required. Capped and idempotent.

How retrieval works

The retrieval pipeline

Ingestion, once per document: upload → extract → chunk (~1000 chars, 150 overlap) → embed (multilingual MiniLM, 384d) → store in pgvector.

Query, every question: embed → vector search and full-text search in parallel → fuse by reciprocal rank → top 5 passages with their source.

Both searches, because neither is enough alone. Vector similarity finds a passage that means the same thing in different words and misses an exact SKU. Full-text finds the exact token and misses the paraphrase. RRF merges the two rankings without calibrating scores between incomparable systems.

The embedder is multilingual on purpose: an English-only model scores a Spanish question against an English policy at 0.18, barely above the 0.02 it gives unrelated text. Cross-language retrieval would silently return noise. The multilingual model scores the same pair at 0.43.


Running it

Requirements: Node 22+, Docker, and an API key from DeepSeek or Anthropic.

npm install                  # also generates the Prisma client
cp .env.example .env         # set RELAY_PROVIDER and the matching key
npm run db:up                # PostgreSQL + pgvector on port 5440
npm run db:push              # create the schema
npm run db:seed              # demo dataset + policy documents
npm run dev

Open http://localhost:3000.

Bring your own key. The Settings tab in the console accepts an API key that is stored in your browser only, sent as a request header, forwarded to that provider and discarded. It is never written to the database, never logged, and never appears in the audit trail.

Command What it does
npm run db:up / db:down Start / stop PostgreSQL
npm run db:reset Wipe and reseed everything
npm run db:seed:docs Reset just the document library
npm run docs:pdf Rebuild the case study PDFs

The seed is deterministic — the same orders, delays and tickets on every run — and dates are generated relative to now, so the data never looks stale.

Try it

Sample documents to upload live in docs/sample-uploads/, with the questions to ask after each one and the correct answers. One of them deliberately contradicts a seeded policy, which is what happens at a real client.


Project layout

prisma/
  schema.prisma          Data model — one datastore
  seed.ts                Deterministic business dataset
  seed-documents.ts      Policy documents into the knowledge base
src/
  app/api/chat/route.ts  The agent endpoint
  lib/
    agents.ts            Orchestrator + specialists, delegation tools
    tools.ts             The 9 tools
    rag/                 Chunking, ingestion, hybrid search
    embeddings.ts        Local multilingual embedder
    audit.ts             Tool call recording
    model.ts             Provider resolution, bring-your-own-key
  components/
    console.tsx          The one-panel console
    architecture.tsx     Live architecture canvas
    renders/             Generative UI: tables, records, charts

Connecting over MCP

// claude_desktop_config.json
{
  "mcpServers": {
    "relay": { "url": "http://localhost:3000/api/mcp" }
  }
}

Eight read tools become available: orders, shipments, customers, tickets, the operational summary and hybrid document search. issue_refund is absent by design — reads are safe to federate, writes stay behind the human gate.

Deployment

Self-hosted. A standalone Next.js build and a PostgreSQL container behind a reverse proxy. No managed platform required and no vendor lock-in introduced.

Security

.env and every .env.* except .env.example are gitignored. This repository is public — no key, token or connection string belongs in a tracked file.

The demo dataset is entirely generated. Harbor & Pine is fictional; no customer, order, address or refund in it refers to a real person.


Documentation

Document For
Case study (EN) The full technical write-up
MCP exposure · (ES) How /api/mcp was built, what it exposes and what it does not
Caso de estudio (ES) Spanish edition
Sample uploads Test documents with expected answers

Built by

IKOM — Haziel Zul and Jorge Bustos.

Relay is a showcase build. Harbor & Pine is a fictional brand and its data is generated; the architecture, the code and the numbers are real and reproducible in the demo.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选