Using mybase with AI agents
Connect coding agents (Claude Code, Cursor, VS Code, …) via MCP, llms.txt, the --json CLI, and `mybase agent init`.
mybase gives agents four ways in. Use as many as the agent supports.
1. MCP server
Streamable HTTP at https://mybase.example.com/mcp, authenticated with an API key. The tool list is filtered to what the key may do.
mybase token create agent --project shop --perm database:read,storage:read,queue:write,cron:write
export MYBASE_API_KEY=mb_…
claude mcp add --transport http mybase https://mybase.example.com/mcp --header "Authorization: Bearer $MYBASE_API_KEY"Or in .mcp.json (Cursor: .cursor/mcp.json); the key stays in the environment:
{
"mcpServers": {
"mybase": { "type": "http", "url": "https://mybase.example.com/mcp", "headers": { "Authorization": "Bearer ${MYBASE_API_KEY}" } }
}
}Tools: search_docs, read_doc, whoami, list_projects, get_project_context, create_project, enable_service, describe_schema, query_rows, run_sql (admin), list_files, list_cron_jobs, create_cron_job, run_cron_job, list_cron_runs, list_queues, create_queue, send_message, peek_messages, cache_command, list_ratelimit_rules, create_ratelimit_rule, analytics_stats, list_secret_envs, list_secret_keys, set_secrets, create_secret_env (names only; no tool returns a secret value). Docs pages are MCP resources (mybase://docs/<slug>), and prompts setup_project, add_queue_worker, add_cron_job, add_analytics, use_secrets walk through common tasks.
Deleting projects, turning services off, purging or deleting queues, and managing keys are not exposed over MCP. Those stay with the dashboard and CLI.
2. Docs for agents
https://mybase.example.com/llms.txt: index with a short "how to act" primer (llmstxt.org format)https://mybase.example.com/llms-full.txt: every page in one filehttps://mybase.example.com/docs/<slug>.md: one page as markdown, with this instance's URL filled inhttps://mybase.example.com/docs/search?q=<words>: best matching sections as JSONmybase docs,mybase docs <slug>,mybase docs --search "<words>"
3. CLI for scripts and agents
--jsonon any command prints the API's answer as JSON; errors are JSON on stderr:{"error", "status", "exitCode"}.- Exit codes: 0 ok, 1 failure, 2 usage (including a missing
--yes), 3 not signed in / bad key, 4 not found. - Without a terminal, destructive commands refuse to run unless
--yesis given; they never hang on a prompt. MYBASE_API_URL+MYBASE_TOKENconfigure it withoutmybase login.mybase context <project>prints the project as markdown (or JSON): services, tables and columns, jobs, queues, rules, env var names, docs to read.
4. mybase agent init
Run in an app repo:
mybase agent init --project shop # add --key to also make a project-limited key in .env.localIt writes (and on re-runs, replaces) a marked mybase section in AGENTS.md (and CLAUDE.md if the repo has one), a Claude Code skill at .claude/skills/mybase/SKILL.md, and a mybase entry in .mcp.json. --key writes the key to .env.local only if git ignores that file.
Agent notes
- Give agents the narrowest key that works.
run_sqland the SQL route needadmin. - Secrets in tool results (from
create_project,enable_servicefor the cache) are shown once: save them to the user's env right away.
Projects, keys, and permissions
How projects are isolated, how API keys and their permissions work, and which permission each action needs.
Database (Postgres)
Connect to a project's Postgres over TCP (LAN or, with a port forward, the internet) or WebSocket (Neon driver), browse tables, run SQL, and enable extensions.