253 lines
9.9 KiB
Markdown
253 lines
9.9 KiB
Markdown
<p align="center">
|
|
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
|
</p>
|
|
|
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
|
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
|
|
|
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
|
<p align="center">
|
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
|
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
|
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
|
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
|
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
|
|
</p>
|
|
<!--[](https://opencollective.com/nest#backer)
|
|
[](https://opencollective.com/nest#sponsor)-->
|
|
|
|
## Description
|
|
|
|
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
|
|
|
## Project setup
|
|
|
|
```bash
|
|
$ npm install
|
|
```
|
|
|
|
## Compile and run the project
|
|
|
|
```bash
|
|
# development
|
|
$ npm run start
|
|
|
|
# watch mode
|
|
$ npm run start:dev
|
|
|
|
# production mode
|
|
$ npm run start:prod
|
|
```
|
|
|
|
## Mistral assistant
|
|
|
|
The in-app assistant calls the Mistral Conversations API from the API server. Configure the key and optional model in the API environment, never in the Angular client:
|
|
|
|
```bash
|
|
MISTRAL_API_KEY=your-mistral-api-key
|
|
MISTRAL_MODEL=mistral-large-latest
|
|
MCP_ACCESS_TOKEN=shared-secret-for-the-listify-mcp-connector
|
|
```
|
|
|
|
The authenticated frontend calls `POST /api/assistant/chat`; the API forwards the conversation to `POST /v1/conversations` with the `listify` connector enabled and returns the assistant text. The MCP connector token authenticates only the connector. The assistant passes the authenticated Listify `userId` into every connector tool call, so each logged-in user sees and modifies only their own lists.
|
|
|
|
Configure the external MCP connector with `Authorization: Bearer $MCP_ACCESS_TOKEN`. If your connector supports dynamic headers, it may also send `x-listify-user-id`; otherwise the MCP tools require a `userId` argument.
|
|
|
|
Every Mistral response is stored in `assistant_chat_logs`. The table includes the sanitized provider request, the full raw provider response, the extracted assistant text sent back to the UI, response status and timing metadata.
|
|
|
|
## Run tests
|
|
|
|
```bash
|
|
# unit tests
|
|
$ npm run test
|
|
|
|
# e2e tests
|
|
$ npm run test:e2e
|
|
|
|
# test coverage
|
|
$ npm run test:cov
|
|
```
|
|
|
|
## MCP-Agent anbinden
|
|
|
|
Die API enthaelt einen Remote-MCP-Server unter `/mcp`. Er nutzt den bestehenden JWT-Login der REST-API. Ein Agent oder MCP-Client darf deshalb nur mit einem gueltigen Access Token eines verifizierten Users auf die Tools zugreifen.
|
|
|
|
### Ablauf
|
|
|
|
1. User ueber die normale Auth-API anmelden, z. B. `POST /auth/login`.
|
|
2. `accessToken` aus der Login-Antwort speichern.
|
|
3. MCP-Client auf den Streamable-HTTP-Endpunkt konfigurieren:
|
|
|
|
```text
|
|
http://localhost:3000/mcp
|
|
```
|
|
|
|
4. Bei jedem MCP-Request diesen Header senden:
|
|
|
|
```http
|
|
Authorization: Bearer <accessToken>
|
|
```
|
|
|
|
Der Server erzeugt beim MCP-Initialize eine Session. Folge-Requests muessen den vom Server gelieferten `mcp-session-id` Header mitsenden. Die Session ist an den User aus dem JWT gebunden; ein Token eines anderen Users kann dieselbe MCP-Session nicht weiterverwenden.
|
|
|
|
### Verfuegbare Tools
|
|
|
|
- `list_existing_lists`
|
|
- Liest die Listen des angemeldeten Users.
|
|
- Input: optional `{ "status": "open" | "completed" | "all", "includeItems": true | false }`
|
|
- Ohne `status` werden nur offene Listen geliefert. Erledigte/geschlossene Listen werden nur mit `"status": "completed"` oder explizit alle Listen mit `"status": "all"` geliefert.
|
|
- Schreibt keine Daten.
|
|
|
|
- `list_templates`
|
|
- Liest die Listenvorlagen des angemeldeten Users.
|
|
- Input: optional `{ "kind": "packing" | "shopping" | "todo" | "custom" }`
|
|
- Schreibt keine Daten.
|
|
|
|
- `suggest_lists`
|
|
- Erzeugt strukturierte Vorschlaege fuer neue Listen.
|
|
- Input:
|
|
|
|
```json
|
|
{
|
|
"goal": "Sommerurlaub mit Handgepaeck",
|
|
"kind": "packing",
|
|
"constraints": ["Nur Handgepaeck", "Reisedokumente nicht vergessen"]
|
|
}
|
|
```
|
|
|
|
- Output enthaelt `suggestions` mit `name`, `description`, `kind`, `items`, optionalem Template-Bezug und `rationale`.
|
|
- Schreibt keine Daten und legt keine Liste an.
|
|
|
|
- `create_list`
|
|
- Erstellt eine neue Liste fuer den angemeldeten User.
|
|
- Input:
|
|
|
|
```json
|
|
{
|
|
"name": "Sommerurlaub",
|
|
"description": "Packliste fuer die Reise",
|
|
"kind": "packing",
|
|
"items": [
|
|
{ "title": "Pass", "required": true },
|
|
{ "title": "Tickets", "notes": "Digital und offline sichern" }
|
|
]
|
|
}
|
|
```
|
|
|
|
- `items` ist optional. Wenn Items angegeben sind, werden sie nach dem Erstellen der Liste in Reihenfolge hinzugefuegt.
|
|
- Output enthaelt `list` mit der erstellten Liste inklusive Items.
|
|
|
|
- `add_list_item`
|
|
- Fuegt ein Item zu einer bestehenden Liste hinzu, auf die der angemeldete User Zugriff hat.
|
|
- Input:
|
|
|
|
```json
|
|
{
|
|
"listId": "list-id",
|
|
"title": "Milch",
|
|
"quantity": 2,
|
|
"required": true
|
|
}
|
|
```
|
|
|
|
- Output enthaelt `list` mit der aktualisierten Liste.
|
|
|
|
- `create_template`
|
|
- Erstellt ein neues Template fuer den angemeldeten User.
|
|
- Input:
|
|
|
|
```json
|
|
{
|
|
"name": "Sommerurlaub",
|
|
"description": "Wiederverwendbare Packvorlage",
|
|
"kind": "packing",
|
|
"items": [
|
|
{ "title": "Pass", "required": true },
|
|
{ "title": "Tickets", "notes": "Digital und offline sichern" }
|
|
]
|
|
}
|
|
```
|
|
|
|
- Output enthaelt `template` mit dem erstellten Template inklusive Items.
|
|
|
|
- `add_template_item`
|
|
- Fuegt ein Item zu einem bestehenden Template hinzu, das dem angemeldeten User gehoert.
|
|
- Input:
|
|
|
|
```json
|
|
{
|
|
"templateId": "template-id",
|
|
"title": "Sonnencreme",
|
|
"required": false
|
|
}
|
|
```
|
|
|
|
- Output enthaelt `template` mit dem aktualisierten Template.
|
|
|
|
### Minimaler MCP-Request
|
|
|
|
Ein MCP-Client uebernimmt normalerweise Initialize, Session-Header und Tool-Calls selbst. Fuer eigene Tests sieht ein Tool-Call nach erfolgreicher Initialisierung sinngemaess so aus:
|
|
|
|
```json
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"method": "tools/call",
|
|
"params": {
|
|
"name": "suggest_lists",
|
|
"arguments": {
|
|
"goal": "Sommerurlaub mit Handgepaeck",
|
|
"kind": "packing",
|
|
"constraints": ["Nur Handgepaeck"]
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
Wichtig: Der aktuelle Ausbau erlaubt Erstellen von Listen und Templates sowie Hinzufuegen von Items. Aendern, Abhaken, Loeschen und Teilen ist ueber MCP noch nicht freigegeben.
|
|
|
|
## Deployment
|
|
|
|
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
|
|
|
|
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
|
|
|
|
```bash
|
|
$ npm install -g @nestjs/mau
|
|
$ mau deploy
|
|
```
|
|
|
|
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
|
|
|
|
## Resources
|
|
|
|
Check out a few resources that may come in handy when working with NestJS:
|
|
|
|
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
|
|
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
|
|
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
|
|
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
|
|
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
|
|
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
|
|
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
|
|
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
|
|
|
|
## Support
|
|
|
|
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
|
|
|
## Stay in touch
|
|
|
|
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
|
|
- Website - [https://nestjs.com](https://nestjs.com/)
|
|
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
|
|
|
## License
|
|
|
|
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
|