# Lab 3 — IDE Integration + GitHub MCP

> **Summary — what this page covers**
> The hands-on MCP lab. Attendees wire Claude Code into their IDE, then connect and drive the
> GitHub MCP server against the BookTracker repo — querying issues/PRs and creating an issue
> through Claude. Note the network dependency up front and give an offline fallback.

**Duration: 65 min · Deliverable: a GitHub MCP session that queried the repo and created an issue**

> **Do this first:** creating the GitHub Personal Access Token in Part B is the slow step and needs
> the internet. If the network looks shaky, start the token now and use the [offline
> fallback](#offline-fallback) for the rest.

## Part A — IDE integration (≈20 min)

- Install the Claude Code integration for **your IDE** — VS Code
  (`code --install-extension anthropic.claude-code`) or **JetBrains/Rider** (Marketplace →
  "Claude Code" → restart).
- Make an edit through Claude and review it as an **inline diff** (VS Code) or in the **merge
  tool** (JetBrains); approve/reject.
- Confirm your `.claude/` config from Labs 1–2 (CLAUDE.md, rules, skill, hook) **still applies in
  the IDE** — same agent, same config, different diff/permission UI. (Open a file under
  `BookTracker.Api/Endpoints/` and check `/memory` shows the path-scoped rule.)
- **Resume your terminal session inside the IDE:** open the IDE's integrated terminal and run

  ```bash
  claude --continue
  ```

  You should land back in the same conversation, with the history from your terminal session intact
  — proof the session, not just the config, follows you across surfaces.

## Part B — Configure the GitHub MCP server (≈20 min)

**1. Create a GitHub Personal Access Token (the slow step).** GitHub → *Settings → Developer
settings → Personal access tokens*. A **classic** token with the **`repo`** scope is simplest; for a
fine-grained token, grant **Issues: read/write**, **Pull requests: read**, and **Contents: read** on
the BookTracker repo. Copy the token — you won't see it again.

**2. Register the server with Claude Code.** The remote GitHub MCP server needs no Docker — register
it over HTTP with your token:

```bash
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
  --header "Authorization: Bearer ghp_YOUR_TOKEN_HERE"
```

**3. Verify the connection:**

```bash
claude mcp list      # should show: github - connected
```

If it shows connected, Claude can now call GitHub's tools. If not, re-check the token scopes and that
you pasted it whole.

## Part C — Drive it (≈25 min)

Run these in sequence, checking each result against the real repo:

```text
List the open issues in this repo, sorted by creation date. Which look like good first
contributions, and why?
```

```text
Find the issues related to the Books API. For the top one, read the relevant source and
propose a concrete fix — don't implement it yet.
```

```text
Create an issue titled "Add GET /books/{id}/reviews endpoint". Include acceptance criteria,
the affected files, and a complexity estimate.
```

Watch the last one go through the **permission prompt** before it writes to GitHub — creating an
issue is a real, outward action, so Claude asks first.

## Checkpoint

- [ ] IDE shows Claude's edits as reviewable diffs
- [ ] `claude mcp list` shows `github` connected
- [ ] Claude listed real issues from the repo
- [ ] Claude **created** an issue in GitHub

## Offline fallback

If the network or GitHub is down, you can still practice the **query → action** pattern locally:

- **Query:** instead of the GitHub tools, have Claude read the repo's own history —
  `git log --oneline -20` and the existing files — and answer "what looks like a good first
  contribution?" from that.
- **Action:** instead of creating a remote issue, have Claude **write the issue to a local file**
  (e.g. `proposed-issues/reviews-endpoint.md`) with the same acceptance criteria, affected files,
  and complexity estimate. Same structured output, no network.
- Refer to the instructor's **recorded GitHub MCP demo** for the live version.
