Repository navigation
Guide Agents MCP
How to let an AI agent (Claude Code, Cursor, Codex) operate an nSelf project safely.
Reference pages: MCP-Tools, MCP-Server, HTTP-API-Reference, Agent-Guide, cmd-mcp.
Run this from inside an nSelf project:
nself mcp setup --client claude-code --write # doc-check: skip registered in cmd/commands/mcp_setup.go, tested by flag in mcp_setup_test.go--client also accepts cursor. The codex and generic clients print the config for you to paste. Without --write nothing is changed on disk.
Run one MCP server per project. Start nself mcp in the project's directory; its tools act on that project only. Started in a directory with no project yet, it serves nself_init and the read-only tools; once init has created the project it lists every tool and sends notifications/tools/list_changed, and it does the same after a plugin is added or removed (for example the ci tools after add ci). Do not point one server at several projects. If you work on two projects, register two servers, each started from its own project directory. Tool results then never mix up which stack was changed.
Tools mirror the command registry. The gate decides what an agent may do alone:
- Read and write commands run directly.
- Remote and destructive commands need a confirmation round trip. The first call returns
confirmation_requiredwith a plan id or nonce. The agent repeats the identical call with theconfirmvalue to run it. - A remote or destructive command with no confirm block is refused (E421).
- Secret values are redacted in request ids and error tails.
Prefer the dry-run form of a command before the confirmed one, and show the plan to a person before you confirm anything destructive. Details: MCP-Server.
For agents that speak HTTP instead of MCP, serve the same command surface on loopback:
nself admin serve --port 3857On loopback the server creates a machine token file and prints its path (never the token). Send the token from that file as a bearer header (Authorization: Bearer YOUR_TOKEN). Non-loopback binds refuse weak tokens and need an allowed host. See HTTP-API-Reference.
For MCP over HTTP, set the NSELF_MCP_TOKEN environment variable and start nself mcp --transport http.
These commands need the free ci plugin installed, so they are shown as text and are not run by the guide checker.
nself add ci
nself ci --check
nself ci
nself ci --check runs the gates only. nself ci also posts the nself-ci commit status. See Guide-CI-CD and the plugins CI Getting Started page.
The agent E2E harness proves an agent can run a whole project through MCP alone. It lives in test/e2e/agent/ (build tag e2eagent) and scripts/e2e/agent/.
What it covers:
- A replay client speaks MCP to
nself mcpand nothing else. It runsinit,build(plan, then confirm),start,db migrate up,add ci, an async CI run (detach, wait, evidence),deploy qa, thendeploy promote qa prodas a dry run and as a confirmed run. - Two legs: failure recovery (the harness stops one service, the agent reads
statusand recovers withstart) and the destructive gate (resetwithout a confirmation returns the confirmation request and no volume changes). -
qaandprodare two loopback sim hosts. The server runs in a sandbox: a tempHOMEholding only the sim key and ssh config, no SSH agent, and an allowlist of127.0.0.1for every host it may name. - Every request, result and harness action goes to a JSONL transcript, and a verifier checks it.
How to run it (shown as text; it needs Docker and a cli checkout):
bash scripts/e2e/agent/run.sh --self-test
bash scripts/e2e/agent/run.sh --replay --transcript /tmp/agent-e2e/replay.jsonl
bash scripts/e2e/agent/run.sh --verify-transcript /tmp/agent-e2e/replay.jsonl
The Agent E2E workflow runs the replay on GitHub-hosted ubuntu and uploads the transcript as agent-e2e-transcript. Details and known gaps: test/e2e/agent/README.md.
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
- Guide-Agents-MCP
- Guide-CI-CD
- Guide-SDK
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