notion-mcp-server
Version:
Notion MCP server with token auth: connect Claude Code, Claude Desktop, Cursor, VS Code, Codex and any MCP client to Notion. Search, create and edit pages, query databases, comment and upload files. Runs headless in CI and agents.
20 lines (19 loc) • 846 B
JavaScript
// src/services/auth.ts
export class AuthError extends Error {
constructor(message) {
super(message);
this.name = "AuthError";
}
}
export class EnvAuthProvider {
async getToken() {
const t = process.env.NOTION_TOKEN;
if (!t) {
throw new AuthError("Notion auth token is not configured. Set the NOTION_TOKEN environment variable in your MCP client config. To get a token, open Notion → Settings → My Settings → Personal Access Tokens → Generate (recommended), or Settings → Connections → Develop or manage integrations → New integration.");
}
return t;
}
}
// Singleton — single-user assumption. v3 multi-user OAuth would require
// per-request provider dispatch (different pattern; out of scope for v2).
export const authProvider = new EnvAuthProvider();