notion-mcp-cli 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.js +2 -0
- package/dist/cli.d.ts +13 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +87 -0
- package/dist/cli.js.map +1 -0
- package/package.json +37 -0
package/bin.js
ADDED
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Notion MCP CLI with OAuth support.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* notioncli login # Save MCP URL and authenticate
|
|
7
|
+
* notioncli mcp notion-search # Search Notion
|
|
8
|
+
* notioncli mcp notion-fetch # Fetch a page
|
|
9
|
+
* notioncli status # Show current config
|
|
10
|
+
* notioncli logout # Clear OAuth tokens
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Notion MCP CLI with OAuth support.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* notioncli login # Save MCP URL and authenticate
|
|
7
|
+
* notioncli mcp notion-search # Search Notion
|
|
8
|
+
* notioncli mcp notion-fetch # Fetch a page
|
|
9
|
+
* notioncli status # Show current config
|
|
10
|
+
* notioncli logout # Clear OAuth tokens
|
|
11
|
+
*/
|
|
12
|
+
import { cac } from "@xmorse/cac";
|
|
13
|
+
import { addMcpCommands } from "mcpcac";
|
|
14
|
+
import fs from "node:fs";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import os from "node:os";
|
|
17
|
+
const CONFIG_DIR = path.join(os.homedir(), ".notioncli");
|
|
18
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
19
|
+
function loadConfig() {
|
|
20
|
+
if (!fs.existsSync(CONFIG_FILE)) {
|
|
21
|
+
return { mcpUrl: "https://mcp.notion.com/mcp" };
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(fs.readFileSync(CONFIG_FILE, "utf-8"));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return { mcpUrl: "https://mcp.notion.com/mcp" };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function saveConfig(config) {
|
|
31
|
+
const existing = loadConfig();
|
|
32
|
+
const merged = { ...existing, ...config };
|
|
33
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
34
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2));
|
|
37
|
+
}
|
|
38
|
+
const cli = cac("notion-mcp-cli");
|
|
39
|
+
// Add MCP commands with OAuth support
|
|
40
|
+
await addMcpCommands({
|
|
41
|
+
cli,
|
|
42
|
+
commandPrefix: "mcp",
|
|
43
|
+
clientName: "notioncli",
|
|
44
|
+
getMcpUrl: () => loadConfig().mcpUrl,
|
|
45
|
+
oauth: {
|
|
46
|
+
clientName: "Notion CLI",
|
|
47
|
+
load: () => loadConfig().oauthState,
|
|
48
|
+
save: (state) => {
|
|
49
|
+
saveConfig({ oauthState: state });
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
loadCache: () => loadConfig().cache,
|
|
53
|
+
saveCache: (cache) => {
|
|
54
|
+
saveConfig({ cache });
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
// Login command - just saves URL, auth happens on first tool call
|
|
58
|
+
cli
|
|
59
|
+
.command("login", "Save MCP URL and prepare for authentication")
|
|
60
|
+
.option("--url <url>", "MCP server URL", { default: "https://mcp.notion.com/mcp" })
|
|
61
|
+
.action((options) => {
|
|
62
|
+
saveConfig({ mcpUrl: options.url });
|
|
63
|
+
console.log(`Saved MCP URL: ${options.url}`);
|
|
64
|
+
console.log(`Config file: ${CONFIG_FILE}`);
|
|
65
|
+
console.log("\nRun any mcp command to authenticate (e.g., notioncli mcp notion-get-users)");
|
|
66
|
+
});
|
|
67
|
+
// Logout command
|
|
68
|
+
cli.command("logout", "Clear OAuth tokens and cache").action(() => {
|
|
69
|
+
saveConfig({ oauthState: undefined, cache: undefined });
|
|
70
|
+
console.log("Cleared OAuth state and cache");
|
|
71
|
+
});
|
|
72
|
+
// Status command
|
|
73
|
+
cli.command("status", "Show current config").action(() => {
|
|
74
|
+
const config = loadConfig();
|
|
75
|
+
const hasTokens = !!config.oauthState?.tokens;
|
|
76
|
+
const toolCount = config.cache?.tools?.length || 0;
|
|
77
|
+
console.log("Notion CLI Status");
|
|
78
|
+
console.log("─".repeat(40));
|
|
79
|
+
console.log(`MCP URL: ${config.mcpUrl}`);
|
|
80
|
+
console.log(`Logged in: ${hasTokens ? "Yes" : "No"}`);
|
|
81
|
+
console.log(`Tools cached: ${toolCount}`);
|
|
82
|
+
console.log(`Config file: ${CONFIG_FILE}`);
|
|
83
|
+
});
|
|
84
|
+
cli.help();
|
|
85
|
+
cli.version("0.0.1");
|
|
86
|
+
cli.parse();
|
|
87
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,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G,UAAU,EAAE,CAAC;IAC5B,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC;IAC9C,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC;IAEnD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACjC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,CAAC,gBAAgB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,gBAAgB,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,iBAAiB,SAAS,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,gBAAgB,WAAW,EAAE,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,IAAI,EAAE,CAAC;AACX,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AACrB,GAAG,CAAC,KAAK,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "notion-mcp-cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CLI for Notion MCP with OAuth support",
|
|
6
|
+
"bin": "bin.js",
|
|
7
|
+
"main": "./dist/cli.js",
|
|
8
|
+
"types": "./dist/cli.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"bin.js"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"notion",
|
|
15
|
+
"mcp",
|
|
16
|
+
"cli"
|
|
17
|
+
],
|
|
18
|
+
"author": "Tommaso De Rossi, morse <beats.by.morse@gmail.com>",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18.0.0"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@xmorse/cac": "^6.0.7",
|
|
25
|
+
"mcpcac": "^0.0.1"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^22.15.21",
|
|
29
|
+
"tsx": "^4.20.3",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc",
|
|
34
|
+
"dev": "tsx src/cli.ts",
|
|
35
|
+
"watch": "tsc -w"
|
|
36
|
+
}
|
|
37
|
+
}
|