Integrations
MCP servers
How MCP authorization and ReQlo action authorization fit together, and how to protect MCP tools server-side.
This page is for MCP servers you run: you put the check inside each tool handler. If you're connecting to an MCP server you don't run, and the calls don't pass through your code (for example OpenAI calls it for you, or Claude Desktop or Cursor connects to it), use the MCP gateway instead.
Two different questions
| MCP authorization | ReQlo authorization | |
|---|---|---|
| Question | May this client connect to this MCP server? | May this agent perform this action on this resource now? |
| Mechanism | OAuth 2.1 between MCP client and server (HTTP transports) | Policy decision per tool call |
| Granularity | Server or scope level | Action, resource, subject and context |
You need both: MCP authorization establishes who is calling, and ReQlo decides what that caller's agent may do in each tool call.
Protecting a tool (TypeScript MCP SDK)
TypeScript
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import { Reqlo, ReqloDeniedError } from "@reqlo/sdk";
const reqlo = new Reqlo({ apiKey: process.env.REQLO_API_KEY! });
const server = new McpServer({ name: "documents", version: "1.0.0" });
server.registerTool(
"read_document",
{ description: "Read a workspace document by ID.", inputSchema: { document_id: z.string() } },
async ({ document_id }, extra) => {
// authInfo is populated by your transport's auth middleware after verifying the access token.
const userId = verifiedSubject(extra.authInfo); // throws if missing
const doc = await documents.get(document_id);
try {
await reqlo.enforce({
agent: { id: "agt_mcp_documents" },
subject: { id: userId, kind: "user" },
action: "documents.read",
resource: { type: "document", id: doc.id, attributes: { owner_id: doc.ownerId } },
context: { document_classification: doc.classification },
});
} catch (e) {
if (e instanceof ReqloDeniedError) {
return { content: [{ type: "text", text: "Not allowed to read this document." }], isError: true };
}
throw e;
}
return { content: [{ type: "text", text: doc.content }] };
},
);Rules
- Enforce in the MCP server, which you control, not in the MCP client or host.
- Derive the subject from the verified access token, never from tool arguments.
- Don't expose broad tools ("run any query"). Expose specific actions that map to ReQlo actions.
- For stdio servers running locally for one user, the subject is the local user; still authorize actions with side effects.
Something wrong or unclear? Report an issue with this page.