Repository navigation
plugin nself ai mcp
The nSelf AI MCP server exposes 7 tools to local AI agents (ClawDE, Claude Code, OpenCode, CLI) over the ADR-003 6-step dispatch chain. Every tool invocation is auth-gated by caller trust level before reaching the PolicyEngine.
Port: 3762 | License: Pro | Bundle: ɳClaw (AI-CP)
| Tool | Trust required | Description |
|---|---|---|
search |
standard (2) | Semantic search over plugin, task, and user data |
recall |
standard (2) | Recall prior context from the nSelf memory index |
summarize |
standard (2) | Summarize a nSelf resource by ID or topic |
safe-write |
standard (2) + user_approved | Write structured output to a scoped memory topic |
route |
elevated (3) | Route a request to the optimal AI provider and lane |
cost-report |
elevated (3) | Pull token cost summary from ag_key_audit |
key-status |
elevated (3) + admin grant | Show key pool health per provider |
Every invocation runs 6 ordered steps. Any failure short-circuits — the handler never executes.
caller → auth → trust → PolicyEngine → SupplyChainPolicy → SandboxGuard → handler
| Step | Component | Action |
|---|---|---|
| 1 | Auth | Resolve caller_id to trust level; deny untrusted immediately |
| 2 | Trust | Pass trust context through chain |
| 3 | PolicyEngine | Evaluate policy (W4-W7: pass-through; W14-T02: deny-by-default) |
| 4 | SupplyChainPolicy | Validate model allowlist and MCP server binary hashes |
| 5 | SandboxGuard | Per-tool input validation |
| 6 | Handler | Invoke the registered tool handler |
Every PolicyEngine evaluation writes a row to ag_key_audit (ALLOW and DENY alike).
Caller identity is determined by the caller_id prefix in the MCP envelope.
| Caller prefix | Trust level | Notes |
|---|---|---|
clawde:* |
3 (elevated) | LEDGER §C lock |
claude-code:* |
3 (elevated) | LEDGER §C lock |
opencode:* |
3 (elevated) | LEDGER §C lock |
cli:* |
2 (standard) | Standard operations |
plugin:* |
1 (limited) | Plugin sandbox |
| (unmatched) | 0 (untrusted) | All tools denied |
Trust level 3 (elevated) can access all 7 tools. Trust level 2 (standard) reaches user-tier tools only (search, recall, summarize, safe-write). Trust levels 0-1 are denied all tools.
Semantic search over nSelf plugin metadata, task records, and user data.
Inputs:
{
"query": "string (required)",
"limit": "integer (optional, default 10)",
"scope": "plugins | tasks | users (optional, default all)"
}Requires: trust_level >= 2
Recall prior conversation context or topic summaries from the memory index.
Inputs:
{
"topic": "string (required)",
"max_age_days": "integer (optional, default 30)"
}Requires: trust_level >= 2
Summarize a nSelf resource (plugin detail, task history, user profile).
Inputs:
{
"resource_id": "string (required)",
"resource_type": "plugin | task | user (required)"
}Requires: trust_level >= 2
Write structured output to a scoped memory topic. Requires explicit user approval in the policy context to prevent unintended writes.
Inputs:
{
"topic": "string (required)",
"content": "string (required, non-empty)"
}Requires: trust_level >= 2 AND policy_context.user_approved = true
If user_approved is false, the request is denied before PolicyEngine runs.
Route an AI request to the optimal provider and lane via nself-ai-gateway.
Inputs:
{
"provider": "anthropic | openai | google | ollama | vllm | tei",
"lane": "fast | deep | multimodal | embedding | rerank | live | local",
"tenant_id": "uuid or null"
}Requires: trust_level = 3 (elevated callers only)
Pull token cost summary from ag_key_audit for the current tenant.
Inputs:
{
"period_days": "integer (optional, default 30)",
"provider": "string (optional, filter by provider)"
}Requires: trust_level = 3 (elevated callers only)
Show current key pool health (enabled count, cooldown count, quota remaining) per provider.
Inputs:
{
"provider": "string (optional, show all if omitted)"
}Requires: trust_level = 3 AND admin grant (admin-only tool)
nself license set <your-key>
nself plugin install nself-ai-mcpSet required environment variables:
nself plugin env set nself-ai-mcp NSELF_LICENSE_KEY=<your-key>
nself plugin env set nself-ai-mcp NSELF_AI_GATEWAY_URL=http://localhost:3761| Variable | Required | Default | Description |
|---|---|---|---|
NSELF_LICENSE_KEY |
Yes | — | nSelf Pro license key |
NSELF_MCP_PORT |
No | 3762 |
HTTP server port |
NSELF_AI_GATEWAY_URL |
No | http://localhost:3761 |
nself-ai-gateway endpoint |
NSELF_DB_URL |
No | — | PostgreSQL for audit writes (optional) |
nself-ai-mcp writes to ag_key_audit (owned by nself-ai-gateway) but maintains no
tables of its own. plugin.json declares "tables": [].
Tenant isolation is inherited from nself-ai-gateway's ag_key_audit row-filter on
tenant_id (cloud multi-tenancy, not source_account_id).
Requires an active nSelf Pro license. Purchase at nself.org/pro.
- plugin-nself-ai-gateway — AI key pool that this plugin dispatches through
- plugin-retrieval — pgvector retrieval backing the search tool
- Architecture
- Home
Getting Started
Commands
- Commands, Overview
- Lifecycle: cmd-init · cmd-build · cmd-start · cmd-stop · cmd-restart · cmd-dev
- Monitoring: cmd-status · cmd-logs · cmd-health · cmd-urls · cmd-doctor · cmd-monitor · cmd-alerts · cmd-sentry · cmd-watchdog
- Data: cmd-db · cmd-backup · cmd-dr · cmd-queue · cmd-webhooks
- Config: cmd-config · cmd-service · cmd-env · cmd-promote
- Networking: cmd-ssl · cmd-trust · cmd-dns-setup
- Security: cmd-access · cmd-security · cmd-secrets
- Tenancy: cmd-tenant · cmd-billing
- Plugins: cmd-plugin · cmd-license · cmd-dogfood (extracted, CLI-R11) · cmd-k8s (extracted, CLI-R11) · cmd-encryption (extracted, CLI-R11) · cmd-waf (extracted, CLI-R11) · cmd-federation (extracted, CLI-R11) · cmd-mail (extracted, CLI-R11) · cmd-dlq (extracted, CLI-R11)
- AI: cmd-ai · cmd-claw · cmd-model
- Templates: cmd-template
- Utilities: cmd-exec · cmd-clean · cmd-reset · cmd-update · cmd-upgrade · cmd-version · cmd-admin · cmd-migrate · cmd-migrate-firebase · cmd-migrate-supabase · cmd-completion
Features
- Features, Overview
- Feature-Auth
- Feature-Storage
- Feature-Search
- Feature-Functions
- Feature-Email
- Feature-Monitoring
- Feature-Plugins
- Feature-nClaw, AI Assistant
- Feature-nChat, Messaging
- Feature-nFamily, Family Social
- Feature-nCloud, Managed Hosting
- Feature-Memory-Rooms, Knowledge Organization
- Feature-Agent-Dashboard, Agent Metrics
- Feature-Image-Generation, AI Image Generation
Configuration
- Configuration, Overview
- Config-Env-Vars
- Config-Postgres
- Config-Hasura
- Config-Auth
- Config-Nginx
- Shared-Proxy
- Config-Optional-Services
- Config-Custom-Services
- Config-System
Plugins (87 + 10 monitoring)
- Plugin-Overview
- Plugin-Catalog
- Plugin-Install
- Plugin-Licensing
- Plugin-Architecture
- Plugin-Dev-Guide
- Plugin-Migrations-Contract
Free (25)
- plugin-backup
- plugin-content-acquisition
- plugin-content-progress
- plugin-cron
- plugin-donorbox
- plugin-feature-flags
- plugin-github
- plugin-github-runner
- plugin-invitations
- plugin-jobs
- plugin-link-preview
- plugin-mdns
- plugin-mlflow
- plugin-monitoring
- plugin-notifications
- plugin-notify
- plugin-paypal
- plugin-search
- plugin-shopify
- plugin-stripe
- plugin-subtitle-manager
- plugin-tokens
- plugin-torrent-manager
- plugin-vpn
- plugin-webhooks
Pro (62)
- plugin-access-controls
- plugin-activity-feed
- plugin-admin-api
- plugin-analytics
- plugin-auth
- plugin-bots
- plugin-browser
- plugin-calendar
- plugin-cdn
- plugin-chat
- plugin-claw
- plugin-claw-budget
- plugin-claw-news
- plugin-claw-web
- plugin-cloudflare
- plugin-cms
- plugin-compliance
- plugin-ddns
- plugin-devices
- plugin-documents
- plugin-entitlements
- plugin-file-processing
- plugin-game-metadata
- plugin-geocoding
- plugin-geolocation
- plugin-google
- plugin-home
- plugin-idme
- plugin-knowledge-base
- plugin-linkedin
- plugin-livekit
- plugin-media-processing
- plugin-meetings
- plugin-moderation
- plugin-mux
- plugin-object-storage
- plugin-observability
- plugin-photos
- plugin-podcast
- plugin-post
- plugin-realtime
- plugin-retro-gaming
- plugin-rom-discovery
- plugin-social
- plugin-sports
- plugin-support
- plugin-tmdb
- plugin-voice
- plugin-web3
- plugin-workflows
Planned (26)
plugin-auditplugin-blogplugin-checkoutplugin-commerceplugin-drmplugin-exportplugin-flowplugin-importplugin-ldapplugin-mailgunplugin-mediaplugin-oauth-providersplugin-pagesplugin-postmarkplugin-rate-limitplugin-reportsplugin-samlplugin-schedulerplugin-sendgridplugin-ssoplugin-subscriptionplugin-thumbplugin-transcoderplugin-twilioplugin-wafplugin-watermark
Guides
- Guide-Production-Deployment
- Guide-SSL-Setup
- Guide-Multi-Tenancy
- Guide-Security-Hardening
- Guide-Monitoring-Setup
- Guide-Backup-Restore
- Guide-Custom-Services
- Guide-Migration-from-v1
Architecture
- Architecture
- Architecture-Guardrails
- Service-Graph
- Compose-Generation
- Nginx-Generation
- Plugin-Architecture
Reference
Machine interface
-
JSON-Output,
--jsonenvelope -
Command-Registry,
nself help --json - Exit-Codes
- error-codes, Error Codes
-
Compat-V15,
NSELF_V15gate
Licensing
Security
Brand
Operations
- operations/release-cascade, Release Cascade
- operations/self-healing, Self-Healing Schema
- operations/redis-tuning, Redis Pool Tuning
- operations/meilisearch-warmup, MeiliSearch Warm-Up
- operations/jwt-rotation, JWT Key Rotation
- operations/windows-wsl2-setup, Windows / WSL2 Setup
- operations/gemini-oauth-reauth, Gemini OAuth Reauth
Contributing
Admin
- USER-ACTION-QUEUE, Pending Admin Actions
All commands (21)
- A: cmd-add · cmd-admin
- B: cmd-backup · cmd-build
- C: cmd-clean · cmd-config
- D: cmd-db · cmd-deploy · cmd-doctor
- E: cmd-exec
- I: cmd-init
- L: cmd-license · cmd-logs
- M: cmd-mcp
- R: cmd-remove · cmd-reset · cmd-restart
- S: cmd-start · cmd-status · cmd-stop
- U: cmd-update