# MCP server

> Give Claude Code, Codex or any MCP agent your spend, budgets, usage, models and teams as tools under your own sign-in, and let an admin manage the organization through them.

`nexus mcp` is a local [Model Context Protocol](https://modelcontextprotocol.io) server. An agent starts it and uses
Nexus through it as tools. Every tool is one operation of the [API](/docs/api), sent with your CLI sign-in, so the
agent sees and does exactly what you may. Most tools read. Owners and admins also get tools that change the
organization, and the agent asks you before each change.

## Set up

1. Install the CLI and [sign in](/docs/authentication) with `nexus auth login`. The server uses that sign-in.
2. Add the server to your agent, once:

   ```sh
   claude mcp add nexus -- nexus mcp     # Claude Code
   codex mcp add nexus -- nexus mcp      # Codex
   ```

   Any other agent takes the same command in its MCP settings: `nexus` with the argument `mcp`, over stdio.

3. Ask the agent something the tools answer, such as "How much of my budget is left this month?".

The server signs in as you, in the organization you last chose with `nexus org switch`. To use another organization,
switch the CLI first, then restart the agent.

## The tools

Each tool has the name, arguments and answer of its API operation, and the same [permission](/docs/concepts/permissions).
A tool whose operation takes a JSON request body takes it as the argument `body`.

| Tool | What it reads | API |
| --- | --- | --- |
| `currentTenant` | Your organization, your role and your permissions | [`GET /v1/tenants/me`](/docs/api/core#current-tenant) |
| `spend` | Budget, spend and reservations by product, with recent calls | [`GET /v1/spend`](/docs/api/core#spend) |
| `listBudgets` | Monthly spend limits: yours, or everyone's for owners and admins | [`GET /v1/budgets`](/docs/api/budgets#list-budgets) |
| `getPersonBudget` | One person's limit this month (`me` for yours) | [`GET /v1/people/{userId}/budget`](/docs/api/budgets#get-person-budget) |
| `getTeamBudget` | A team's cap, as you may see it | [`GET /v1/teams/{slug}/budget`](/docs/api/teams#get-team-budget) |
| `usage` | Usage over a date range, grouped by team, person, model, provider, product or day | [`GET /v1/analytics/usage`](/docs/api/analytics#usage) |
| `getAgentAdoption` | Who used coding agents through Nexus, day by day | [`GET /v1/analytics/agents`](/docs/api/analytics#get-agent-adoption) |
| `getChatUsage` | Chat sessions in numbers, never their content | [`GET /v1/analytics/chat`](/docs/api/analytics#get-chat-usage) |
| `listModels` | The models you may use, with context windows and prices | [`GET /v1/models`](/docs/api/models#list-models) |
| `listTeams` | The organization's teams, as a list or a tree | [`GET /v1/teams`](/docs/api/teams#list-teams) |
| `getTeam` | A team, its members and its child teams | [`GET /v1/teams/{slug}`](/docs/api/teams#get-team) |
| `listAgentSessions` | Coding-agent sessions, newest first | [`GET /v1/agents/sessions`](/docs/api/agents#list-agent-sessions) |
| `getAgentSession` | One coding-agent session | [`GET /v1/agents/sessions/{id}`](/docs/api/agents#get-agent-session) |
| `modules` | The products and capabilities your Gateway registers | [`GET /v1/modules`](/docs/api/core#modules) |

### Ask your agent

The `ask` tool asks your own Nexus agent a question and returns its answer, the model that ran and its cost. It is
the one tool that is not an API operation. It answers on a model your policy allows, `nexus/auto` unless the agent
names one.

`ask` never makes a change. It runs no tool, so it cannot write or confirm a write. When a change is needed, the
answer says so, and you confirm the change yourself in Slack or Nexus UI. Gateway records each call from the surface
`mcp`.

### Review before a pull request

`nexus mcp` also has `review_local`, which needs the machine the server runs on. It reviews the change in your working
tree against its merge base with the remote default branch. It uses the repository's own review
rules and spends your model budget. It posts nothing, and answers the findings and whether one would fail the check. It
reads only folders inside the one `nexus mcp` runs in. It is not marked read-only, so the agent asks you before each
call. A run can take several minutes.

### Connectors

These tools reach outside systems such as GitHub or Jira through Nexus. Call `describeConnector` first. It lists each
operation with its `effect` and the schema of its `body`. Its `usable` field says whether you may use the connector.
`readConnector` and `writeConnector` run only connectors your organization made available to you. `readConnector`
runs only operations that read, so you may approve it once. `writeConnector` runs a change, and the agent asks you
before each call. People cannot make changes through connectors yet, so it refuses them for now. A `readConnector`
answer longer than 50,000 characters is cut there, with a note that starts with `answer_cut`. Ask the agent for a
page, a limit or a filter where the operation takes one. Each connector answer starts with a `connector_data` note: the text comes from an
outside system, so the agent treats it as data, not instructions.

| Tool | What it does | API |
| --- | --- | --- |
| `describeConnector` | One connector's operations, what each changes, and its arguments | [`GET /v1/connectors/{name}`](/docs/api/connectors#describe-connector) |
| `readConnector` | Run one operation that only reads | [`POST /v1/connectors/{name}/{operation}/read`](/docs/api/connectors#read-connector) |
| `writeConnector` | Run one operation that changes something | [`POST /v1/connectors/{name}/{operation}`](/docs/api/connectors#write-connector) |

### Your notifications

Everyone can read their own inbox and clear an item from it. `doneNotification` is a change, so the agent asks you
before each call.

| Tool | What it does | API |
| --- | --- | --- |
| `listNotifications` | Your inbox: items not yet done, newest first | [`GET /v1/notifications`](/docs/api/core#list-notifications) |
| `doneNotification` | Mark one of your items done, so it leaves the inbox | [`POST /v1/notifications/{id}/done`](/docs/api/core#done-notification) |

### Pages

These tools let an agent publish a [page](/docs/guides/artifacts) it wrote, read it back, read the design system it
uses and run Check on it. The page is private to your organization's Gateway until you share it, and there is no tool
to share a page. `createPage` and `writePageVersion` are changes, so the agent asks you before each call. The rest
only read. Nexus for desktop gives them to its Code sessions, which may have no `nexus` command to run
`nexus pages publish`.

| Tool | What it does | API |
| --- | --- | --- |
| `createPage` | Publish a new page from HTML or Markdown | [`POST /v1/pages`](/docs/api/pages#create-page) |
| `writePageVersion` | Write the next version of one of your pages | [`POST /v1/pages/{id}/versions`](/docs/api/pages#write-page-version) |
| `listPages` | Your pages, most recently written first | [`GET /v1/pages`](/docs/api/pages#list-pages) |
| `getPage` | One page and its versions: titles and sizes, not content | [`GET /v1/pages/{id}`](/docs/api/pages#get-page) |
| `getPageSource` | A version's source as text, to edit and write back (`latest` is the newest) | [`GET /v1/pages/{id}/versions/{version}/source`](/docs/api/pages#get-page-source) |
| `listPageComments` | The comments on a page | [`GET /v1/pages/{id}/comments`](/docs/api/pages#list-page-comments) |
| `checkPage` | Run Check on a design: colours, sizes and spacing off its tokens, and low contrast | [`POST /v1/pages/{id}/check`](/docs/api/pages#check-page) |
| `listDesignSystems` | The organization's design systems, the built-in `@nexus/brand` first | [`GET /v1/design-systems`](/docs/api/design-systems#list-design-systems) |
| `getDesignSystem` | One design system: its tokens, notes and components | [`GET /v1/design-systems/{id}`](/docs/api/design-systems#get-design-system) |

### For owners and admins

These tools read the whole organization. Most answer owners and admins only, and the billing tools answer the owner
only. Anyone else gets Gateway's refusal, or only their own part, as the API answers them.

| Tool | What it reads | API |
| --- | --- | --- |
| `listOrgs` | Your organizations and your role in each | [`GET /v1/orgs`](/docs/api/organizations#list-orgs) |
| `getOrgSettings` | The organization's settings, such as how long chats are kept | [`GET /v1/orgs/settings`](/docs/api/organizations#get-org-settings) |
| `listOrgDomains` | The organization's verified email domains | [`GET /v1/orgs/domains`](/docs/api/organizations#list-org-domains) |
| `listMembers` | Members and their roles, with each person's spend | [`GET /v1/orgs/members`](/docs/api/organizations#list-members) |
| `listPendingTeamMembers` | People added to a team by an email that has not joined yet | [`GET /v1/teams/pending`](/docs/api/teams#list-pending-team-members) |
| `listAuditEvents` | Who changed what, newest first | [`GET /v1/audit`](/docs/api/audit#list-audit-events) |
| `listSpendCalls` | The organization's model calls, newest first, with filters | [`GET /v1/spend/calls`](/docs/api/core#list-spend-calls) |
| `getSpendCall` | One model call: what was reserved and charged, or why it was refused | [`GET /v1/spend/calls/{id}`](/docs/api/core#get-spend-call) |
| `getOrganizationPolicy` | The organization's model policy | [`GET /v1/policies/organization`](/docs/api/models#get-organization-policy) |
| `getTeamPolicy` | A team's model policy and what it inherits | [`GET /v1/policies/teams/{slug}`](/docs/api/models#get-team-policy) |
| `getAgentPolicy` | A coding agent's model policy | [`GET /v1/policies/agents/{agent}`](/docs/api/models#get-agent-policy) |
| `listOperatorControls` | The pauses, limits and overrides in force | [`GET /v1/policies/controls`](/docs/api/models#list-operator-controls) |
| `listWriteGrants` | Which module may write through which connector operation | [`GET /v1/policies/grants`](/docs/api/models#list-write-grants) |
| `listProviderKeys` | The organization's own provider keys, last four characters only | [`GET /v1/keys/providers`](/docs/api/core#list-provider-keys) |
| `getProviderKey` | One provider key and its versions, never its value | [`GET /v1/keys/providers/{provider}`](/docs/api/core#get-provider-key) |
| `listTokens` | Live tokens: yours, or everyone's with `all` | [`GET /v1/auth/tokens`](/docs/api/auth#list-tokens) |
| `getBilling` | The payment method and Stripe customer (the owner only) | [`GET /v1/billing`](/docs/api/organizations#get-billing) |
| `listBillingStatements` | The stored monthly statements (the owner only) | [`GET /v1/billing/statements`](/docs/api/organizations#list-billing-statements) |
| `getBillingStatement` | A month's bill (the owner only) | [`GET /v1/billing/statement`](/docs/api/organizations#get-billing-statement) |
| `connectors` | The connectors Gateway offers and their operations | [`GET /v1/connectors`](/docs/api/connectors#connectors) |
| `listRepositories` | GitHub installations and linked repositories | [`GET /v1/github/repositories`](/docs/api/github#list-repositories) |
| `githubApp` | Whether the GitHub App is set up, and its install link | [`GET /v1/github/app`](/docs/api/github#github-app) |

### Changes, for owners and admins

These tools change the organization. Each one is the API call itself, so Gateway checks your permission and records
the change in the [audit log](/docs/api/audit#list-audit-events). No change tool is marked read-only, so Claude Code
and Codex ask you before each call. Keep that prompt on for these tools.

The API's own guards still apply. `inviteMembers` needs `expect`, the count you confirmed, to invite more than one
person. `importTeams` applies only the `plan` that its dry run returned.

| Tool | What it changes | API |
| --- | --- | --- |
| `inviteMembers` | Invite people by email, as members or admins | [`POST /v1/orgs/invitations`](/docs/api/organizations#invite-members) |
| `setMemberRole` | Make a member an admin, or an admin a member | [`POST /v1/orgs/members/{userId}/role`](/docs/api/organizations#set-member-role) |
| `removeMember` | Remove a member and revoke their tokens | [`DELETE /v1/orgs/members/{userId}`](/docs/api/organizations#remove-member) |
| `transferOwnership` | Make another member the owner (the owner only) | [`POST /v1/orgs/owner`](/docs/api/organizations#transfer-ownership) |
| `setOrgSettings` | The organization's settings, such as how long chats are kept | [`PUT /v1/orgs/settings`](/docs/api/organizations#set-org-settings) |
| `addOrgDomain` | Add a verified email domain | [`POST /v1/orgs/domains`](/docs/api/organizations#add-org-domain) |
| `removeOrgDomain` | Remove a verified email domain | [`DELETE /v1/orgs/domains/{id}`](/docs/api/organizations#remove-org-domain) |
| `setBudget` | The organization's budget | [`POST /v1/orgs/budget`](/docs/api/organizations#set-budget) |
| `createTeam` | Create a team, optionally under a parent | [`POST /v1/teams`](/docs/api/teams#create-team) |
| `updateTeam` | Rename, relabel or move a team | [`PATCH /v1/teams/{slug}`](/docs/api/teams#update-team) |
| `deleteTeam` | Delete a team | [`DELETE /v1/teams/{slug}`](/docs/api/teams#delete-team) |
| `addTeamMember` | Add someone to a team, by user id or email | [`POST /v1/teams/{slug}/members`](/docs/api/teams#add-team-member) |
| `removeTeamMember` | Take someone off a team | [`DELETE /v1/teams/{slug}/members/{userId}`](/docs/api/teams#remove-team-member) |
| `importTeams` | Load teams from a file, after a dry run | [`POST /v1/teams/import`](/docs/api/teams#import-teams) |
| `cancelPendingTeamMembers` | Cancel pending team members | [`DELETE /v1/teams/pending`](/docs/api/teams#cancel-pending-team-members) |
| `setDefaultTeam` | A person's default team | [`PUT /v1/people/{userId}/default-team`](/docs/api/teams#set-default-team) |
| `setTeamBudget` | A team's cap per day, week or month | [`PUT /v1/teams/{slug}/budget`](/docs/api/teams#set-team-budget) |
| `setPersonBudget` | One person's monthly limit | [`PUT /v1/people/{userId}/budget`](/docs/api/budgets#set-person-budget) |
| `setPersonDefaultBudget` | Everyone's default monthly limit | [`PUT /v1/budgets/person-default`](/docs/api/budgets#set-person-default-budget) |
| `setOrganizationPolicy` | The organization's model policy | [`PUT /v1/policies/organization`](/docs/api/models#set-organization-policy) |
| `setTeamPolicy` | A team's model policy | [`PUT /v1/policies/teams/{slug}`](/docs/api/models#set-team-policy) |
| `setAgentPolicy` | A coding agent's model policy | [`PUT /v1/policies/agents/{agent}`](/docs/api/models#set-agent-policy) |
| `setOperatorControl` | Pause, limit or override models for a subject | [`POST /v1/policies/controls`](/docs/api/models#set-operator-control) |
| `clearOperatorControl` | End an operator control | [`DELETE /v1/policies/controls/{id}`](/docs/api/models#clear-operator-control) |
| `setWriteGrants` | The connector writes a module may make | [`PUT /v1/policies/grants/{product}/{capability}`](/docs/api/models#set-write-grants) |
| `testPolicy` | Check whether a person may use a model, and by which rule (changes nothing) | [`POST /v1/policies/test`](/docs/api/models#test-policy) |
| `enableProviderKey` | Turn a disabled provider key back on | [`POST /v1/keys/providers/{provider}/enable`](/docs/api/core#enable-provider-key) |
| `disableProviderKey` | Stop calls from using a provider key | [`POST /v1/keys/providers/{provider}/disable`](/docs/api/core#disable-provider-key) |
| `removeProviderKey` | Remove a provider key | [`POST /v1/keys/providers/{provider}/remove`](/docs/api/core#remove-provider-key) |
| `revokeToken` | Revoke a token: yours, or anyone's | [`DELETE /v1/auth/tokens/{id}`](/docs/api/auth#revoke-token) |
| `revokeScopedKey` | Revoke a module's scoped key before it expires | [`POST /v1/auth/scoped-keys/revoke`](/docs/api/auth#revoke-scoped-key) |
| `unlinkInstallation` | Unlink a GitHub installation | [`DELETE /v1/github/installations/{id}`](/docs/api/github#unlink-installation) |

Chats and artifacts are not tools, and no tool reads a page, so a prompt an agent reads cannot ask it to pass them
on. When Nexus refuses a call, the agent gets the refusal as a tool error with Gateway's status, code and message, as
the API sends it.

Adding or replacing a provider key and creating an API key are not tools, because the secret would stay in the
agent's transcript. Use `nexus keys add` or `nexus keys replace` for a provider key, and Nexus UI for an API key.

## Not yet

Approvals that Nexus enforces on an agent's change, and a remote server that signs in through your browser, are
planned.
