> ## Documentation Index
> Fetch the complete documentation index at: https://docs.auditynow.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code

> Connect Audity to Claude Code via MCP (recommended) or call the REST API directly without any connector setup.

## Two paths

|                         | MCP via config file                              | Direct API via CLAUDE.md                                |
| ----------------------- | ------------------------------------------------ | ------------------------------------------------------- |
| **Tool calling**        | Typed tools with full schemas                    | Claude constructs curl commands from a text description |
| **Setup**               | 3-line JSON config                               | Env var + CLAUDE.md snippet                             |
| **External dependency** | Requires docs.auditynow\.com/mcp to be reachable | None                                                    |
| **Best for**            | Most users                                       | Air-gapped environments, zero-dependency setups         |

## Option A: MCP via config file (recommended)

Claude Code has native MCP support via a config file. No GUI, no OAuth dance -- just JSON.

### 1. Get a Personal Access Token

Go to **Settings → API Tokens** in your Audity workspace and create a token with **Read + Write** scopes. It starts with `aky_` and is shown only once.

### 2. Add the MCP server config

Create or edit `.claude/mcp_servers.json`. Project-level (`.claude/mcp_servers.json` in your project root) takes precedence over global (`~/.claude/mcp_servers.json`); use global for access across all projects:

```json theme={null}
{
  "mcpServers": {
    "audity": {
      "url": "https://docs.auditynow.com/mcp",
      "headers": {
        "Authorization": "Bearer aky_your_token_here"
      }
    }
  }
}
```

Or use the CLI to add it without editing JSON:

```bash theme={null}
claude mcp add audity \
  --url https://docs.auditynow.com/mcp \
  --header "Authorization: Bearer aky_your_token_here"
```

### 3. Reload and test

