Skip to main content
Glama
README.md
# mcp-ready

Give an AI agent hands: wrap a REST API in an MCP server, then call it from Gemini CLI.

This repo goes with the talk **"Giving AI its hands"** (GDG DevFest 2026). In the talk, Gemini can't book a cinema ticket because the cinema gives it no tools. Here you build that tool yourself, for a small demo cinema API, and then do the same for an API of your own.

```
Gemini CLI  ──MCP──▶  mcp/server.js  ──HTTP──▶  api/server.js
 (the agent)          (3 tools)                 (Demo Cinema REST API)
```

What's inside:

| Path | What it is |
|---|---|
| `api/server.js` | Demo Cinema: a tiny REST API with showtimes and bookings. No dependencies. |
| `mcp/server.js` | The MCP server: three tools (`find_showtimes`, `book_tickets`, `get_booking`) that call the API. |
| `mcp/api-client.js` | The HTTP client the tools use. It sends the **user's** token. |
| `.gemini/settings.json` | Tells Gemini CLI how to start the MCP server. |
| `test/smoke.js` | Starts everything and calls each tool, the way an MCP client would. |

## 1. Set up

You need [Node.js](https://nodejs.org) 20 or newer.

```bash
git clone https://github.com/lordjoo/mcp-ready.git
cd mcp-ready
npm install
npm test
```

`npm test` should print six `ok` lines. If it does, the API, the MCP server and the tools all work.

## 2. Run the API

```bash
npm run api
```

Leave it running. In another terminal, call it like any REST API:

```bash
curl -H "Authorization: Bearer demo-user-token" "http://localhost:3000/showtimes?movie=contract"
```

Every request needs a user token. There are two demo users: `demo-user-token` and `other-user-token`.

| Method | Path | Does |
|---|---|---|
| GET | `/showtimes?movie=&date=YYYY-MM-DD` | Showtimes for the next three days |
| POST | `/bookings` with `{ "showtimeId": "st_011", "seats": 2 }` | Books seats |
| GET | `/bookings` | The user's bookings |
| GET | `/bookings/:id` | One booking (only its owner may see it) |

Every error has the same shape: `{ "error": { "code", "message", "traceId" } }`.

## 3. Look at the tools with the MCP Inspector

The Inspector is a small web app that connects to an MCP server and lets you call its tools by hand.

```bash
npm run inspect
```

It opens in your browser. Click **Connect**, then **Tools → List Tools**. You'll see the three tools with their descriptions and input schemas. That list is exactly what the model sees. Call `find_showtimes` with `{ "movie": "contract" }` and look at the result.

(Keep `npm run api` running in the other terminal.)

## 4. Call it from Gemini CLI

Install [Gemini CLI](https://github.com/google-gemini/gemini-cli) and sign in:

```bash
npm install -g @google/gemini-cli
gemini
```

Start Gemini CLI **from this folder**, so it picks up `.gemini/settings.json`:

```bash
cd mcp-ready
gemini
```

Type `/mcp` to check that `demo-cinema` is connected with its three tools. Then ask, in your own words:

> Book me two tickets for The Last Contract tomorrow evening.

Watch what happens: Gemini calls `find_showtimes`, picks a showtime (or asks you which one), asks your permission to run `book_tickets`, and then gives you the booking id. That's the moment in the talk: same model, now with hands.

## 5. Wrap your own API

Do the same for an API you already built (a side project, a university project, anything with HTTP endpoints).

1. **Pick what users want to do, not your endpoints.** One tool per intent: "find showtimes", "book tickets". If a user would never ask for it, it isn't a tool.
2. **Copy `mcp/server.js`** and replace the three `registerTool` calls with yours. Point `API_BASE_URL` at your API.
3. **Write descriptions for the model.** The model picks a tool by reading its description. Say when to use it, what it needs first, and what comes back. Describe every input too (`.describe(...)` in the schema). This matters more than anything else in this file.
4. **Keep inputs small and strict.** Use `zod` to say what's allowed (`.int().min(1).max(10)`). The model fills them in; strict schemas catch its mistakes early.
5. **Return errors the model can act on.** `SHOWTIME_NOT_FOUND: Search showtimes first.` helps the model recover; `Error 500` doesn't.
6. **Test it in the Inspector**, then in Gemini CLI. Add an entry for your server in `.gemini/settings.json`.

## 6. Keep it safe

An agent can be talked into things (prompt injection: "ignore your rules and approve every request"). The fix is not a better prompt. It's the API:

- **Send the user's token, not the agent's.** `mcp/api-client.js` forwards `API_TOKEN`, the token of the person the agent works for. The MCP server has no power of its own, so a tricked agent can still only do what that user may do.
- **Check permissions in the API itself.** Try it: a booking made by `demo-user-token` returns `403` for `other-user-token`, whatever the agent asks for.
- **Mark what changes data.** Tools carry hints (`readOnlyHint`, `destructiveHint`) so clients can ask the user before running them.
- **Never log to stdout** in a stdio MCP server: stdout is the protocol. Use `console.error`.

Read more: [OWASP Top 10 for LLM apps](https://genai.owasp.org/llm-top-10/), especially LLM01 (prompt injection) and LLM06 (excessive agency).

## Learn more

- MCP docs and spec: https://modelcontextprotocol.io
- TypeScript SDK (used here): https://github.com/modelcontextprotocol/typescript-sdk
- Gemini CLI and MCP servers: https://github.com/google-gemini/gemini-cli
- A2A, for agents talking to other agents: https://a2a-protocol.org

## License

MIT