@n24q02m/better-notion-mcp 2.3.11 → 2.3.13-beta.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/LICENSE +21 -21
- package/README.md +40 -76
- package/bin/cli.mjs +6 -6
- package/build/src/tools/composite/databases.js +13 -16
- package/build/src/tools/composite/databases.js.map +1 -1
- package/build/src/tools/composite/pages.js +11 -12
- package/build/src/tools/composite/pages.js.map +1 -1
- package/build/src/tools/helpers/batch.d.ts +9 -0
- package/build/src/tools/helpers/batch.d.ts.map +1 -0
- package/build/src/tools/helpers/batch.js +17 -0
- package/build/src/tools/helpers/batch.js.map +1 -0
- package/build/src/tools/helpers/errors.d.ts.map +1 -1
- package/build/src/tools/helpers/errors.js +21 -3
- package/build/src/tools/helpers/errors.js.map +1 -1
- package/build/src/tools/helpers/errors.test.d.ts +2 -0
- package/build/src/tools/helpers/errors.test.d.ts.map +1 -0
- package/build/src/tools/helpers/errors.test.js +33 -0
- package/build/src/tools/helpers/errors.test.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 n24q02m
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 n24q02m
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,35 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
**Markdown-First MCP Server for Notion - Optimized for AI Agents**
|
|
4
4
|
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://www.npmjs.com/package/@n24q02m/better-notion-mcp)
|
|
5
|
+
[](https://www.npmjs.com/package/@n24q02m/better-notion-mcp)
|
|
8
6
|
[](https://hub.docker.com/r/n24q02m/better-notion-mcp)
|
|
7
|
+
[](LICENSE)
|
|
9
8
|
|
|
10
9
|
## Why "Better"?
|
|
11
10
|
|
|
12
|
-
**
|
|
11
|
+
**8 composite tools** that consolidate Notion's 28+ REST API endpoints into action-based operations optimized for AI agents.
|
|
13
12
|
|
|
14
13
|
### vs. Official Notion MCP Server
|
|
15
14
|
|
|
16
|
-
| Feature
|
|
17
|
-
|
|
18
|
-
| **Content Format**
|
|
19
|
-
| **Operations**
|
|
20
|
-
| **Pagination**
|
|
21
|
-
| **Bulk Operations**
|
|
22
|
-
| **
|
|
23
|
-
| **
|
|
24
|
-
| **Token Efficiency** | **Optimized for AI context** | Standard API responses |
|
|
25
|
-
| **Setup** | Simple (NOTION_TOKEN only) | OAuth flow or token |
|
|
15
|
+
| Feature | Better Notion MCP | Official Notion MCP |
|
|
16
|
+
|---------|-------------------|---------------------|
|
|
17
|
+
| **Content Format** | **Markdown** (human-readable) | Raw JSON blocks |
|
|
18
|
+
| **Operations** | **Composite actions** (1 call) | Atomic (2+ calls) |
|
|
19
|
+
| **Pagination** | **Auto-pagination** | Manual cursor |
|
|
20
|
+
| **Bulk Operations** | **Native batch support** | Loop manually |
|
|
21
|
+
| **Tools** | **8 tools** (30+ actions) | 28+ endpoint tools |
|
|
22
|
+
| **Token Efficiency** | **Optimized** | Standard |
|
|
26
23
|
|
|
27
24
|
---
|
|
28
25
|
|
|
29
|
-
##
|
|
26
|
+
## Quick Start
|
|
30
27
|
|
|
31
|
-
Get your
|
|
32
|
-
|
|
33
|
-
### Quick Start
|
|
28
|
+
Get your token: <https://www.notion.so/my-integrations> → Create integration → Copy token → Share pages
|
|
34
29
|
|
|
35
30
|
### NPX (Recommended)
|
|
36
31
|
|
|
@@ -66,95 +61,64 @@ Get your Notion token: <https://www.notion.so/my-integrations> → Create integr
|
|
|
66
61
|
|
|
67
62
|
---
|
|
68
63
|
|
|
69
|
-
## Tools
|
|
70
|
-
|
|
71
|
-
**7 mega tools with 30+ actions:**
|
|
64
|
+
## Tools
|
|
72
65
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
| Tool | Actions |
|
|
67
|
+
|------|---------|
|
|
68
|
+
| `pages` | create, get, update, archive, restore, duplicate |
|
|
69
|
+
| `databases` | create, get, query, create_page, update_page, delete_page, create_data_source, update_data_source, update_database |
|
|
70
|
+
| `blocks` | get, children, append, update, delete |
|
|
71
|
+
| `users` | list, get, me, from_workspace |
|
|
72
|
+
| `workspace` | info, search |
|
|
73
|
+
| `comments` | list, create |
|
|
74
|
+
| `content_convert` | markdown-to-blocks, blocks-to-markdown |
|
|
75
|
+
| `help` | Get full documentation for any tool |
|
|
77
76
|
|
|
78
77
|
---
|
|
79
78
|
|
|
80
|
-
## Token Optimization
|
|
79
|
+
## Token Optimization
|
|
81
80
|
|
|
82
81
|
**~77% token reduction** via tiered descriptions:
|
|
83
82
|
|
|
84
|
-
| Tier | Purpose |
|
|
85
|
-
|
|
86
|
-
| **Tier 1** | Compressed descriptions
|
|
87
|
-
| **Tier 2** | Full docs via `help` tool
|
|
88
|
-
| **Tier 3** | MCP Resources
|
|
83
|
+
| Tier | Purpose | When |
|
|
84
|
+
|------|---------|------|
|
|
85
|
+
| **Tier 1** | Compressed descriptions | Always loaded |
|
|
86
|
+
| **Tier 2** | Full docs via `help` tool | On-demand |
|
|
87
|
+
| **Tier 3** | MCP Resources | Supported clients |
|
|
89
88
|
|
|
90
|
-
**Usage:**
|
|
91
89
|
```json
|
|
92
90
|
{"name": "help", "tool_name": "pages"}
|
|
93
91
|
```
|
|
94
92
|
|
|
95
|
-
**Client Compatibility:**
|
|
96
|
-
- Claude Desktop, VS Code Copilot: Full support (Tier 1 + 2 + 3)
|
|
97
|
-
- Cursor, Windsurf: Via `help` tool (Tier 1 + 2)
|
|
98
|
-
|
|
99
93
|
---
|
|
100
94
|
|
|
101
95
|
## Limitations
|
|
102
96
|
|
|
103
|
-
**Supported
|
|
104
|
-
|
|
105
|
-
- ✅
|
|
106
|
-
- ✅ Code blocks, Quotes, Dividers
|
|
107
|
-
- ✅ Inline formatting (bold, italic, code, strikethrough, links)
|
|
108
|
-
|
|
109
|
-
**Unsupported Block Types:**
|
|
97
|
+
**Supported Blocks:**
|
|
98
|
+
- ✅ Headings, Paragraphs, Lists, Code blocks, Quotes, Dividers
|
|
99
|
+
- ✅ Inline: bold, italic, code, strikethrough, links
|
|
110
100
|
|
|
111
|
-
|
|
112
|
-
- ❌ Databases, Embeds, Images, Files
|
|
113
|
-
- ❌ Synced blocks, Templates
|
|
101
|
+
**Unsupported Blocks:**
|
|
102
|
+
- ❌ Tables, Toggles, Callouts, Columns, Databases, Embeds, Images, Files
|
|
114
103
|
|
|
115
104
|
---
|
|
116
105
|
|
|
117
|
-
|
|
106
|
+
## Build from Source
|
|
118
107
|
|
|
119
108
|
```bash
|
|
120
109
|
git clone https://github.com/n24q02m/better-notion-mcp
|
|
121
110
|
cd better-notion-mcp
|
|
122
|
-
|
|
123
|
-
# Setup (requires mise: https://mise.jdx.dev/)
|
|
124
111
|
mise run setup
|
|
125
|
-
|
|
126
|
-
# Build
|
|
127
112
|
pnpm build
|
|
128
113
|
```
|
|
129
114
|
|
|
130
|
-
**
|
|
131
|
-
|
|
132
|
-
### Available Commands
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
pnpm dev # Run development server with auto-reload
|
|
136
|
-
pnpm build # Build the project
|
|
137
|
-
pnpm test # Run tests
|
|
138
|
-
pnpm test:watch # Run tests in watch mode
|
|
139
|
-
pnpm test:coverage # Run tests with coverage report
|
|
140
|
-
pnpm check # Check formatting, linting & types (Biome + TypeScript)
|
|
141
|
-
pnpm check:fix # Auto-fix formatting and linting issues
|
|
142
|
-
```
|
|
115
|
+
**Requirements:** Node.js 24+, pnpm
|
|
143
116
|
|
|
144
117
|
## Contributing
|
|
145
118
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
- Development workflow (verified via CI)
|
|
149
|
-
- Commit convention (enforced via git hooks)
|
|
150
|
-
- Testing and code quality standards
|
|
151
|
-
|
|
152
|
-
---
|
|
119
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
153
120
|
|
|
154
121
|
## License
|
|
155
122
|
|
|
156
|
-
MIT
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
**Star this repo if you find it useful! ⭐**
|
|
123
|
+
MIT - See [LICENSE](LICENSE)
|
|
124
|
+
# Trigger CD
|
package/bin/cli.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
3
|
-
import{Server as
|
|
3
|
+
import{Server as Te}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as Ie}from"@modelcontextprotocol/sdk/server/stdio.js";import{readFileSync as V}from"node:fs";import{dirname as fe,join as P}from"node:path";import{fileURLToPath as he}from"node:url";import{CallToolRequestSchema as ye,ListResourcesRequestSchema as be,ListToolsRequestSchema as we,ReadResourceRequestSchema as ke}from"@modelcontextprotocol/sdk/types.js";import{Client as xe}from"@notionhq/client";var c=class extends Error{constructor(t,r,o,i){super(t);this.code=r;this.suggestion=o;this.details=i;this.name="NotionMCPError"}toJSON(){return{error:this.name,code:this.code,message:this.message,suggestion:this.suggestion,details:this.details}}};function W(a){if(!a||typeof a!="object")return a;let e={message:a.message,name:a.name,code:a.code};return a.status&&(e.status=a.status),a.response?.status&&(e.status=a.response.status),e}function F(a){return a.code?J(a):a.message?.includes("ECONNREFUSED")||a.message?.includes("ENOTFOUND")?new c("Cannot connect to Notion API","NETWORK_ERROR","Check your internet connection and try again"):new c(a.message||"Unknown error occurred","UNKNOWN_ERROR","Please check your request and try again",W(a))}function J(a){let e=a.code,t=a.message||"Unknown Notion API error";switch(console.error("Notion API Error:",JSON.stringify({code:e,message:t,status:a.status},null,2)),e){case"unauthorized":return new c("Invalid or missing Notion API token","UNAUTHORIZED","Set NOTION_TOKEN environment variable with a valid integration token from https://www.notion.so/my-integrations");case"restricted_resource":return new c("Integration does not have access to this resource","RESTRICTED_RESOURCE","Share the page/database with your integration in Notion settings");case"object_not_found":return new c("Page or database not found","NOT_FOUND","Check that the ID is correct and the resource exists");case"validation_error":return new c("Invalid request parameters","VALIDATION_ERROR","Check the API documentation for valid parameter formats",a.details);case"rate_limited":return new c("Too many requests to Notion API","RATE_LIMITED","Wait a few seconds and try again. Consider batching operations.");case"conflict_error":return new c("Conflict with existing data","CONFLICT","The resource may have been modified. Refresh and try again.");case"service_unavailable":return new c("Notion API is temporarily unavailable","SERVICE_UNAVAILABLE","Wait a moment and try again. Check https://status.notion.so for updates.");default:return new c(t,e.toUpperCase(),"Check the Notion API documentation for this error code")}}function E(a){let e=`Error: ${a.message}`;return a.suggestion&&(e+=`
|
|
4
4
|
|
|
5
5
|
Suggestion: ${a.suggestion}`),a.details&&(e+=`
|
|
6
6
|
|
|
7
|
-
Details: ${JSON.stringify(a.details,null,2)}`),e}function f(a){return async(...e)=>{try{return await a(...e)}catch(t){throw
|
|
8
|
-
`),t=[],r=[],
|
|
9
|
-
`),d))}else if(n.match(/^[-*]\s/)){let d=n.slice(2);
|
|
10
|
-
`)}function I(a){let e=[],t="",r=!1,i=!1,o=!1,n=!1;for(let d=0;d<a.length;d++){let s=a[d],u=a[d+1];if(s==="["){let p=a.indexOf("]",d),_=p!==-1?a.indexOf("(",p):-1,w=_!==-1?a.indexOf(")",_):-1;if(p!==-1&&_===p+1&&w!==-1){t&&(e.push(b(t,{bold:r,italic:i,code:o,strikethrough:n})),t="");let l=a.slice(d+1,p),k=a.slice(_+1,w);e.push({type:"text",text:{content:l,link:{url:k}},annotations:{bold:r,italic:i,strikethrough:n,underline:!1,code:o,color:"default"}}),d=w;continue}}if(s==="*"&&u==="*"){t&&(e.push(b(t,{bold:r,italic:i,code:o,strikethrough:n})),t=""),r=!r,d++;continue}else if(s==="*"&&u!=="*"){t&&(e.push(b(t,{bold:r,italic:i,code:o,strikethrough:n})),t=""),i=!i;continue}else if(s==="`"){t&&(e.push(b(t,{bold:r,italic:i,code:o,strikethrough:n})),t=""),o=!o;continue}else if(s==="~"&&u==="~"){t&&(e.push(b(t,{bold:r,italic:i,code:o,strikethrough:n})),t=""),n=!n,d++;continue}t+=s}return t&&e.push(b(t,{bold:r,italic:i,code:o,strikethrough:n})),e.length>0?e:[b(a)]}function y(a){return!a||!Array.isArray(a)?"":a.map(e=>{if(!e||!e.text)return"";let t=e.text.content||"",r=e.annotations||{};return r.bold&&(t=`**${t}**`),r.italic&&(t=`*${t}*`),r.code&&(t=`\`${t}\``),r.strikethrough&&(t=`~~${t}~~`),e.text.link&&(t=`[${t}](${e.text.link.url})`),t}).join("")}function b(a,e={}){return{type:"text",text:{content:a,link:null},annotations:{bold:e.bold||!1,italic:e.italic||!1,strikethrough:e.strikethrough||!1,underline:!1,code:e.code||!1,color:"default"}}}function P(a,e){let t=`heading_${a}`;return{object:"block",type:t,[t]:{rich_text:I(e),color:"default"}}}function F(a){return{object:"block",type:"paragraph",paragraph:{rich_text:I(a),color:"default"}}}function J(a){return{object:"block",type:"bulleted_list_item",bulleted_list_item:{rich_text:I(a),color:"default"}}}function K(a){return{object:"block",type:"numbered_list_item",numbered_list_item:{rich_text:I(a),color:"default"}}}function G(a,e){return{object:"block",type:"code",code:{rich_text:[b(a)],language:e||"plain text"}}}function Q(a){return{object:"block",type:"quote",quote:{rich_text:I(a),color:"default"}}}function Z(){return{object:"block",type:"divider",divider:{}}}function X(a){return a.match(/^[-*]\s/)!==null||a.match(/^\d+\.\s/)!==null}async function m(a,e={}){let{maxPages:t=0,pageSize:r=100}=e,i=[],o=null,n=0;do{let d=await a(o||void 0,r);if(i.push(...d.results),o=d.next_cursor,n++,t>0&&n>=t)break}while(o!==null);return i}async function E(a,e){return f(async()=>{if(!e.block_id)throw new c("block_id required","VALIDATION_ERROR","Provide block_id");switch(e.action){case"get":{let t=await a.blocks.retrieve({block_id:e.block_id});return{action:"get",block_id:t.id,type:t.type,has_children:t.has_children,archived:t.archived,block:t}}case"children":{let t=await m(i=>a.blocks.children.list({block_id:e.block_id,start_cursor:i,page_size:100})),r=x(t);return{action:"children",block_id:e.block_id,total_children:t.length,markdown:r,blocks:t}}case"append":{if(!e.content)throw new c("content required for append","VALIDATION_ERROR","Provide markdown content");let t=h(e.content);return await a.blocks.children.append({block_id:e.block_id,children:t}),{action:"append",block_id:e.block_id,appended_count:t.length}}case"update":{if(!e.content)throw new c("content required for update","VALIDATION_ERROR","Provide markdown content");let r=(await a.blocks.retrieve({block_id:e.block_id})).type,i=h(e.content);if(i.length===0)throw new c("Content must produce at least one block","VALIDATION_ERROR","Invalid markdown");let o=i[0],n={};if(["paragraph","heading_1","heading_2","heading_3","bulleted_list_item","numbered_list_item","quote"].includes(r))n[r]={rich_text:o[r]?.rich_text||[]};else throw new c(`Block type '${r}' cannot be updated`,"VALIDATION_ERROR","Only text blocks can be updated");return await a.blocks.update({block_id:e.block_id,...n}),{action:"update",block_id:e.block_id,type:r,updated:!0}}case"delete":return await a.blocks.delete({block_id:e.block_id}),{action:"delete",block_id:e.block_id,deleted:!0};default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: get, children, append, update, delete")}})()}function g(a){return{type:"text",text:{content:a,link:null},annotations:{bold:!1,italic:!1,strikethrough:!1,underline:!1,code:!1,color:"default"}}}function A(a){return a.map(e=>e.text.content).join("")}async function C(a,e){return f(async()=>{switch(e.action){case"list":{if(!e.page_id)throw new Error("page_id required for list action");let t=await m(async r=>await a.comments.list({block_id:e.page_id,start_cursor:r}));return{page_id:e.page_id,total_comments:t.length,comments:t.map(r=>({id:r.id,created_time:r.created_time,created_by:r.created_by,discussion_id:r.discussion_id,text:A(r.rich_text),parent:r.parent}))}}case"create":{if(!e.content)throw new Error("content required for create action");if(!e.page_id&&!e.discussion_id)throw new Error("Either page_id or discussion_id is required for create action");let t={rich_text:[g(e.content)]};e.discussion_id?t.discussion_id=e.discussion_id:t.parent={page_id:e.page_id};let r=await a.comments.create(t);return{comment_id:r.id,discussion_id:r.discussion_id,created:!0}}default:throw new Error(`Unsupported action: ${e.action}`)}})()}async function q(a){return f(async()=>{switch(a.direction){case"markdown-to-blocks":{if(typeof a.content!="string")throw new Error("Content must be a string for markdown-to-blocks");let e=h(a.content);return{direction:a.direction,block_count:e.length,blocks:e}}case"blocks-to-markdown":{let e=a.content;if(typeof e=="string")try{e=JSON.parse(e)}catch{throw new Error("Content must be a valid JSON array or array object for blocks-to-markdown")}if(!Array.isArray(e))throw new Error("Content must be an array for blocks-to-markdown");let t=x(e);return{direction:a.direction,char_count:t.length,markdown:t}}default:throw new Error(`Unsupported direction: ${a.direction}`)}})()}function R(a){let e={};for(let[t,r]of Object.entries(a)){if(r==null){e[t]=r;continue}typeof r=="string"?t==="Name"||t==="Title"||t.toLowerCase()==="title"?e[t]={title:[g(r)]}:e[t]={select:{name:r}}:typeof r=="number"?e[t]={number:r}:typeof r=="boolean"?e[t]={checkbox:r}:Array.isArray(r)&&r.length>0&&typeof r[0]=="string"?e[t]={multi_select:r.map(i=>({name:i}))}:e[t]=r}return e}async function S(a,e){return f(async()=>{switch(e.action){case"create":return await Y(a,e);case"get":return await ee(a,e);case"query":return await te(a,e);case"create_page":return await ae(a,e);case"update_page":return await re(a,e);case"delete_page":return await oe(a,e);case"create_data_source":return await ie(a,e);case"update_data_source":return await ne(a,e);case"update_database":return await se(a,e);default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: create, get, query, create_page, update_page, delete_page, create_data_source, update_data_source, update_database")}})()}async function Y(a,e){if(!e.parent_id||!e.title||!e.properties)throw new c("parent_id, title, and properties required for create action","VALIDATION_ERROR","Provide parent_id, title, and properties");let t={parent:{type:"page_id",page_id:e.parent_id},title:[g(e.title)],initial_data_source:{properties:e.properties}};e.description&&(t.description=[g(e.description)]),e.is_inline!==void 0&&(t.is_inline=e.is_inline);let r=await a.databases.create(t);return{action:"create",database_id:r.id,data_source_id:r.data_sources?.[0]?.id,url:r.url,created:!0}}async function ee(a,e){if(!e.database_id)throw new c("database_id required for get action","VALIDATION_ERROR","Provide database_id");let t=await a.databases.retrieve({database_id:e.database_id}),r={},i=null;if(t.data_sources&&t.data_sources.length>0){let o=await a.dataSources.retrieve({data_source_id:t.data_sources[0].id});if(i={id:o.id,name:o.title?.[0]?.plain_text||t.data_sources[0].name},o.properties)for(let[n,d]of Object.entries(o.properties)){let s=d;r[n]={type:s.type,id:s.id},s.type==="select"&&s.select?.options?r[n].options=s.select.options.map(u=>u.name):s.type==="multi_select"&&s.multi_select?.options?r[n].options=s.multi_select.options.map(u=>u.name):s.type==="formula"&&s.formula&&(r[n].expression=s.formula.expression)}}return{action:"get",database_id:t.id,title:t.title?.[0]?.plain_text||"Untitled",description:t.description?.[0]?.plain_text||"",url:t.url,is_inline:t.is_inline,created_time:t.created_time,last_edited_time:t.last_edited_time,data_source:i,schema:r}}async function te(a,e){if(!e.database_id)throw new c("database_id required for query action","VALIDATION_ERROR","Provide database_id");let t=await a.databases.retrieve({database_id:e.database_id});if(!t.data_sources||t.data_sources.length===0)throw new c("No data sources found in database","VALIDATION_ERROR","Database has no data sources");let r=t.data_sources[0].id,i=e.filters;if(e.search&&!i){let u=await a.dataSources.retrieve({data_source_id:r}),p=Object.entries(u.properties||{}).filter(([_,w])=>["title","rich_text"].includes(w.type)).map(([_])=>_);p.length>0&&(i={or:p.map(_=>({property:_,rich_text:{contains:e.search}}))})}let o={data_source_id:r};i&&(o.filter=i),e.sorts&&(o.sorts=e.sorts);let n=await m(async u=>{let p=await a.dataSources.query({...o,start_cursor:u,page_size:100});return{results:p.results,next_cursor:p.next_cursor,has_more:p.has_more}}),s=(e.limit?n.slice(0,e.limit):n).map(u=>{let p={page_id:u.id,url:u.url};for(let[_,w]of Object.entries(u.properties)){let l=w;l.type==="title"&&l.title?p[_]=l.title.map(k=>k.plain_text).join(""):l.type==="rich_text"&&l.rich_text?p[_]=l.rich_text.map(k=>k.plain_text).join(""):l.type==="select"&&l.select?p[_]=l.select.name:l.type==="multi_select"&&l.multi_select?p[_]=l.multi_select.map(k=>k.name):l.type==="number"?p[_]=l.number:l.type==="checkbox"?p[_]=l.checkbox:l.type==="url"?p[_]=l.url:l.type==="email"?p[_]=l.email:l.type==="phone_number"?p[_]=l.phone_number:l.type==="date"&&l.date&&(p[_]=l.date.start+(l.date.end?` to ${l.date.end}`:""))}return p});return{action:"query",database_id:e.database_id,data_source_id:r,total:s.length,results:s}}async function ae(a,e){if(!e.database_id)throw new c("database_id required","VALIDATION_ERROR","Provide database_id");let t=await a.databases.retrieve({database_id:e.database_id});if(!t.data_sources||t.data_sources.length===0)throw new c("No data sources found in database","VALIDATION_ERROR","Database has no data sources");let r=t.data_sources[0].id,i=e.pages||(e.page_properties?[{properties:e.page_properties}]:[]);if(i.length===0)throw new c("pages or page_properties required","VALIDATION_ERROR","Provide items to create");let o=[];for(let n of i){let d=R(n.properties),s=await a.pages.create({parent:{type:"data_source_id",data_source_id:r},properties:d});o.push({page_id:s.id,url:s.url,created:!0})}return{action:"create_page",database_id:e.database_id,data_source_id:r,processed:o.length,results:o}}async function re(a,e){let t=e.pages||(e.page_id&&e.page_properties?[{page_id:e.page_id,properties:e.page_properties}]:[]);if(t.length===0)throw new c("pages or page_id+page_properties required","VALIDATION_ERROR","Provide items to update");let r=[];for(let i of t){if(!i.page_id)throw new c("page_id required for each item","VALIDATION_ERROR","Provide page_id");let o=R(i.properties);await a.pages.update({page_id:i.page_id,properties:o}),r.push({page_id:i.page_id,updated:!0})}return{action:"update_page",processed:r.length,results:r}}async function oe(a,e){let t=e.page_ids||(e.page_id?[e.page_id]:[])||(e.pages?e.pages.map(i=>i.page_id).filter(Boolean):[]);if(t.length===0)throw new c("page_id or page_ids required","VALIDATION_ERROR","Provide page IDs to delete");let r=[];for(let i of t)await a.pages.update({page_id:i,archived:!0}),r.push({page_id:i,deleted:!0});return{action:"delete_page",processed:r.length,results:r}}async function ie(a,e){if(!e.database_id||!e.title||!e.properties)throw new c("database_id, title, and properties required","VALIDATION_ERROR","Provide database_id, title, and properties for new data source");let t={parent:{type:"database_id",database_id:e.database_id},title:[g(e.title)],properties:e.properties};return e.description&&(t.description=[g(e.description)]),{action:"create_data_source",data_source_id:(await a.dataSources.create(t)).id,database_id:e.database_id,created:!0}}async function ne(a,e){if(!e.data_source_id)throw new c("data_source_id required","VALIDATION_ERROR","Provide data_source_id");let t={};if(e.title&&(t.title=[g(e.title)]),e.description&&(t.description=[g(e.description)]),e.properties&&(t.properties=e.properties),Object.keys(t).length===0)throw new c("No updates provided","VALIDATION_ERROR","Provide title, description, or properties to update");return await a.dataSources.update({data_source_id:e.data_source_id,...t}),{action:"update_data_source",data_source_id:e.data_source_id,updated:!0}}async function se(a,e){if(!e.database_id)throw new c("database_id required","VALIDATION_ERROR","Provide database_id");let t={};if(e.parent_id&&(t.parent={type:"page_id",page_id:e.parent_id}),e.title&&(t.title=[g(e.title)]),e.description&&(t.description=[g(e.description)]),e.is_inline!==void 0&&(t.is_inline=e.is_inline),e.icon&&(t.icon={type:"emoji",emoji:e.icon}),e.cover&&(t.cover={type:"external",external:{url:e.cover}}),Object.keys(t).length===0)throw new c("No updates provided","VALIDATION_ERROR","Provide parent_id, title, description, is_inline, icon, or cover");return await a.databases.update({database_id:e.database_id,...t}),{action:"update_database",database_id:e.database_id,updated:!0}}async function j(a,e){return f(async()=>{switch(e.action){case"create":return await ce(a,e);case"get":return await de(a,e);case"update":return await le(a,e);case"archive":case"restore":return await pe(a,e);case"duplicate":return await ue(a,e);default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: create, get, update, archive, restore, move, duplicate")}})()}async function ce(a,e){if(!e.title)throw new c("title is required for create action","VALIDATION_ERROR","Provide page title");if(!e.parent_id)throw new c("parent_id is required for page creation","VALIDATION_ERROR","Integration tokens cannot create workspace-level pages. Provide parent_id (database or page ID).");let t=e.parent_id.replace(/-/g,""),r;e.properties&&Object.keys(e.properties).length>0?r={type:"database_id",database_id:t}:r={type:"page_id",page_id:t};let i={};r.database_id?(i=R(e.properties||{}),!i.title&&!i.Name&&!i.Title&&(i.Name={title:[g(e.title)]})):i={title:{title:[g(e.title)]}};let o={parent:r,properties:i};e.icon&&(o.icon={type:"emoji",emoji:e.icon}),e.cover&&(o.cover={type:"external",external:{url:e.cover}});let n=await a.pages.create(o);if(e.content){let d=h(e.content);d.length>0&&await a.blocks.children.append({block_id:n.id,children:d})}return{action:"create",page_id:n.id,url:n.url,created:!0}}async function de(a,e){if(!e.page_id)throw new c("page_id is required for get action","VALIDATION_ERROR","Provide page_id");let t=await a.pages.retrieve({page_id:e.page_id}),r=await m(n=>a.blocks.children.list({block_id:e.page_id,start_cursor:n,page_size:100})),i=x(r),o={};for(let[n,d]of Object.entries(t.properties)){let s=d;s.type==="title"&&s.title?o[n]=s.title.map(u=>u.plain_text).join(""):s.type==="rich_text"&&s.rich_text?o[n]=s.rich_text.map(u=>u.plain_text).join(""):s.type==="select"&&s.select?o[n]=s.select.name:s.type==="multi_select"&&s.multi_select?o[n]=s.multi_select.map(u=>u.name):s.type==="number"?o[n]=s.number:s.type==="checkbox"?o[n]=s.checkbox:s.type==="url"?o[n]=s.url:s.type==="email"?o[n]=s.email:s.type==="phone_number"?o[n]=s.phone_number:s.type==="date"&&s.date&&(o[n]=s.date.start+(s.date.end?` to ${s.date.end}`:""))}return{action:"get",page_id:t.id,url:t.url,created_time:t.created_time,last_edited_time:t.last_edited_time,archived:t.archived,properties:o,content:i,block_count:r.length}}async function le(a,e){if(!e.page_id)throw new c("page_id is required for update action","VALIDATION_ERROR","Provide page_id");let t={};if(e.icon&&(t.icon={type:"emoji",emoji:e.icon}),e.cover&&(t.cover={type:"external",external:{url:e.cover}}),e.archived!==void 0&&(t.archived=e.archived),(e.properties||e.title)&&(t.properties={},e.title&&(t.properties.title={title:[g(e.title)]}),e.properties)){let r=R(e.properties);t.properties={...t.properties,...r}}if(Object.keys(t).length>0&&await a.pages.update({page_id:e.page_id,...t}),e.content||e.append_content||e.prepend_content){if(e.content){let r=await m(o=>a.blocks.children.list({block_id:e.page_id,start_cursor:o,page_size:100}));for(let o of r)await a.blocks.delete({block_id:o.id});let i=h(e.content);i.length>0&&await a.blocks.children.append({block_id:e.page_id,children:i})}else if(e.append_content){let r=h(e.append_content);r.length>0&&await a.blocks.children.append({block_id:e.page_id,children:r})}else if(e.prepend_content){let r=await m(o=>a.blocks.children.list({block_id:e.page_id,start_cursor:o,page_size:1})),i=h(e.prepend_content);i.length>0&&(r[0]?.id?await a.blocks.children.append({block_id:e.page_id,children:i,after:void 0}):await a.blocks.children.append({block_id:e.page_id,children:i}))}}return{action:"update",page_id:e.page_id,updated:!0}}async function pe(a,e){let t=e.page_ids||(e.page_id?[e.page_id]:[]);if(t.length===0)throw new c("page_id or page_ids required","VALIDATION_ERROR","Provide at least one page ID");let r=e.action==="archive",i=[];for(let o of t)await a.pages.update({page_id:o,archived:r}),i.push({page_id:o,archived:r});return{action:e.action,processed:i.length,results:i}}async function ue(a,e){let t=e.page_ids||(e.page_id?[e.page_id]:[]);if(t.length===0)throw new c("page_id or page_ids required","VALIDATION_ERROR","Provide at least one page ID");let r=[];for(let i of t){let o=await a.pages.retrieve({page_id:i}),n=await m(s=>a.blocks.children.list({block_id:i,start_cursor:s,page_size:100})),d=await a.pages.create({parent:o.parent,properties:o.properties,icon:o.icon,cover:o.cover});n.length>0&&await a.blocks.children.append({block_id:d.id,children:n}),r.push({original_id:i,duplicate_id:d.id,url:d.url})}return{action:"duplicate",processed:r.length,results:r}}async function L(a,e){return f(async()=>{switch(e.action){case"list":{let t=await m(r=>a.users.list({start_cursor:r,page_size:100}));return{action:"list",total:t.length,users:t.map(r=>({id:r.id,type:r.type,name:r.name||"Unknown",avatar_url:r.avatar_url,email:r.type==="person"?r.person?.email:void 0}))}}case"get":{if(!e.user_id)throw new c("user_id required for get action","VALIDATION_ERROR","Provide user_id");let t=await a.users.retrieve({user_id:e.user_id});return{action:"get",id:t.id,type:t.type,name:t.name||"Unknown",avatar_url:t.avatar_url,email:t.type==="person"?t.person?.email:void 0}}case"me":{let t=await a.users.retrieve({user_id:"me"});return{action:"me",id:t.id,type:t.type,name:t.name||"Bot",bot:t.bot}}case"from_workspace":{let t=await a.search({filter:{property:"object",value:"page"},page_size:100}),r=new Map;for(let o of t.results)o.created_by&&r.set(o.created_by.id,{id:o.created_by.id,type:o.created_by.object,source:"page_metadata"}),o.last_edited_by&&r.set(o.last_edited_by.id,{id:o.last_edited_by.id,type:o.last_edited_by.object,source:"page_metadata"});let i=Array.from(r.values());return{action:"from_workspace",total:i.length,users:i,note:'Users extracted from accessible pages. Use "me" action for bot info, or share more pages for more users.'}}default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: list, get, me, from_workspace")}})()}async function U(a,e){return f(async()=>{switch(e.action){case"info":{let t=await a.users.retrieve({user_id:"me"});return{action:"info",bot:{id:t.id,name:t.name||"Bot",type:t.type,owner:t.bot?.owner}}}case"search":{let t={query:e.query||""};e.filter?.object&&(t.filter={value:e.filter.object,property:"object"}),e.sort&&(t.sort={direction:e.sort.direction||"descending",timestamp:e.sort.timestamp||"last_edited_time"});let r=await m(o=>a.search({...t,start_cursor:o,page_size:100})),i=e.limit?r.slice(0,e.limit):r;return{action:"search",query:e.query,total:i.length,results:i.map(o=>({id:o.id,object:o.object,title:o.object==="page"?o.properties?.title?.title?.[0]?.plain_text||o.properties?.Name?.title?.[0]?.plain_text||"Untitled":o.title?.[0]?.plain_text||"Untitled",url:o.url,last_edited_time:o.last_edited_time}))}}default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: info, search")}})()}var we=ge(import.meta.url),O=_e(we),V=O.endsWith("bin")?v(O,"..","build","src","docs"):v(O,"..","docs"),N=[{uri:"notion://docs/pages",name:"Pages Tool Docs",file:"pages.md"},{uri:"notion://docs/databases",name:"Databases Tool Docs",file:"databases.md"},{uri:"notion://docs/blocks",name:"Blocks Tool Docs",file:"blocks.md"},{uri:"notion://docs/users",name:"Users Tool Docs",file:"users.md"},{uri:"notion://docs/workspace",name:"Workspace Tool Docs",file:"workspace.md"},{uri:"notion://docs/comments",name:"Comments Tool Docs",file:"comments.md"},{uri:"notion://docs/content_convert",name:"Content Convert Tool Docs",file:"content_convert.md"}],M=[{name:"pages",description:"Page lifecycle: create, get, update, archive, restore, duplicate. Requires parent_id for create. Returns markdown content for get.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["create","get","update","archive","restore","duplicate"],description:"Action to perform"},page_id:{type:"string",description:"Page ID (required for most actions)"},page_ids:{type:"array",items:{type:"string"},description:"Multiple page IDs for batch operations"},title:{type:"string",description:"Page title"},content:{type:"string",description:"Markdown content"},append_content:{type:"string",description:"Markdown to append"},prepend_content:{type:"string",description:"Markdown to prepend"},parent_id:{type:"string",description:"Parent page or database ID"},properties:{type:"object",description:"Page properties (for database pages)"},icon:{type:"string",description:"Emoji icon"},cover:{type:"string",description:"Cover image URL"},archived:{type:"boolean",description:"Archive status"}},required:["action"]}},{name:"databases",description:"Database operations: create, get, query, create_page, update_page, delete_page, create_data_source, update_data_source, update_database. Databases contain data sources with schema and rows.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["create","get","query","create_page","update_page","delete_page","create_data_source","update_data_source","update_database"],description:"Action to perform"},database_id:{type:"string",description:"Database ID (container)"},data_source_id:{type:"string",description:"Data source ID (for update_data_source action)"},parent_id:{type:"string",description:"Parent page ID (for create/update_database)"},title:{type:"string",description:"Title (for database or data source)"},description:{type:"string",description:"Description"},properties:{type:"object",description:"Schema properties (for create/update data source)"},is_inline:{type:"boolean",description:"Display as inline (for create/update_database)"},icon:{type:"string",description:"Emoji icon (for update_database)"},cover:{type:"string",description:"Cover image URL (for update_database)"},filters:{type:"object",description:"Query filters (for query action)"},sorts:{type:"array",items:{type:"object"},description:"Query sorts"},limit:{type:"number",description:"Max query results"},search:{type:"string",description:"Smart search across text fields (for query)"},page_id:{type:"string",description:"Single page ID (for update_page)"},page_ids:{type:"array",items:{type:"string"},description:"Multiple page IDs (for delete_page)"},page_properties:{type:"object",description:"Page properties to update (for update_page)"},pages:{type:"array",items:{type:"object"},description:"Array of pages for bulk create/update"}},required:["action"]}},{name:"blocks",description:"Block-level content: get, children, append, update, delete. Page IDs are valid block IDs. Use for precise edits.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["get","children","append","update","delete"],description:"Action to perform"},block_id:{type:"string",description:"Block ID"},content:{type:"string",description:"Markdown content (for append/update)"}},required:["action","block_id"]}},{name:"users",description:"User info: list, get, me, from_workspace. Use from_workspace if list fails due to permissions.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["list","get","me","from_workspace"],description:"Action to perform"},user_id:{type:"string",description:"User ID (for get action)"}},required:["action"]}},{name:"workspace",description:"Workspace: info, search. Search returns pages/databases shared with integration. Use filter.object for type.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["info","search"],description:"Action to perform"},query:{type:"string",description:"Search query"},filter:{type:"object",properties:{object:{type:"string",enum:["page","data_source"]}}},sort:{type:"object",properties:{direction:{type:"string",enum:["ascending","descending"]},timestamp:{type:"string",enum:["last_edited_time","created_time"]}}},limit:{type:"number",description:"Max results"}},required:["action"]}},{name:"comments",description:"Comments: list, create. Use page_id for new discussion, discussion_id for replies.",inputSchema:{type:"object",properties:{page_id:{type:"string",description:"Page ID"},discussion_id:{type:"string",description:"Discussion ID (for replies)"},action:{type:"string",enum:["list","create"],description:"Action to perform"},content:{type:"string",description:"Comment content (for create)"}},required:["action"]}},{name:"content_convert",description:"Convert: markdown-to-blocks, blocks-to-markdown. Most tools handle markdown automatically.",inputSchema:{type:"object",properties:{direction:{type:"string",enum:["markdown-to-blocks","blocks-to-markdown"],description:"Conversion direction"},content:{description:"Content to convert (string or array/JSON string)"}},required:["direction","content"]}},{name:"help",description:"Get full documentation for a tool. Use when compressed descriptions are insufficient.",inputSchema:{type:"object",properties:{tool_name:{type:"string",enum:["pages","databases","blocks","users","workspace","comments","content_convert"],description:"Tool to get documentation for"}},required:["tool_name"]}}];function $(a,e){let t=new be({auth:e,notionVersion:"2025-09-03"});a.setRequestHandler(he,async()=>({tools:M})),a.setRequestHandler(fe,async()=>({resources:N.map(r=>({uri:r.uri,name:r.name,mimeType:"text/markdown"}))})),a.setRequestHandler(ye,async r=>{let{uri:i}=r.params,o=N.find(d=>d.uri===i);if(!o)throw new c(`Resource not found: ${i}`,"RESOURCE_NOT_FOUND",`Available: ${N.map(d=>d.uri).join(", ")}`);let n=B(v(V,o.file),"utf-8");return{contents:[{uri:i,mimeType:"text/markdown",text:n}]}}),a.setRequestHandler(me,async r=>{let{name:i,arguments:o}=r.params;if(!o)return{content:[{type:"text",text:"Error: No arguments provided"}],isError:!0};try{let n;switch(i){case"pages":n=await j(t,o);break;case"databases":n=await S(t,o);break;case"blocks":n=await E(t,o);break;case"users":n=await L(t,o);break;case"workspace":n=await U(t,o);break;case"comments":n=await C(t,o);break;case"content_convert":n=await q(o);break;case"help":{let d=o.tool_name,s=`${d}.md`;try{let u=B(v(V,s),"utf-8");n={tool:d,documentation:u}}catch{throw new c(`Documentation not found for: ${d}`,"DOC_NOT_FOUND","Check tool_name")}break}default:throw new c(`Unknown tool: ${i}`,"UNKNOWN_TOOL",`Available tools: ${M.map(d=>d.name).join(", ")}`)}return{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}catch(n){let d=n instanceof c?n:new c(n.message,"TOOL_ERROR","Check the error details and try again");return{content:[{type:"text",text:D(d)}],isError:!0}}})}async function H(){let a=process.env.NOTION_TOKEN;a||(console.error("NOTION_TOKEN environment variable is required"),console.error("Get your token from https://www.notion.so/my-integrations"),process.exit(1));let e=new ke({name:"@n24q02m/better-notion-mcp",version:"1.0.0"},{capabilities:{tools:{},resources:{}}});$(e,a);let t=new xe;return await e.connect(t),e}async function Re(){try{await H(),process.on("SIGINT",()=>{console.error(`
|
|
11
|
-
Shutting down Better Notion MCP Server`),process.exit(0)})}catch(a){console.error("Failed to start server:",a),process.exit(1)}}
|
|
7
|
+
Details: ${JSON.stringify(a.details,null,2)}`),e}function f(a){return async(...e)=>{try{return await a(...e)}catch(t){throw F(t)}}}function h(a){let e=a.split(`
|
|
8
|
+
`),t=[],r=[],o=null;for(let i=0;i<e.length;i++){let n=e[i];if(o&&!ee(n)&&(t.push(...r),r=[],o=null),!!n.trim())if(n.startsWith("# "))t.push(O(1,n.slice(2)));else if(n.startsWith("## "))t.push(O(2,n.slice(3)));else if(n.startsWith("### "))t.push(O(3,n.slice(4)));else if(n.startsWith("```")){let d=n.slice(3).trim(),s=[];for(i++;i<e.length&&!e[i].startsWith("```");)s.push(e[i]),i++;t.push(Z(s.join(`
|
|
9
|
+
`),d))}else if(n.match(/^[-*]\s/)){let d=n.slice(2);o="bulleted",r.push(G(d))}else if(n.match(/^\d+\.\s/)){let d=n.replace(/^\d+\.\s/,"");o="numbered",r.push(Q(d))}else n.startsWith("> ")?t.push(X(n.slice(2))):n.match(/^[-*]{3,}$/)?t.push(Y()):t.push(K(n))}return r.length>0&&t.push(...r),t}function R(a){let e=[];for(let t of a)switch(t.type){case"heading_1":e.push(`# ${y(t.heading_1.rich_text)}`);break;case"heading_2":e.push(`## ${y(t.heading_2.rich_text)}`);break;case"heading_3":e.push(`### ${y(t.heading_3.rich_text)}`);break;case"paragraph":e.push(y(t.paragraph.rich_text));break;case"bulleted_list_item":e.push(`- ${y(t.bulleted_list_item.rich_text)}`);break;case"numbered_list_item":e.push(`1. ${y(t.numbered_list_item.rich_text)}`);break;case"code":e.push(`\`\`\`${t.code.language||""}`),e.push(y(t.code.rich_text)),e.push("```");break;case"quote":e.push(`> ${y(t.quote.rich_text)}`);break;case"divider":e.push("---");break;default:break}return e.join(`
|
|
10
|
+
`)}function I(a){let e=[],t="",r=!1,o=!1,i=!1,n=!1;for(let d=0;d<a.length;d++){let s=a[d],u=a[d+1];if(s==="["){let p=a.indexOf("]",d),_=p!==-1?a.indexOf("(",p):-1,k=_!==-1?a.indexOf(")",_):-1;if(p!==-1&&_===p+1&&k!==-1){t&&(e.push(b(t,{bold:r,italic:o,code:i,strikethrough:n})),t="");let l=a.slice(d+1,p),x=a.slice(_+1,k);e.push({type:"text",text:{content:l,link:{url:x}},annotations:{bold:r,italic:o,strikethrough:n,underline:!1,code:i,color:"default"}}),d=k;continue}}if(s==="*"&&u==="*"){t&&(e.push(b(t,{bold:r,italic:o,code:i,strikethrough:n})),t=""),r=!r,d++;continue}else if(s==="*"&&u!=="*"){t&&(e.push(b(t,{bold:r,italic:o,code:i,strikethrough:n})),t=""),o=!o;continue}else if(s==="`"){t&&(e.push(b(t,{bold:r,italic:o,code:i,strikethrough:n})),t=""),i=!i;continue}else if(s==="~"&&u==="~"){t&&(e.push(b(t,{bold:r,italic:o,code:i,strikethrough:n})),t=""),n=!n,d++;continue}t+=s}return t&&e.push(b(t,{bold:r,italic:o,code:i,strikethrough:n})),e.length>0?e:[b(a)]}function y(a){return!a||!Array.isArray(a)?"":a.map(e=>{if(!e||!e.text)return"";let t=e.text.content||"",r=e.annotations||{};return r.bold&&(t=`**${t}**`),r.italic&&(t=`*${t}*`),r.code&&(t=`\`${t}\``),r.strikethrough&&(t=`~~${t}~~`),e.text.link&&(t=`[${t}](${e.text.link.url})`),t}).join("")}function b(a,e={}){return{type:"text",text:{content:a,link:null},annotations:{bold:e.bold||!1,italic:e.italic||!1,strikethrough:e.strikethrough||!1,underline:!1,code:e.code||!1,color:"default"}}}function O(a,e){let t=`heading_${a}`;return{object:"block",type:t,[t]:{rich_text:I(e),color:"default"}}}function K(a){return{object:"block",type:"paragraph",paragraph:{rich_text:I(a),color:"default"}}}function G(a){return{object:"block",type:"bulleted_list_item",bulleted_list_item:{rich_text:I(a),color:"default"}}}function Q(a){return{object:"block",type:"numbered_list_item",numbered_list_item:{rich_text:I(a),color:"default"}}}function Z(a,e){return{object:"block",type:"code",code:{rich_text:[b(a)],language:e||"plain text"}}}function X(a){return{object:"block",type:"quote",quote:{rich_text:I(a),color:"default"}}}function Y(){return{object:"block",type:"divider",divider:{}}}function ee(a){return a.match(/^[-*]\s/)!==null||a.match(/^\d+\.\s/)!==null}async function m(a,e={}){let{maxPages:t=0,pageSize:r=100}=e,o=[],i=null,n=0;do{let d=await a(i||void 0,r);if(o.push(...d.results),i=d.next_cursor,n++,t>0&&n>=t)break}while(i!==null);return o}function te(a,e){let t=[];for(let r=0;r<a.length;r+=e)t.push(a.slice(r,r+e));return t}async function w(a,e,t={}){let{batchSize:r=10,concurrency:o=3}=t,i=te(a,r),n=[];for(let d=0;d<i.length;d+=o){let u=i.slice(d,d+o).map(_=>Promise.all(_.map(e))),p=await Promise.all(u);n.push(...p.flat())}return n}async function A(a,e){return f(async()=>{if(!e.block_id)throw new c("block_id required","VALIDATION_ERROR","Provide block_id");switch(e.action){case"get":{let t=await a.blocks.retrieve({block_id:e.block_id});return{action:"get",block_id:t.id,type:t.type,has_children:t.has_children,archived:t.archived,block:t}}case"children":{let t=await m(o=>a.blocks.children.list({block_id:e.block_id,start_cursor:o,page_size:100})),r=R(t);return{action:"children",block_id:e.block_id,total_children:t.length,markdown:r,blocks:t}}case"append":{if(!e.content)throw new c("content required for append","VALIDATION_ERROR","Provide markdown content");let t=h(e.content);return await a.blocks.children.append({block_id:e.block_id,children:t}),{action:"append",block_id:e.block_id,appended_count:t.length}}case"update":{if(!e.content)throw new c("content required for update","VALIDATION_ERROR","Provide markdown content");let r=(await a.blocks.retrieve({block_id:e.block_id})).type,o=h(e.content);if(o.length===0)throw new c("Content must produce at least one block","VALIDATION_ERROR","Invalid markdown");let i=o[0],n={};if(["paragraph","heading_1","heading_2","heading_3","bulleted_list_item","numbered_list_item","quote"].includes(r))n[r]={rich_text:i[r]?.rich_text||[]};else throw new c(`Block type '${r}' cannot be updated`,"VALIDATION_ERROR","Only text blocks can be updated");return await a.blocks.update({block_id:e.block_id,...n}),{action:"update",block_id:e.block_id,type:r,updated:!0}}case"delete":return await a.blocks.delete({block_id:e.block_id}),{action:"delete",block_id:e.block_id,deleted:!0};default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: get, children, append, update, delete")}})()}function g(a){return{type:"text",text:{content:a,link:null},annotations:{bold:!1,italic:!1,strikethrough:!1,underline:!1,code:!1,color:"default"}}}function C(a){return a.map(e=>e.text.content).join("")}async function q(a,e){return f(async()=>{switch(e.action){case"list":{if(!e.page_id)throw new Error("page_id required for list action");let t=await m(async r=>await a.comments.list({block_id:e.page_id,start_cursor:r}));return{page_id:e.page_id,total_comments:t.length,comments:t.map(r=>({id:r.id,created_time:r.created_time,created_by:r.created_by,discussion_id:r.discussion_id,text:C(r.rich_text),parent:r.parent}))}}case"create":{if(!e.content)throw new Error("content required for create action");if(!e.page_id&&!e.discussion_id)throw new Error("Either page_id or discussion_id is required for create action");let t={rich_text:[g(e.content)]};e.discussion_id?t.discussion_id=e.discussion_id:t.parent={page_id:e.page_id};let r=await a.comments.create(t);return{comment_id:r.id,discussion_id:r.discussion_id,created:!0}}default:throw new Error(`Unsupported action: ${e.action}`)}})()}async function S(a){return f(async()=>{switch(a.direction){case"markdown-to-blocks":{if(typeof a.content!="string")throw new Error("Content must be a string for markdown-to-blocks");let e=h(a.content);return{direction:a.direction,block_count:e.length,blocks:e}}case"blocks-to-markdown":{let e=a.content;if(typeof e=="string")try{e=JSON.parse(e)}catch{throw new Error("Content must be a valid JSON array or array object for blocks-to-markdown")}if(!Array.isArray(e))throw new Error("Content must be an array for blocks-to-markdown");let t=R(e);return{direction:a.direction,char_count:t.length,markdown:t}}default:throw new Error(`Unsupported direction: ${a.direction}`)}})()}function T(a){let e={};for(let[t,r]of Object.entries(a)){if(r==null){e[t]=r;continue}typeof r=="string"?t==="Name"||t==="Title"||t.toLowerCase()==="title"?e[t]={title:[g(r)]}:e[t]={select:{name:r}}:typeof r=="number"?e[t]={number:r}:typeof r=="boolean"?e[t]={checkbox:r}:Array.isArray(r)&&r.length>0&&typeof r[0]=="string"?e[t]={multi_select:r.map(o=>({name:o}))}:e[t]=r}return e}async function j(a,e){return f(async()=>{switch(e.action){case"create":return await ae(a,e);case"get":return await re(a,e);case"query":return await ie(a,e);case"create_page":return await oe(a,e);case"update_page":return await ne(a,e);case"delete_page":return await se(a,e);case"create_data_source":return await ce(a,e);case"update_data_source":return await de(a,e);case"update_database":return await le(a,e);default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: create, get, query, create_page, update_page, delete_page, create_data_source, update_data_source, update_database")}})()}async function ae(a,e){if(!e.parent_id||!e.title||!e.properties)throw new c("parent_id, title, and properties required for create action","VALIDATION_ERROR","Provide parent_id, title, and properties");let t={parent:{type:"page_id",page_id:e.parent_id},title:[g(e.title)],initial_data_source:{properties:e.properties}};e.description&&(t.description=[g(e.description)]),e.is_inline!==void 0&&(t.is_inline=e.is_inline);let r=await a.databases.create(t);return{action:"create",database_id:r.id,data_source_id:r.data_sources?.[0]?.id,url:r.url,created:!0}}async function re(a,e){if(!e.database_id)throw new c("database_id required for get action","VALIDATION_ERROR","Provide database_id");let t=await a.databases.retrieve({database_id:e.database_id}),r={},o=null;if(t.data_sources&&t.data_sources.length>0){let i=await a.dataSources.retrieve({data_source_id:t.data_sources[0].id});if(o={id:i.id,name:i.title?.[0]?.plain_text||t.data_sources[0].name},i.properties)for(let[n,d]of Object.entries(i.properties)){let s=d;r[n]={type:s.type,id:s.id},s.type==="select"&&s.select?.options?r[n].options=s.select.options.map(u=>u.name):s.type==="multi_select"&&s.multi_select?.options?r[n].options=s.multi_select.options.map(u=>u.name):s.type==="formula"&&s.formula&&(r[n].expression=s.formula.expression)}}return{action:"get",database_id:t.id,title:t.title?.[0]?.plain_text||"Untitled",description:t.description?.[0]?.plain_text||"",url:t.url,is_inline:t.is_inline,created_time:t.created_time,last_edited_time:t.last_edited_time,data_source:o,schema:r}}async function ie(a,e){if(!e.database_id)throw new c("database_id required for query action","VALIDATION_ERROR","Provide database_id");let t=await a.databases.retrieve({database_id:e.database_id});if(!t.data_sources||t.data_sources.length===0)throw new c("No data sources found in database","VALIDATION_ERROR","Database has no data sources");let r=t.data_sources[0].id,o=e.filters;if(e.search&&!o){let u=await a.dataSources.retrieve({data_source_id:r}),p=Object.entries(u.properties||{}).filter(([_,k])=>["title","rich_text"].includes(k.type)).map(([_])=>_);p.length>0&&(o={or:p.map(_=>({property:_,rich_text:{contains:e.search}}))})}let i={data_source_id:r};o&&(i.filter=o),e.sorts&&(i.sorts=e.sorts);let n=await m(async u=>{let p=await a.dataSources.query({...i,start_cursor:u,page_size:100});return{results:p.results,next_cursor:p.next_cursor,has_more:p.has_more}}),s=(e.limit?n.slice(0,e.limit):n).map(u=>{let p={page_id:u.id,url:u.url};for(let[_,k]of Object.entries(u.properties)){let l=k;l.type==="title"&&l.title?p[_]=l.title.map(x=>x.plain_text).join(""):l.type==="rich_text"&&l.rich_text?p[_]=l.rich_text.map(x=>x.plain_text).join(""):l.type==="select"&&l.select?p[_]=l.select.name:l.type==="multi_select"&&l.multi_select?p[_]=l.multi_select.map(x=>x.name):l.type==="number"?p[_]=l.number:l.type==="checkbox"?p[_]=l.checkbox:l.type==="url"?p[_]=l.url:l.type==="email"?p[_]=l.email:l.type==="phone_number"?p[_]=l.phone_number:l.type==="date"&&l.date&&(p[_]=l.date.start+(l.date.end?` to ${l.date.end}`:""))}return p});return{action:"query",database_id:e.database_id,data_source_id:r,total:s.length,results:s}}async function oe(a,e){if(!e.database_id)throw new c("database_id required","VALIDATION_ERROR","Provide database_id");let t=await a.databases.retrieve({database_id:e.database_id});if(!t.data_sources||t.data_sources.length===0)throw new c("No data sources found in database","VALIDATION_ERROR","Database has no data sources");let r=t.data_sources[0].id,o=e.pages||(e.page_properties?[{properties:e.page_properties}]:[]);if(o.length===0)throw new c("pages or page_properties required","VALIDATION_ERROR","Provide items to create");let i=await w(o,async n=>{let d=T(n.properties),s=await a.pages.create({parent:{type:"data_source_id",data_source_id:r},properties:d});return{page_id:s.id,url:s.url,created:!0}});return{action:"create_page",database_id:e.database_id,data_source_id:r,processed:i.length,results:i}}async function ne(a,e){let t=e.pages||(e.page_id&&e.page_properties?[{page_id:e.page_id,properties:e.page_properties}]:[]);if(t.length===0)throw new c("pages or page_id+page_properties required","VALIDATION_ERROR","Provide items to update");let r=await w(t,async o=>{if(!o.page_id)throw new c("page_id required for each item","VALIDATION_ERROR","Provide page_id");let i=T(o.properties);return await a.pages.update({page_id:o.page_id,properties:i}),{page_id:o.page_id,updated:!0}});return{action:"update_page",processed:r.length,results:r}}async function se(a,e){let t=e.page_ids||(e.page_id?[e.page_id]:[])||(e.pages?e.pages.map(o=>o.page_id).filter(Boolean):[]);if(t.length===0)throw new c("page_id or page_ids required","VALIDATION_ERROR","Provide page IDs to delete");let r=await w(t,async o=>(await a.pages.update({page_id:o,archived:!0}),{page_id:o,deleted:!0}),{batchSize:5,concurrency:3});return{action:"delete_page",processed:r.length,results:r}}async function ce(a,e){if(!e.database_id||!e.title||!e.properties)throw new c("database_id, title, and properties required","VALIDATION_ERROR","Provide database_id, title, and properties for new data source");let t={parent:{type:"database_id",database_id:e.database_id},title:[g(e.title)],properties:e.properties};return e.description&&(t.description=[g(e.description)]),{action:"create_data_source",data_source_id:(await a.dataSources.create(t)).id,database_id:e.database_id,created:!0}}async function de(a,e){if(!e.data_source_id)throw new c("data_source_id required","VALIDATION_ERROR","Provide data_source_id");let t={};if(e.title&&(t.title=[g(e.title)]),e.description&&(t.description=[g(e.description)]),e.properties&&(t.properties=e.properties),Object.keys(t).length===0)throw new c("No updates provided","VALIDATION_ERROR","Provide title, description, or properties to update");return await a.dataSources.update({data_source_id:e.data_source_id,...t}),{action:"update_data_source",data_source_id:e.data_source_id,updated:!0}}async function le(a,e){if(!e.database_id)throw new c("database_id required","VALIDATION_ERROR","Provide database_id");let t={};if(e.parent_id&&(t.parent={type:"page_id",page_id:e.parent_id}),e.title&&(t.title=[g(e.title)]),e.description&&(t.description=[g(e.description)]),e.is_inline!==void 0&&(t.is_inline=e.is_inline),e.icon&&(t.icon={type:"emoji",emoji:e.icon}),e.cover&&(t.cover={type:"external",external:{url:e.cover}}),Object.keys(t).length===0)throw new c("No updates provided","VALIDATION_ERROR","Provide parent_id, title, description, is_inline, icon, or cover");return await a.databases.update({database_id:e.database_id,...t}),{action:"update_database",database_id:e.database_id,updated:!0}}async function L(a,e){return f(async()=>{switch(e.action){case"create":return await pe(a,e);case"get":return await ue(a,e);case"update":return await _e(a,e);case"archive":case"restore":return await ge(a,e);case"duplicate":return await me(a,e);default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: create, get, update, archive, restore, move, duplicate")}})()}async function pe(a,e){if(!e.title)throw new c("title is required for create action","VALIDATION_ERROR","Provide page title");if(!e.parent_id)throw new c("parent_id is required for page creation","VALIDATION_ERROR","Integration tokens cannot create workspace-level pages. Provide parent_id (database or page ID).");let t=e.parent_id.replace(/-/g,""),r;e.properties&&Object.keys(e.properties).length>0?r={type:"database_id",database_id:t}:r={type:"page_id",page_id:t};let o={};r.database_id?(o=T(e.properties||{}),!o.title&&!o.Name&&!o.Title&&(o.Name={title:[g(e.title)]})):o={title:{title:[g(e.title)]}};let i={parent:r,properties:o};e.icon&&(i.icon={type:"emoji",emoji:e.icon}),e.cover&&(i.cover={type:"external",external:{url:e.cover}});let n=await a.pages.create(i);if(e.content){let d=h(e.content);d.length>0&&await a.blocks.children.append({block_id:n.id,children:d})}return{action:"create",page_id:n.id,url:n.url,created:!0}}async function ue(a,e){if(!e.page_id)throw new c("page_id is required for get action","VALIDATION_ERROR","Provide page_id");let t=await a.pages.retrieve({page_id:e.page_id}),r=await m(n=>a.blocks.children.list({block_id:e.page_id,start_cursor:n,page_size:100})),o=R(r),i={};for(let[n,d]of Object.entries(t.properties)){let s=d;s.type==="title"&&s.title?i[n]=s.title.map(u=>u.plain_text).join(""):s.type==="rich_text"&&s.rich_text?i[n]=s.rich_text.map(u=>u.plain_text).join(""):s.type==="select"&&s.select?i[n]=s.select.name:s.type==="multi_select"&&s.multi_select?i[n]=s.multi_select.map(u=>u.name):s.type==="number"?i[n]=s.number:s.type==="checkbox"?i[n]=s.checkbox:s.type==="url"?i[n]=s.url:s.type==="email"?i[n]=s.email:s.type==="phone_number"?i[n]=s.phone_number:s.type==="date"&&s.date&&(i[n]=s.date.start+(s.date.end?` to ${s.date.end}`:""))}return{action:"get",page_id:t.id,url:t.url,created_time:t.created_time,last_edited_time:t.last_edited_time,archived:t.archived,properties:i,content:o,block_count:r.length}}async function _e(a,e){if(!e.page_id)throw new c("page_id is required for update action","VALIDATION_ERROR","Provide page_id");let t={};if(e.icon&&(t.icon={type:"emoji",emoji:e.icon}),e.cover&&(t.cover={type:"external",external:{url:e.cover}}),e.archived!==void 0&&(t.archived=e.archived),(e.properties||e.title)&&(t.properties={},e.title&&(t.properties.title={title:[g(e.title)]}),e.properties)){let r=T(e.properties);t.properties={...t.properties,...r}}if(Object.keys(t).length>0&&await a.pages.update({page_id:e.page_id,...t}),e.content||e.append_content||e.prepend_content){if(e.content){let r=await m(i=>a.blocks.children.list({block_id:e.page_id,start_cursor:i,page_size:100}));await w(r,async i=>{await a.blocks.delete({block_id:i.id})});let o=h(e.content);o.length>0&&await a.blocks.children.append({block_id:e.page_id,children:o})}else if(e.append_content){let r=h(e.append_content);r.length>0&&await a.blocks.children.append({block_id:e.page_id,children:r})}else if(e.prepend_content){let r=await m(i=>a.blocks.children.list({block_id:e.page_id,start_cursor:i,page_size:1})),o=h(e.prepend_content);o.length>0&&(r[0]?.id?await a.blocks.children.append({block_id:e.page_id,children:o,after:void 0}):await a.blocks.children.append({block_id:e.page_id,children:o}))}}return{action:"update",page_id:e.page_id,updated:!0}}async function ge(a,e){let t=e.page_ids||(e.page_id?[e.page_id]:[]);if(t.length===0)throw new c("page_id or page_ids required","VALIDATION_ERROR","Provide at least one page ID");let r=e.action==="archive",o=await w(t,async i=>(await a.pages.update({page_id:i,archived:r}),{page_id:i,archived:r}),{batchSize:1,concurrency:5});return{action:e.action,processed:o.length,results:o}}async function me(a,e){let t=e.page_ids||(e.page_id?[e.page_id]:[]);if(t.length===0)throw new c("page_id or page_ids required","VALIDATION_ERROR","Provide at least one page ID");let r=await w(t,async o=>{let i=await a.pages.retrieve({page_id:o}),n=await m(s=>a.blocks.children.list({block_id:o,start_cursor:s,page_size:100})),d=await a.pages.create({parent:i.parent,properties:i.properties,icon:i.icon,cover:i.cover});return n.length>0&&await a.blocks.children.append({block_id:d.id,children:n}),{original_id:o,duplicate_id:d.id,url:d.url}},{batchSize:5,concurrency:3});return{action:"duplicate",processed:r.length,results:r}}async function U(a,e){return f(async()=>{switch(e.action){case"list":{let t=await m(r=>a.users.list({start_cursor:r,page_size:100}));return{action:"list",total:t.length,users:t.map(r=>({id:r.id,type:r.type,name:r.name||"Unknown",avatar_url:r.avatar_url,email:r.type==="person"?r.person?.email:void 0}))}}case"get":{if(!e.user_id)throw new c("user_id required for get action","VALIDATION_ERROR","Provide user_id");let t=await a.users.retrieve({user_id:e.user_id});return{action:"get",id:t.id,type:t.type,name:t.name||"Unknown",avatar_url:t.avatar_url,email:t.type==="person"?t.person?.email:void 0}}case"me":{let t=await a.users.retrieve({user_id:"me"});return{action:"me",id:t.id,type:t.type,name:t.name||"Bot",bot:t.bot}}case"from_workspace":{let t=await a.search({filter:{property:"object",value:"page"},page_size:100}),r=new Map;for(let i of t.results)i.created_by&&r.set(i.created_by.id,{id:i.created_by.id,type:i.created_by.object,source:"page_metadata"}),i.last_edited_by&&r.set(i.last_edited_by.id,{id:i.last_edited_by.id,type:i.last_edited_by.object,source:"page_metadata"});let o=Array.from(r.values());return{action:"from_workspace",total:o.length,users:o,note:'Users extracted from accessible pages. Use "me" action for bot info, or share more pages for more users.'}}default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: list, get, me, from_workspace")}})()}async function B(a,e){return f(async()=>{switch(e.action){case"info":{let t=await a.users.retrieve({user_id:"me"});return{action:"info",bot:{id:t.id,name:t.name||"Bot",type:t.type,owner:t.bot?.owner}}}case"search":{let t={query:e.query||""};e.filter?.object&&(t.filter={value:e.filter.object,property:"object"}),e.sort&&(t.sort={direction:e.sort.direction||"descending",timestamp:e.sort.timestamp||"last_edited_time"});let r=await m(i=>a.search({...t,start_cursor:i,page_size:100})),o=e.limit?r.slice(0,e.limit):r;return{action:"search",query:e.query,total:o.length,results:o.map(i=>({id:i.id,object:i.object,title:i.object==="page"?i.properties?.title?.title?.[0]?.plain_text||i.properties?.Name?.title?.[0]?.plain_text||"Untitled":i.title?.[0]?.plain_text||"Untitled",url:i.url,last_edited_time:i.last_edited_time}))}}default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: info, search")}})()}var Re=he(import.meta.url),N=fe(Re),M=N.endsWith("bin")?P(N,"..","build","src","docs"):P(N,"..","docs"),D=[{uri:"notion://docs/pages",name:"Pages Tool Docs",file:"pages.md"},{uri:"notion://docs/databases",name:"Databases Tool Docs",file:"databases.md"},{uri:"notion://docs/blocks",name:"Blocks Tool Docs",file:"blocks.md"},{uri:"notion://docs/users",name:"Users Tool Docs",file:"users.md"},{uri:"notion://docs/workspace",name:"Workspace Tool Docs",file:"workspace.md"},{uri:"notion://docs/comments",name:"Comments Tool Docs",file:"comments.md"},{uri:"notion://docs/content_convert",name:"Content Convert Tool Docs",file:"content_convert.md"}],$=[{name:"pages",description:"Page lifecycle: create, get, update, archive, restore, duplicate. Requires parent_id for create. Returns markdown content for get.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["create","get","update","archive","restore","duplicate"],description:"Action to perform"},page_id:{type:"string",description:"Page ID (required for most actions)"},page_ids:{type:"array",items:{type:"string"},description:"Multiple page IDs for batch operations"},title:{type:"string",description:"Page title"},content:{type:"string",description:"Markdown content"},append_content:{type:"string",description:"Markdown to append"},prepend_content:{type:"string",description:"Markdown to prepend"},parent_id:{type:"string",description:"Parent page or database ID"},properties:{type:"object",description:"Page properties (for database pages)"},icon:{type:"string",description:"Emoji icon"},cover:{type:"string",description:"Cover image URL"},archived:{type:"boolean",description:"Archive status"}},required:["action"]}},{name:"databases",description:"Database operations: create, get, query, create_page, update_page, delete_page, create_data_source, update_data_source, update_database. Databases contain data sources with schema and rows.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["create","get","query","create_page","update_page","delete_page","create_data_source","update_data_source","update_database"],description:"Action to perform"},database_id:{type:"string",description:"Database ID (container)"},data_source_id:{type:"string",description:"Data source ID (for update_data_source action)"},parent_id:{type:"string",description:"Parent page ID (for create/update_database)"},title:{type:"string",description:"Title (for database or data source)"},description:{type:"string",description:"Description"},properties:{type:"object",description:"Schema properties (for create/update data source)"},is_inline:{type:"boolean",description:"Display as inline (for create/update_database)"},icon:{type:"string",description:"Emoji icon (for update_database)"},cover:{type:"string",description:"Cover image URL (for update_database)"},filters:{type:"object",description:"Query filters (for query action)"},sorts:{type:"array",items:{type:"object"},description:"Query sorts"},limit:{type:"number",description:"Max query results"},search:{type:"string",description:"Smart search across text fields (for query)"},page_id:{type:"string",description:"Single page ID (for update_page)"},page_ids:{type:"array",items:{type:"string"},description:"Multiple page IDs (for delete_page)"},page_properties:{type:"object",description:"Page properties to update (for update_page)"},pages:{type:"array",items:{type:"object"},description:"Array of pages for bulk create/update"}},required:["action"]}},{name:"blocks",description:"Block-level content: get, children, append, update, delete. Page IDs are valid block IDs. Use for precise edits.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["get","children","append","update","delete"],description:"Action to perform"},block_id:{type:"string",description:"Block ID"},content:{type:"string",description:"Markdown content (for append/update)"}},required:["action","block_id"]}},{name:"users",description:"User info: list, get, me, from_workspace. Use from_workspace if list fails due to permissions.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["list","get","me","from_workspace"],description:"Action to perform"},user_id:{type:"string",description:"User ID (for get action)"}},required:["action"]}},{name:"workspace",description:"Workspace: info, search. Search returns pages/databases shared with integration. Use filter.object for type.",inputSchema:{type:"object",properties:{action:{type:"string",enum:["info","search"],description:"Action to perform"},query:{type:"string",description:"Search query"},filter:{type:"object",properties:{object:{type:"string",enum:["page","data_source"]}}},sort:{type:"object",properties:{direction:{type:"string",enum:["ascending","descending"]},timestamp:{type:"string",enum:["last_edited_time","created_time"]}}},limit:{type:"number",description:"Max results"}},required:["action"]}},{name:"comments",description:"Comments: list, create. Use page_id for new discussion, discussion_id for replies.",inputSchema:{type:"object",properties:{page_id:{type:"string",description:"Page ID"},discussion_id:{type:"string",description:"Discussion ID (for replies)"},action:{type:"string",enum:["list","create"],description:"Action to perform"},content:{type:"string",description:"Comment content (for create)"}},required:["action"]}},{name:"content_convert",description:"Convert: markdown-to-blocks, blocks-to-markdown. Most tools handle markdown automatically.",inputSchema:{type:"object",properties:{direction:{type:"string",enum:["markdown-to-blocks","blocks-to-markdown"],description:"Conversion direction"},content:{description:"Content to convert (string or array/JSON string)"}},required:["direction","content"]}},{name:"help",description:"Get full documentation for a tool. Use when compressed descriptions are insufficient.",inputSchema:{type:"object",properties:{tool_name:{type:"string",enum:["pages","databases","blocks","users","workspace","comments","content_convert"],description:"Tool to get documentation for"}},required:["tool_name"]}}];function z(a,e){let t=new xe({auth:e,notionVersion:"2025-09-03"});a.setRequestHandler(we,async()=>({tools:$})),a.setRequestHandler(be,async()=>({resources:D.map(r=>({uri:r.uri,name:r.name,mimeType:"text/markdown"}))})),a.setRequestHandler(ke,async r=>{let{uri:o}=r.params,i=D.find(d=>d.uri===o);if(!i)throw new c(`Resource not found: ${o}`,"RESOURCE_NOT_FOUND",`Available: ${D.map(d=>d.uri).join(", ")}`);let n=V(P(M,i.file),"utf-8");return{contents:[{uri:o,mimeType:"text/markdown",text:n}]}}),a.setRequestHandler(ye,async r=>{let{name:o,arguments:i}=r.params;if(!i)return{content:[{type:"text",text:"Error: No arguments provided"}],isError:!0};try{let n;switch(o){case"pages":n=await L(t,i);break;case"databases":n=await j(t,i);break;case"blocks":n=await A(t,i);break;case"users":n=await U(t,i);break;case"workspace":n=await B(t,i);break;case"comments":n=await q(t,i);break;case"content_convert":n=await S(i);break;case"help":{let d=i.tool_name,s=`${d}.md`;try{let u=V(P(M,s),"utf-8");n={tool:d,documentation:u}}catch{throw new c(`Documentation not found for: ${d}`,"DOC_NOT_FOUND","Check tool_name")}break}default:throw new c(`Unknown tool: ${o}`,"UNKNOWN_TOOL",`Available tools: ${$.map(d=>d.name).join(", ")}`)}return{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}catch(n){let d=n instanceof c?n:new c(n.message,"TOOL_ERROR","Check the error details and try again");return{content:[{type:"text",text:E(d)}],isError:!0}}})}async function H(){let a=process.env.NOTION_TOKEN;a||(console.error("NOTION_TOKEN environment variable is required"),console.error("Get your token from https://www.notion.so/my-integrations"),process.exit(1));let e=new Te({name:"@n24q02m/better-notion-mcp",version:"1.0.0"},{capabilities:{tools:{},resources:{}}});z(e,a);let t=new Ie;return await e.connect(t),e}async function ve(){try{await H(),process.on("SIGINT",()=>{console.error(`
|
|
11
|
+
Shutting down Better Notion MCP Server`),process.exit(0)})}catch(a){console.error("Failed to start server:",a),process.exit(1)}}ve();
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Supports data_sources architecture
|
|
4
4
|
*/
|
|
5
5
|
import { NotionMCPError, withErrorHandling } from '../helpers/errors.js';
|
|
6
|
-
import { autoPaginate } from '../helpers/pagination.js';
|
|
6
|
+
import { autoPaginate, processBatches } from '../helpers/pagination.js';
|
|
7
7
|
import { convertToNotionProperties } from '../helpers/properties.js';
|
|
8
8
|
import * as RichText from '../helpers/richtext.js';
|
|
9
9
|
/**
|
|
@@ -242,19 +242,18 @@ async function createDatabasePages(notion, input) {
|
|
|
242
242
|
if (items.length === 0) {
|
|
243
243
|
throw new NotionMCPError('pages or page_properties required', 'VALIDATION_ERROR', 'Provide items to create');
|
|
244
244
|
}
|
|
245
|
-
const results =
|
|
246
|
-
for (const item of items) {
|
|
245
|
+
const results = await processBatches(items, async (item) => {
|
|
247
246
|
const properties = convertToNotionProperties(item.properties);
|
|
248
247
|
const page = await notion.pages.create({
|
|
249
248
|
parent: { type: 'data_source_id', data_source_id: dataSourceId },
|
|
250
249
|
properties
|
|
251
250
|
});
|
|
252
|
-
|
|
251
|
+
return {
|
|
253
252
|
page_id: page.id,
|
|
254
253
|
url: page.url,
|
|
255
254
|
created: true
|
|
256
|
-
}
|
|
257
|
-
}
|
|
255
|
+
};
|
|
256
|
+
});
|
|
258
257
|
return {
|
|
259
258
|
action: 'create_page',
|
|
260
259
|
database_id: input.database_id,
|
|
@@ -273,8 +272,7 @@ async function updateDatabasePages(notion, input) {
|
|
|
273
272
|
if (items.length === 0) {
|
|
274
273
|
throw new NotionMCPError('pages or page_id+page_properties required', 'VALIDATION_ERROR', 'Provide items to update');
|
|
275
274
|
}
|
|
276
|
-
const results =
|
|
277
|
-
for (const item of items) {
|
|
275
|
+
const results = await processBatches(items, async (item) => {
|
|
278
276
|
if (!item.page_id) {
|
|
279
277
|
throw new NotionMCPError('page_id required for each item', 'VALIDATION_ERROR', 'Provide page_id');
|
|
280
278
|
}
|
|
@@ -283,11 +281,11 @@ async function updateDatabasePages(notion, input) {
|
|
|
283
281
|
page_id: item.page_id,
|
|
284
282
|
properties
|
|
285
283
|
});
|
|
286
|
-
|
|
284
|
+
return {
|
|
287
285
|
page_id: item.page_id,
|
|
288
286
|
updated: true
|
|
289
|
-
}
|
|
290
|
-
}
|
|
287
|
+
};
|
|
288
|
+
});
|
|
291
289
|
return {
|
|
292
290
|
action: 'update_page',
|
|
293
291
|
processed: results.length,
|
|
@@ -305,17 +303,16 @@ async function deleteDatabasePages(notion, input) {
|
|
|
305
303
|
if (pageIds.length === 0) {
|
|
306
304
|
throw new NotionMCPError('page_id or page_ids required', 'VALIDATION_ERROR', 'Provide page IDs to delete');
|
|
307
305
|
}
|
|
308
|
-
const results =
|
|
309
|
-
for (const pageId of pageIds) {
|
|
306
|
+
const results = await processBatches(pageIds, async (pageId) => {
|
|
310
307
|
await notion.pages.update({
|
|
311
308
|
page_id: pageId,
|
|
312
309
|
archived: true
|
|
313
310
|
});
|
|
314
|
-
|
|
311
|
+
return {
|
|
315
312
|
page_id: pageId,
|
|
316
313
|
deleted: true
|
|
317
|
-
}
|
|
318
|
-
}
|
|
314
|
+
};
|
|
315
|
+
}, { batchSize: 5, concurrency: 3 });
|
|
319
316
|
return {
|
|
320
317
|
action: 'delete_page',
|
|
321
318
|
processed: results.length,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"databases.js","sourceRoot":"","sources":["../../../../src/tools/composite/databases.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AA6ClD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,KAAqB;IACnE,OAAO,iBAAiB,CAAC,KAAK,IAAI,EAAE;QAClC,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,QAAQ;gBACX,OAAO,MAAM,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;YAE5C,KAAK,KAAK;gBACR,OAAO,MAAM,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;YAEzC,KAAK,OAAO;gBACV,OAAO,MAAM,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;YAE3C,KAAK,aAAa;gBAChB,OAAO,MAAM,mBAAmB,CAAC,MAAM,EAAE,KAAK,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,CAAC;QACf,OAAO,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAA;IACrD,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAA;IACtE,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,cAAc,CACtB,qBAAqB,EACrB,kBAAkB,EAClB,kEAAkE,CACnE,CAAA;IACH,CAAC;IAED,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;QAC5B,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,GAAG,OAAO;KACX,CAAC,CAAA;IAEF,OAAO;QACL,MAAM,EAAE,iBAAiB;QACzB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,OAAO,EAAE,IAAI;KACd,CAAA;AACH,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { NotionMCPError, withErrorHandling } from '../helpers/errors.js';
|
|
6
6
|
import { blocksToMarkdown, markdownToBlocks } from '../helpers/markdown.js';
|
|
7
|
-
import { autoPaginate } from '../helpers/pagination.js';
|
|
7
|
+
import { autoPaginate, processBatches } from '../helpers/pagination.js';
|
|
8
8
|
import { convertToNotionProperties } from '../helpers/properties.js';
|
|
9
9
|
import * as RichText from '../helpers/richtext.js';
|
|
10
10
|
/**
|
|
@@ -189,9 +189,9 @@ async function updatePage(notion, input) {
|
|
|
189
189
|
start_cursor: cursor,
|
|
190
190
|
page_size: 100
|
|
191
191
|
}));
|
|
192
|
-
|
|
192
|
+
await processBatches(existingBlocks, async (block) => {
|
|
193
193
|
await notion.blocks.delete({ block_id: block.id });
|
|
194
|
-
}
|
|
194
|
+
});
|
|
195
195
|
const newBlocks = markdownToBlocks(input.content);
|
|
196
196
|
if (newBlocks.length > 0) {
|
|
197
197
|
await notion.blocks.children.append({
|
|
@@ -250,14 +250,13 @@ async function archivePage(notion, input) {
|
|
|
250
250
|
throw new NotionMCPError('page_id or page_ids required', 'VALIDATION_ERROR', 'Provide at least one page ID');
|
|
251
251
|
}
|
|
252
252
|
const archived = input.action === 'archive';
|
|
253
|
-
const results =
|
|
254
|
-
for (const pageId of pageIds) {
|
|
253
|
+
const results = await processBatches(pageIds, async (pageId) => {
|
|
255
254
|
await notion.pages.update({
|
|
256
255
|
page_id: pageId,
|
|
257
256
|
archived
|
|
258
257
|
});
|
|
259
|
-
|
|
260
|
-
}
|
|
258
|
+
return { page_id: pageId, archived };
|
|
259
|
+
}, { batchSize: 1, concurrency: 5 });
|
|
261
260
|
return {
|
|
262
261
|
action: input.action,
|
|
263
262
|
processed: results.length,
|
|
@@ -277,8 +276,8 @@ async function duplicatePage(notion, input) {
|
|
|
277
276
|
if (pageIds.length === 0) {
|
|
278
277
|
throw new NotionMCPError('page_id or page_ids required', 'VALIDATION_ERROR', 'Provide at least one page ID');
|
|
279
278
|
}
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
// Process duplicates in batches to improve performance while respecting rate limits
|
|
280
|
+
const results = await processBatches(pageIds, async (pageId) => {
|
|
282
281
|
// Get original page
|
|
283
282
|
const originalPage = await notion.pages.retrieve({ page_id: pageId });
|
|
284
283
|
// Get original content
|
|
@@ -301,12 +300,12 @@ async function duplicatePage(notion, input) {
|
|
|
301
300
|
children: originalBlocks
|
|
302
301
|
});
|
|
303
302
|
}
|
|
304
|
-
|
|
303
|
+
return {
|
|
305
304
|
original_id: pageId,
|
|
306
305
|
duplicate_id: duplicatePage.id,
|
|
307
306
|
url: duplicatePage.url
|
|
308
|
-
}
|
|
309
|
-
}
|
|
307
|
+
};
|
|
308
|
+
}, { batchSize: 5, concurrency: 3 });
|
|
310
309
|
return {
|
|
311
310
|
action: 'duplicate',
|
|
312
311
|
processed: results.length,
|