Run `claude mcp reload` to pick up the new config, then start a new session (reload alone doesn't refresh an active session). Try:

```text theme={null}
List my Audity projects.
```

Claude Code will call the `listProjects` tool and return your real projects. You now have the Audity operations as first-class tools, with typed parameters and schema validation.

**Common tools:** `getCurrentUser`, `getCurrentTier`, `getCredits`, `listProjects`, `createProject`, `getProject`, `patchProject`, `triggerAuditAnalysis`, `triggerAsyncAuditAnalysis`, `getJobStatus`, `getAuditAnalysis`, `listOpportunities`, `getDeliverables`, `listLeads`, `getLead`, `convertLead`, `listMemories`, `createMemory`, `deleteMemory`, `listCaptures`, `createCaptureNote`, `getCapture`, `reprocessCapture`, `deleteCapture`, `listContacts`, `createContact`, `updateContact`, `deleteContact`, `listInsights`, and `getSuggestions`. The exact list follows the OpenAPI spec and may grow as new endpoints ship.

***

## Option B: Direct API via CLAUDE.md (no external dependencies)

If you need zero external dependencies, or docs.auditynow\.com isn't reachable in your environment, Claude Code can call the Audity REST API directly using its built-in Bash tool. The tradeoff is that Claude constructs curl commands from a text description rather than having typed tool schemas.

### 1. Set your token as an environment variable

Add this to your shell profile (`.zshrc`, `.bashrc`, etc.) for persistent access:

```bash theme={null}
export AUDITY_TOKEN="aky_your_token_here"
```

Reload your shell or run `source ~/.zshrc` to pick it up immediately. For a one-off session without editing your profile:

```bash theme={null}
AUDITY_TOKEN="aky_your_token_here" claude
```

### 2. Add the Audity context to your CLAUDE.md

Copy this block into your global `~/.claude/CLAUDE.md` (or your project's `CLAUDE.md`). Claude Code reads this file at the start of every session.

```markdown theme={null}
## Audity API

Base URL: https://app.auditynow.com
Auth: pass `Authorization: Bearer $AUDITY_TOKEN` on every request
Full spec: https://docs.auditynow.com/api-reference/openapi.json

Key endpoints:
- GET  /api/user/current                        verify token
- GET  /api/user/credits                        credit balance
- GET  /api/projects                            list all projects
- POST /api/projects                            create project (1,000 credits)
- GET  /api/projects/{id}                       project detail
- POST /api/projects/{id}/audit-analysis        run synthesis (60-300s, use --max-time 360)
- POST /api/agent/projects/{id}/audit-analysis/async  start async synthesis (requires current document + interview analyses)
- GET  /api/agent/jobs/{id}                     poll async synthesis status
- GET  /api/projects/{id}/opportunities         AI-generated opportunities
- GET  /api/projects/{id}/deliverables          full deliverable output
- GET  /api/lead-generation/leads               list ReadyLink leads
- POST /api/lead-generation/leads/{id}/convert  convert lead to project (1,000 credits)
- POST /api/nucleus/capture/note                submit a text note or transcript
- GET  /api/nucleus/memories                    search persistent client knowledge
- GET  /api/nucleus/contacts                    lightweight CRM contacts

Errors worth handling:
- 401 PAT_MALFORMED: token format wrong, regenerate
- 401 (no code): token revoked or not found
- 403 PAT_SCOPE_INSUFFICIENT: need a write-scoped token
- 429: rate limited, honor Retry-After header
- Audit synthesis is long-running; use --max-time 360 for the synchronous endpoint. Use the async endpoint plus job polling only when the project already has current document and interview analyses.
```

***

## Example prompts (both options)

```text theme={null}
List my Audity projects and show me which ones have completed analysis.
```

```text theme={null}
Create a new Audity project for "Meridian Healthcare", healthcare industry,
50-200 employees. Run the audit analysis. When it finishes, summarize the
top three opportunities by impact score.
```

```text theme={null}
Pull my Audity leads from this week with an AI readiness score above 70.
Show me the business name, score, and survey status for each.
```

```text theme={null}
Search my Audity Nucleus memories for anything tagged as a client pattern
across healthcare engagements. Include confidence scores.
```

## Troubleshooting

<AccordionGroup>
  <Accordion title="Claude Code says Audity tools aren't available (MCP path)">
    Run `claude mcp list` to confirm the server is registered. If it's missing, re-add it. If it's listed but tools don't appear, run `claude mcp reload` and start a new session. Check that `docs.auditynow.com/mcp` is reachable from your network.
  </Accordion>

  <Accordion title="Claude says it doesn't know the Audity API (CLAUDE.md path)">
    The CLAUDE.md entry isn't being picked up. Confirm the file is at `~/.claude/CLAUDE.md` (global) or at the root of your project directory. Start a new Claude Code session after saving the file.
  </Accordion>

  <Accordion title="401 on every request">
    Run `echo $AUDITY_TOKEN` in your terminal. If it's empty, the env var isn't set in this shell session. Add the export to your shell profile and reload, or prefix the session with `AUDITY_TOKEN=aky_... claude`.
  </Accordion>

  <Accordion title="Audit synthesis times out">
    The synthesis pipeline runs for 60-300 seconds. If you're hitting a timeout, ask Claude to run the curl with `--max-time 360` explicitly. If the project already has current document and interview analyses, use `POST /api/agent/projects/{id}/audit-analysis/async` and poll `GET /api/agent/jobs/{jobId}` until it returns `completed` or `failed`.
  </Accordion>

  <Accordion title="403 PAT_SCOPE_INSUFFICIENT">
    Your token was created with read-only scope. Go to **Settings → API Tokens**, revoke it, and create a new one with **Read + Write** selected.
  </Accordion>
</AccordionGroup>

## What's next

* [Run a full audit workflow](/guides/running-an-audit), the end-to-end recipe from intake to deliverables
* [Working with Nucleus](/guides/working-with-nucleus), memories, captures, insights, contacts
* [Authentication](/authentication), token scopes, rotation, error codes
