nestjs-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@nestjs-mcp-servercreate a note titled 'Grocery' with content 'Buy milk and eggs'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
NestJS + GraphQL + MCP
NestJS alkalmazás, ahol GraphQL API és MCP szerver közös domain rétegen (Prisma + SQLite) keresztül működik. Az MCP toolok ugyanazokat a service-eket hívják, nem a GraphQL-t.
Az iterációs terv: iterations.md.
Előfeltételek
Node.js 20+
npm
Related MCP server: Local Knowledge Desk
Beállítás
npm install
cp .env.example .env
npx prisma migrate devAz npm install a postinstall scripttel legenerálja a Prisma Clientet (src/generated/prisma).
Indítás
# fejlesztés (watch)
npm run start:dev
# build
npm run build
# production
npm run start:prodAlapértelmezett port: 3000 (PORT a .env-ben).
Ellenőrzés
GET /→Hello World!GET /health→{ "status": "ok" }
curl http://localhost:3000/healthAdatbázis (Prisma + SQLite)
Séma:
prisma/schema.prismaConfig:
prisma.config.tsSQLite fájl:
prisma/dev.db(gitignored)Nest DI:
PrismaModule/PrismaService(globális)
npx prisma migrate dev # migráció fejlesztés közben
npx prisma generate # client újragenerálásaNotes domain
Tiszta domain réteg (nincs GraphQL/MCP függőség):
NotesService:findAll,findOne,create,update,removeDTO-k:
CreateNoteDto,UpdateNoteDtoEntitás:
Note(id,title,content,createdAt)
npm test # tartalmazza a NotesService egységteszteketGraphQL API
Code-first Apollo GraphQL a /graphql endpointon (Apollo Sandbox böngészőben).
Queries:
notes,note(id)Mutations:
createNote,updateNote,deleteNoteGenerált séma:
src/schema.gqlA resolverök csak a
NotesService-t hívják
Példa:
mutation {
createNote(input: { title: "Hello", content: "World" }) {
id
title
content
createdAt
}
}
query {
notes {
id
title
}
}curl http://localhost:3000/graphql \
-H "Content-Type: application/json" \
-H "x-api-key: dev-secret-change-me" \
-d '{"query":"{ notes { id title } }"}'MCP server (Streamable HTTP)
@rekog/mcp-nest Streamable HTTP transport a /mcp endpointon. A toolok közvetlenül a NotesService-t hívják (nem GraphQL-t).
Tool | Leírás |
| Összes note listázása |
| Egy note ID alapján |
| Új note (title + content) |
| Note frissítése |
| Note törlése |
Bootstrap: McpStrategy + StreamableHttpTransport a main.ts-ben (startAllMicroservices a listen előtt).
Cursor MCP kliens
A projekt tartalmazza a Cursor HTTP MCP configot: .cursor/mcp.json.
1. Indítsd a szervert
npm run start:devEllenőrizd: http://localhost:3000/health és hogy a logban megjelenik: MCP streamable-http transport mounted at /mcp.
2. Engedélyezd a szervert Cursorban
Nyisd meg Cursor Settings → Tools & MCP
A
nestjs-notesszervernek zölden / connected állapotban kell lennie (a.cursor/mcp.jsonalapján)Ha nem jelenik meg: Reload Window, vagy add hozzá manuálisan:
{
"mcpServers": {
"nestjs-notes": {
"url": "http://localhost:3000/mcp",
"headers": {
"x-api-key": "dev-secret-change-me"
}
}
}
}3. Manuális ellenőrzés chatből
Agent módban kérd pl.:
Használd a
create_noteMCP toolt: titleFrom Cursor, contenthello
Majd GraphQL-ben ellenőrizd:
query {
notes {
id
title
content
}
}vagy:
curl http://localhost:3000/graphql \
-H "Content-Type: application/json" \
-H "x-api-key: dev-secret-change-me" \
-d "{\"query\":\"{ notes { id title } }\"}"MCP kliens smoke (CLI)
Szerver futása mellett:
npm run smoke:mcpEz initialize → tools/list → create_note hívást végez a /mcp endpointon.
Opcionális: STDIO transport
Ugyanazok a Notes toolok helyi subprocessként (GraphQL nélkül). Előbb build:
npm run buildCursor / más kliens példa (projekt gyökérből):
{
"mcpServers": {
"nestjs-notes-stdio": {
"command": "node",
"args": ["dist/main.stdio.js"]
}
}
}Állítsd a Cursor working directory-jét a projekt gyökerére, vagy add meg abszolút args útvonalat a dist/main.stdio.js-hez.
vagy közvetlenül:
npm run start:mcp:stdioA STDIO módban a stdout a protokollé — ne kapcsolj be Nest logger t.
Seed, validáció, smoke (DX)
DX = Developer Experience — a fejlesztői élmény: gyors seed, smoke script, érthető hibák, logging.
Seed
npm run prisma:seed
# vagy: npx prisma db seedHárom példa note kerül az adatbázisba (prisma/seed.ts).
Validáció és hibák
GraphQL:
class-validatora DTO-kon + globálisValidationPipeMCP: szigorú Zod sémák (
notes.schemas.ts) a tool paraméterekenDomain:
NotesServiceis Zod-dal validál (közös szabályok)Hiányzó note: GraphQL
NotFoundException, MCP toolisError: true+ üzenet
Smoke
Szerver futása mellett:
npm run smoke # auth 401 + GraphQL + MCP
npm run smoke:mcp # csak MCP kliens smoke (API key-vel)Auth, rate limit, környezetek
API key
A /graphql és /mcp endpointok x-api-key headert várnak (API_KEY a .env-ben). A / és /health nyilvános.
curl http://localhost:3000/graphql \
-H "Content-Type: application/json" \
-H "x-api-key: dev-secret-change-me" \
-d '{"query":"{ notes { id title } }"}'Kulcs nélkül → 401.
Rate limit + timeout
HTTP
/graphql+/mcp: IP+path alapú limit (THROTTLE_LIMIT/THROTTLE_TTL_MS)Nest Throttler a GraphQL resolverökön
Tool/resolver timeout:
MCP_TOOL_TIMEOUT_MS(alap 10s)
Környezetek
Fájl | Cél |
| Helyi fejlesztés (lazább limit) |
| Demo / szigorúbb limit, külön DB |
| Közös / fallback értékek |
# development (alap)
npm run start:dev
# demo
set APP_ENV=demo
npm run start:devConfigModule betöltési sorrend: .env.<APP_ENV> → .env.
Több MCP kliens példa
Cursor (projekt):
.cursor/mcp.jsonCursor + STDIO:
examples/mcp-clients/cursor.mcp.jsonMás HTTP MCP kliens:
examples/mcp-clients/http-client.mcp.json
Cursor config (API key headerrel):
{
"mcpServers": {
"nestjs-notes": {
"url": "http://localhost:3000/mcp",
"headers": {
"x-api-key": "dev-secret-change-me"
}
}
}
}A STDIO transport helyi folyamat — HTTP API key nem vonatkozik rá.
Környezeti változók
Változó | Leírás | Alapértelmezés |
| HTTP szerver port |
|
| SQLite connection string |
|
|
|
|
|
| — (kötelező a védett route-okhoz) |
| Rate limit ablak |
|
| Max kérések / ablak |
|
| Tool/resolver timeout |
|
Másold a .env.example fájlt .env-re, és igazítsd a helyi értékeket. A .env nincs a gitben.
Dependency notes
overrides.ws→ patchedws@8.21.3(Nest GraphQL transitive CVE).npmrclegacy-peer-deps=true→ elnyomja a Nest Apollo / deprecated GraphQL Playground peer konfliktust (Apollo 5 +playground: falsemellett biztonságos)Maradék:
@hono/node-servermoderate (MCP SDK 1.x függőség) — 2.x override eltöri az@modelcontextprotocol/node-ot, amíg az upstream frissül
This server cannot be deployed
Maintenance
Related MCP Connectors
An MCP server that used to create notes
Google Keep-style notes app with an MCP server for AI agents to read/write notes.
Markdown-based note-taking with a hosted MCP server. Your notes serve you and your AI.
Hosted MCP server for AI-driven data ops. Create apps, manage schemas, and CRUD structured data.
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server for managing and persisting notes, offering CRUD operations, note summarization, and resource-based access via a note:// URI scheme.47MIT
- FlicenseAqualityBmaintenanceA local MCP server for managing Markdown notes, enabling create, list, read, search, summarize, and delete operations through natural language.61-
- FlicenseNot gradedqualityDmaintenanceA simple notes MCP server that enables creating, listing, and summarizing text notes via resources, tools, and prompts.-
- FlicenseNot gradedqualityCmaintenanceMCP server for a JWT-authenticated note-taking API, exposing CRUD tools for notes.-