Skip to content

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 ​

  1. Open the organization's Settings page.
  2. In MCP tokens, choose Create token.
  3. Pick a name, the permissions the token may use, an optional project or environment scope, and an optional expiry.
  4. 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:

http
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 ​

sh
NAREW_MCP_URL=https://<your-narew-api-host>/mcp \
NAREW_MCP_TOKEN=narew_mcp_... \
pnpm exec narew-cms mcp

Or 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:

json
{
	"mcpServers": {
		"narew": {
			"command": "pnpm",
			"args": ["exec", "narew-cms", "mcp"],
			"env": {
				"NAREW_MCP_URL": "https://api.example.com/mcp",
				"NAREW_MCP_TOKEN": "narew_mcp_..."
			}
		}
	}
}

Tools ​

ToolPermissionPurpose
list_organizations— (token's own organization only)Show the tenant bound to the token
list_projectsprojects.viewList visible projects
list_environmentsprojects.viewList environments of a project
list_databasescontent.readList registered databases for an environment
list_collectionscontent.readCollections, key fields and metadata checksums
get_schemaschema.viewFull installed metadata document
query_recordscontent.readTyped filters, projection, sorting and pagination
create_recordcontent.createCreate one record
update_recordcontent.updateUpdate one record by complete key and version
get_record_operationmatching content.* permissionDurable status of a mutation
list_mediamedia.readList ready media assets
get_mediamedia.readRead 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.