# AI Agent Access (MCP)

AI Agent Access lets AI assistants work with your NewInstance data safely. The **Model Context Protocol (MCP)** is the open standard AI tools use to call external systems; Claude Desktop/Code, IDE agents and agent frameworks all speak it.

There are two ways to connect an agent to the same endpoint:

- **Sign in as yourself.** The agent connects with no key, you sign in once in your browser and approve it, and it works in every organization you belong to with your own permissions. See the [Sign in as yourself](/sign-in-as-yourself) page in this folder.
- **API key.** For servers and automation. The agent sends a server API key and works in the one organization that owns the key: it can list your BugWatch projects, browse issues, and run the platform's AI root-cause analysis, scoped to exactly what the key allows.

## With an API key

One endpoint, stateless JSON-RPC 2.0:

```http
POST https://service.newinstance.cloud/mcp
x-api-key: sk_live_KEYID:secret        (or Authorization: Bearer KEYID:secret)
Content-Type: application/json
Accept: application/json, text/event-stream
```

- **Server keys only.** Publishable widget keys (bare key ID) are rejected with `401` / JSON-RPC `-32001`.
- **Org scoping is automatic**: with a key, every tool runs against the organization that owns the key; there is no way to pass another organization.
- **Scope-filtered tools**: a key sees only tools for products in its scopes (`FULL_ACCESS` sees all).
- **Stateless**: each POST is independent; no session handshake is required (send `initialize` only if your client library insists). GET/DELETE return `405`.
- Responses stream back as a single SSE frame (`data: {…}`); parse the `data:` line as JSON.

**Tools with an API key (BugWatch):** `bugwatch_list_projects`, `bugwatch_list_issues`, `bugwatch_root_cause_analysis`.

Claude Desktop config example:
```json
{ "mcpServers": { "newinstance": {
    "url": "https://service.newinstance.cloud/mcp",
    "headers": { "x-api-key": "sk_live_KEYID:secret" } } } }
```

**POST /mcp**: List available tools (fetch id `endpoint:6ae152d083f212a997c813d2`)
