MCP integration
Narew exposes an authenticated MCP endpoint at /mcp on the API Worker. Agents and integrations call the same application services and authorization checks as the dashboard: tenant, project, environment and registered database are resolved server-side, and no tool accepts SQL.
Create a token
- Open the organization's Settings page.
- In MCP tokens, choose Create token.
- Pick a name, the permissions the token may use, an optional project or environment scope, and an optional expiry.
- Copy the secret immediately. It is shown once and stored only as a digest.
A token can never exceed your own current permissions. Removing a role, changing a grant or removing membership narrows every token created by that member on its next call. Revoking a token takes effect immediately.
Listing tokens requires integrations.view; creating and revoking requires integrations.manage.
Connect a remote client
Point the client at https://<your-narew-api-host>/mcp and send the token as a bearer credential on every request:
Authorization: Bearer narew_mcp_...Non-browser clients do not send an Origin header. Requests with an unknown Origin are rejected. Each token is limited to 120 calls per minute.
The first slice uses a static bearer token. Clients that cannot set an Authorization header on a remote server can use the stdio bridge below; full OAuth discovery is not implemented yet.
Connect a stdio-only client
NAREW_MCP_URL=https://<your-narew-api-host>/mcp \
NAREW_MCP_TOKEN=narew_mcp_... \
pnpm exec narew-cms mcpOr pass --url and --token. The bridge reads newline-delimited JSON-RPC from stdin and writes only MCP messages to stdout; diagnostics go to stderr. Errors use stable codes such as MCP_CONFIGURATION_INVALID, MCP_UNAUTHORIZED, MCP_RATE_LIMITED and MCP_UPSTREAM_ERROR.
Example client configuration:
{
"mcpServers": {
"narew": {
"command": "pnpm",
"args": ["exec", "narew-cms", "mcp"],
"env": {
"NAREW_MCP_URL": "https://api.example.com/mcp",
"NAREW_MCP_TOKEN": "narew_mcp_..."
}
}
}
}Tools
| Tool | Permission | Purpose |
|---|---|---|
list_organizations | — (token's own organization only) | Show the tenant bound to the token |
list_projects | projects.view | List visible projects |
list_environments | projects.view | List environments of a project |
list_databases | content.read | List registered databases for an environment |
list_collections | content.read | Collections, key fields and metadata checksums |
get_schema | schema.view | Full installed metadata document |
query_records | content.read | Typed filters, projection, sorting and pagination |
create_record | content.create | Create one record |
update_record | content.update | Update one record by complete key and version |
get_record_operation | matching content.* permission | Durable status of a mutation |
list_media | media.read | List ready media assets |
get_media | media.read | Read one asset's metadata and delivery URL |
inspect_my_permissions | — | Effective permissions after token intersection |
Mutations follow the same durable protocol as the dashboard and CLI. Pass the checksum and schemaChecksum returned by list_collections, and a unique operationId. There is no automatic replay: after a lost response, call get_record_operation with the same operationId. If installed metadata declares publication.mode: "all-content-writes", the token also needs content.publish.
Media upload, move, delete and publication toggles are not exposed yet.