# Note Tracker MCP

The backend exposes a project-scoped Model Context Protocol server powered by the official `laravel/mcp` package.

## Endpoint

`POST /mcp/note-tracker`

The MCP transport also registers `GET` and `DELETE` on the same path for session handling. Every request requires the separate MCP key generated in Organization Settings:

```text
Authorization: Bearer <ntmcp_key>
Accept: application/json, text/event-stream
```

The key resolves one organization and its managed `AI Assistant` member. MCP can only access projects that have MCP enabled and include that member. It can only read notes assigned to the AI member. Notes created through MCP are always internal and assigned to the AI member. Plain-text note content is converted to safe HTML paragraphs and lists before rendering. MCP can also edit note title/content, assign additional project members, set labels, and set or change note status while keeping the AI member assigned.

## Available tools

- `workspace_summary`
- `list_projects`
- `list_notes`
- `create_note`
- `update_note`

## Provision the local AI workspace

Run the idempotent command below using PHP 8.3 or newer. Omit the option to enter the password through a hidden prompt.

```powershell
php artisan notetracker:provision-ai-workspace --password=<account-password>
```

It creates or updates the `ai_org` organization and `ai@tester.test` administrator, ensures the managed AI member and default organization data, enables the `note tracker` project for MCP, creates its first setup note, and rotates the organization MCP key. The password and new plaintext key must remain outside version control.

## Verification

```powershell
php vendor/bin/phpunit tests/Feature/NoteTrackerMcpTest.php tests/Feature/OrganizationMcpSettingsTest.php
php artisan route:list --path=mcp
```

