Letting AI agents talk to my site, with OAuth and scoped grants

I added an MCP server to my own site so an assistant can draft and publish only with the grants I have actually given it, and only after a confirm.

I wanted an assistant to be able to work on my site the same way I do in Studio: read a journal draft, write one, publish only when that is actually allowed. The way I did that was to expose a Model Context Protocol server on the site, and to put OAuth in front of it, with scoped grants.

This is how I think about that design, not a complete protocol walkthrough.

Why OAuth, and why scopes

An MCP tool is just a function with a name and a JSON schema. Without auth, that is a public remote control. With a single shared token, every caller has the same power, and there is no good way to later take one power away.

OAuth lets a person approve a connection and give that connection a set of grants. On my site, reading the journal is a different grant from writing a draft, and publishing is a different grant again. Publishing also requires an explicit confirm flag, a category, tags, and an article date. That is on purpose. A draft can be wrong. A publish should not be something a tool can do because it guessed.

Public clients, the kind an assistant runs as, need PKCE. I do not want a client secret sitting in a desktop app. The authorization code has to be bound to the client that started the login.

What I refused to automate

Automatic publication is off unless I turn on a very specific, owner-controlled path. A scheduled run can write a draft and send it for review. It should not be able to ship a post because a prompt was confident.

I also kept destructive tools behind confirm flags. Trash, restore, and anything that changes a published URL should be hard to do by accident. The assistant can prepare the work. A person still has to mean it.

What I would repeat on another site

If I added an agent API to another project, I would start with the same rules:

  • One grant per kind of power, not one "admin" switch.
  • Idempotency keys on creates, so a retry does not invent a second draft.
  • Validation errors that name the missing field, so the assistant can fix the request instead of guessing.
  • No secrets in tool output. Ever.
  • A written list of what the connection may do, visible to the person who approved it.

The interesting part of this work is not that an assistant can call an HTTP API. Plenty of apps can do that. The interesting part is that the API is willing to say no, in a way the assistant can understand, when the grant or the confirm is missing.

If you are building something similar, start with the official MCP authorization guidance and OAuth 2.1 practice, then add only the tools you are willing to see called when you are not in the room.

Back to Journal