跳到正文
DEV Community· Dominic Rockson·· 6 天前AI 評分40

Yatta JS 1.0.5:後端可成為 MCP 伺服器,無需第二個程序

Your backend can be an MCP server — and it doesn't need a second process

AI 導讀

Yatta JS 1.0.5 在執行後端的同一個 Bun 程序內嵌入 MCP 伺服器 yatta/mcp,讓後端可直接向 AI 工具提供工具。工具共用後端的資料庫、身份驗證和持久化工作佇列,毋須另建服務。

正文

Dominic Rockson

AI tools want to call your backend. That's the whole idea behind the Model Context Protocol: an AI client talks to an MCP server, and the server exposes tools — look up an order, create a record, run a job, check a status.

The usual way to get there is to stand up a second service. Your API stays where it is, and next to it you build an MCP server that reaches into the same database, re-implements the same auth checks, and duplicates the same business logic in a thinner wrapper. Two things to deploy. Two things to keep in sync. Two log streams to read at 2am when something disagrees with itself.

Yatta JS 1.0.5 takes the other route. It ships an embedded MCP server — yatta/mcp — inside the same Bun process that already runs your database, auth, mail, storage, realtime, and jobs.

That matters because the backend and the MCP server stop being two systems that have to agree. They're one process:

  • The tools an AI client calls read from the same built-in database your API reads from. There is no second copy of the data to drift.
  • The auth that already guards your API guards the tools too. Nothing gets a back door because the MCP layer forgot a check the API remembered.
  • A job an AI client triggers is the same durable job queue your app already uses — not a fire-and-forget side channel.

None of this is a chatbot, and Yatta JS isn't trying to be one. It's a backend-as-a-server: one process that runs the whole backend. The MCP module just means that one process can now speak the protocol AI tools already speak, instead of you building a translator service next to it.

The install is still the same:

npm i yatta.js

Docs: https://yatta.js.org — Code: https://github.com/psrockstar098/yatta.js

If your backend is already one process, letting AI tools talk to it shouldn't take a second one. What would you let an AI client do against your backend first — read, or act?

來源:DEV Community · dev.to