@n24q02m/better-notion-mcp 2.6.1 → 2.6.3
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/README.md +23 -4
- package/bin/cli.mjs +4 -4
- package/build/src/docs/databases.md +16 -0
- package/build/src/docs/users.md +3 -2
- package/build/src/docs/workspace.md +3 -3
- package/build/src/init-server.d.ts.map +1 -1
- package/build/src/init-server.js +16 -1
- package/build/src/init-server.js.map +1 -1
- package/build/src/tools/composite/pages.d.ts +0 -1
- package/build/src/tools/composite/pages.d.ts.map +1 -1
- package/build/src/tools/composite/pages.js +19 -27
- package/build/src/tools/composite/pages.js.map +1 -1
- package/build/src/tools/composite/workspace.d.ts +1 -1
- package/build/src/tools/composite/workspace.d.ts.map +1 -1
- package/build/src/tools/registry.d.ts +1 -1
- package/build/src/tools/registry.d.ts.map +1 -1
- package/build/src/tools/registry.js +7 -4
- package/build/src/tools/registry.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/build/src/tools/composite/search.d.ts +0 -23
- package/build/src/tools/composite/search.d.ts.map +0 -1
- package/build/src/tools/composite/search.js +0 -94
- package/build/src/tools/composite/search.js.map +0 -1
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
Get your token: <https://www.notion.so/my-integrations> → Create integration → Copy token → Share pages
|
|
29
29
|
|
|
30
|
-
###
|
|
30
|
+
### npx (Recommended)
|
|
31
31
|
|
|
32
32
|
```json
|
|
33
33
|
{
|
|
@@ -36,7 +36,7 @@ Get your token: <https://www.notion.so/my-integrations> → Create integration
|
|
|
36
36
|
"command": "npx",
|
|
37
37
|
"args": ["-y", "@n24q02m/better-notion-mcp@latest"],
|
|
38
38
|
"env": {
|
|
39
|
-
"NOTION_TOKEN": "
|
|
39
|
+
"NOTION_TOKEN": "ntn_..."
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -50,9 +50,14 @@ Get your token: <https://www.notion.so/my-integrations> → Create integration
|
|
|
50
50
|
"mcpServers": {
|
|
51
51
|
"better-notion": {
|
|
52
52
|
"command": "docker",
|
|
53
|
-
"args": [
|
|
53
|
+
"args": [
|
|
54
|
+
"run", "-i", "--rm",
|
|
55
|
+
"--name", "mcp-notion",
|
|
56
|
+
"-e", "NOTION_TOKEN",
|
|
57
|
+
"n24q02m/better-notion-mcp:latest"
|
|
58
|
+
],
|
|
54
59
|
"env": {
|
|
55
|
-
"NOTION_TOKEN": "
|
|
60
|
+
"NOTION_TOKEN": "ntn_..."
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
}
|
|
@@ -90,6 +95,20 @@ Get your token: <https://www.notion.so/my-integrations> → Create integration
|
|
|
90
95
|
{"name": "help", "tool_name": "pages"}
|
|
91
96
|
```
|
|
92
97
|
|
|
98
|
+
### MCP Resources (Tier 3)
|
|
99
|
+
|
|
100
|
+
Clients that support MCP Resources can load full tool documentation:
|
|
101
|
+
|
|
102
|
+
| URI | Description |
|
|
103
|
+
|-----|-------------|
|
|
104
|
+
| `notion://docs/pages` | Pages tool docs |
|
|
105
|
+
| `notion://docs/databases` | Databases tool docs |
|
|
106
|
+
| `notion://docs/blocks` | Blocks tool docs |
|
|
107
|
+
| `notion://docs/users` | Users tool docs |
|
|
108
|
+
| `notion://docs/workspace` | Workspace tool docs |
|
|
109
|
+
| `notion://docs/comments` | Comments tool docs |
|
|
110
|
+
| `notion://docs/content_convert` | Content Convert tool docs |
|
|
111
|
+
|
|
93
112
|
---
|
|
94
113
|
|
|
95
114
|
## Limitations
|
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{
|
|
3
|
+
import{readFileSync as Te}from"node:fs";import{dirname as Ie,join as ve}from"node:path";import{fileURLToPath as Oe}from"node:url";import{Server as Pe}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as Ne}from"@modelcontextprotocol/sdk/server/stdio.js";import{readFileSync as B}from"node:fs";import{dirname as fe,join as O}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 z(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",z(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(a.body?.message||"Invalid request parameters","VALIDATION_ERROR","Check the API documentation for valid parameter formats",a.body);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
|
|
7
|
+
Details: ${JSON.stringify(a.details,null,2)}`),e}function g(a){return async(...e)=>{try{return await a(...e)}catch(t){throw F(t)}}}function h(a){let e=a.split(`
|
|
8
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(P(1,n.slice(2)));else if(n.startsWith("## "))t.push(P(2,n.slice(3)));else if(n.startsWith("### "))t.push(P(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
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],l=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 u=a.slice(d+1,p),x=a.slice(_+1,k);e.push({type:"text",text:{content:u,link:{url:x}},annotations:{bold:r,italic:o,strikethrough:n,underline:!1,code:i,color:"default"}}),d=k;continue}}if(s==="*"&&l==="*"){t&&(e.push(b(t,{bold:r,italic:o,code:i,strikethrough:n})),t=""),r=!r,d++;continue}else if(s==="*"&&l!=="*"){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==="~"&&l==="~"){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 P(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 l=i.slice(d,d+o).map(_=>Promise.all(_.map(e))),p=await Promise.all(l);n.push(...p.flat())}return n}async function C(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 A(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: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 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,e){let t={};for(let[r,o]of Object.entries(a)){if(o==null){t[r]=o;continue}if(typeof o=="string"){let i=e?.[r];i==="title"?t[r]={title:[g(o)]}:i==="rich_text"?t[r]={rich_text:[g(o)]}:i==="date"?t[r]={date:{start:o}}:i==="url"?t[r]={url:o}:i==="email"?t[r]={email:o}:i==="phone_number"?t[r]={phone_number:o}:r==="Name"||r==="Title"||r.toLowerCase()==="title"?t[r]={title:[g(o)]}:t[r]={select:{name:o}}}else typeof o=="number"?t[r]={number:o}:typeof o=="boolean"?t[r]={checkbox:o}:Array.isArray(o)&&o.length>0&&typeof o[0]=="string"?t[r]={multi_select:o.map(i=>({name:i}))}:t[r]=o}return t}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(l=>l.name):s.type==="multi_select"&&s.multi_select?.options?r[n].options=s.multi_select.options.map(l=>l.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 l=await a.dataSources.retrieve({data_source_id:r}),p=Object.entries(l.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 l=>{let p=await a.dataSources.query({...i,start_cursor:l,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(l=>{let p={page_id:l.id,url:l.url};for(let[_,k]of Object.entries(l.properties)){let u=k;u.type==="title"&&u.title?p[_]=u.title.map(x=>x.plain_text).join(""):u.type==="rich_text"&&u.rich_text?p[_]=u.rich_text.map(x=>x.plain_text).join(""):u.type==="select"&&u.select?p[_]=u.select.name:u.type==="multi_select"&&u.multi_select?p[_]=u.multi_select.map(x=>x.name):u.type==="number"?p[_]=u.number:u.type==="checkbox"?p[_]=u.checkbox:u.type==="url"?p[_]=u.url:u.type==="email"?p[_]=u.email:u.type==="phone_number"?p[_]=u.phone_number:u.type==="date"&&u.date&&(p[_]=u.date.start+(u.date.end?` to ${u.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=await a.dataSources.retrieve({data_source_id:r}),i={};if(o.properties)for(let[s,l]of Object.entries(o.properties))i[s]=l.type;let n=e.pages||(e.page_properties?[{properties:e.page_properties}]:[]);if(n.length===0)throw new c("pages or page_properties required","VALIDATION_ERROR","Provide items to create");let d=await w(n,async s=>{let l=T(s.properties,i),p=await a.pages.create({parent:{type:"data_source_id",data_source_id:r},properties:l});return{page_id:p.id,url:p.url,created:!0}});return{action:"create_page",database_id:e.database_id,data_source_id:r,processed:d.length,results:d}}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 U(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(l=>l.plain_text).join(""):s.type==="rich_text"&&s.rich_text?i[n]=s.rich_text.map(l=>l.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(l=>l.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 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 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 H(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),V=N.endsWith("bin")?O(N,"..","build","src","docs"):O(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"}],M=[{name:"pages",description:"Page lifecycle: create, get, update, archive, restore, duplicate. Requires parent_id for create. Returns markdown content for get.",annotations:{title:"Pages",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},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.",annotations:{title:"Databases",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},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.",annotations:{title:"Blocks",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},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.",annotations:{title:"Users",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},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.",annotations:{title:"Workspace",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},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.",annotations:{title:"Comments",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},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.",annotations:{title:"Content Convert",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},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.",annotations:{title:"Help",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},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 xe({auth:e,notionVersion:"2025-09-03"});a.setRequestHandler(we,async()=>({tools:M})),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=B(O(V,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 U(t,i);break;case"databases":n=await j(t,i);break;case"blocks":n=await C(t,i);break;case"users":n=await L(t,i);break;case"workspace":n=await H(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 l=B(O(V,s),"utf-8");n={tool:d,documentation:l}}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: ${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:E(d)}],isError:!0}}})}async function W(){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:{}}});$(e,a);let t=new Ie;return await e.connect(t),e}async function ve(){try{await W(),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)}}
|
|
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],l=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 u=a.slice(d+1,p),x=a.slice(_+1,k);e.push({type:"text",text:{content:u,link:{url:x}},annotations:{bold:r,italic:o,strikethrough:n,underline:!1,code:i,color:"default"}}),d=k;continue}}if(s==="*"&&l==="*"){t&&(e.push(b(t,{bold:r,italic:o,code:i,strikethrough:n})),t=""),r=!r,d++;continue}else if(s==="*"&&l!=="*"){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==="~"&&l==="~"){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 P(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 f(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 l=i.slice(d,d+o).map(_=>Promise.all(_.map(e))),p=await Promise.all(l);n.push(...p.flat())}return n}async function A(a,e){return g(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 f(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 m(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 S(a,e){return g(async()=>{switch(e.action){case"list":{if(!e.page_id)throw new Error("page_id required for list action");let t=await f(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:[m(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 g(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,e){let t={};for(let[r,o]of Object.entries(a)){if(o==null){t[r]=o;continue}if(typeof o=="string"){let i=e?.[r];i==="title"?t[r]={title:[m(o)]}:i==="rich_text"?t[r]={rich_text:[m(o)]}:i==="date"?t[r]={date:{start:o}}:i==="url"?t[r]={url:o}:i==="email"?t[r]={email:o}:i==="phone_number"?t[r]={phone_number:o}:r==="Name"||r==="Title"||r.toLowerCase()==="title"?t[r]={title:[m(o)]}:t[r]={select:{name:o}}}else typeof o=="number"?t[r]={number:o}:typeof o=="boolean"?t[r]={checkbox:o}:Array.isArray(o)&&o.length>0&&typeof o[0]=="string"?t[r]={multi_select:o.map(i=>({name:i}))}:t[r]=o}return t}async function j(a,e){return g(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:[m(e.title)],initial_data_source:{properties:e.properties}};e.description&&(t.description=[m(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(l=>l.name):s.type==="multi_select"&&s.multi_select?.options?r[n].options=s.multi_select.options.map(l=>l.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 l=await a.dataSources.retrieve({data_source_id:r}),p=Object.entries(l.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 f(async l=>{let p=await a.dataSources.query({...i,start_cursor:l,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(l=>{let p={page_id:l.id,url:l.url};for(let[_,k]of Object.entries(l.properties)){let u=k;u.type==="title"&&u.title?p[_]=u.title.map(x=>x.plain_text).join(""):u.type==="rich_text"&&u.rich_text?p[_]=u.rich_text.map(x=>x.plain_text).join(""):u.type==="select"&&u.select?p[_]=u.select.name:u.type==="multi_select"&&u.multi_select?p[_]=u.multi_select.map(x=>x.name):u.type==="number"?p[_]=u.number:u.type==="checkbox"?p[_]=u.checkbox:u.type==="url"?p[_]=u.url:u.type==="email"?p[_]=u.email:u.type==="phone_number"?p[_]=u.phone_number:u.type==="date"&&u.date&&(p[_]=u.date.start+(u.date.end?` to ${u.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=await a.dataSources.retrieve({data_source_id:r}),i={};if(o.properties)for(let[s,l]of Object.entries(o.properties))i[s]=l.type;let n=e.pages||(e.page_properties?[{properties:e.page_properties}]:[]);if(n.length===0)throw new c("pages or page_properties required","VALIDATION_ERROR","Provide items to create");let d=await w(n,async s=>{let l=T(s.properties,i),p=await a.pages.create({parent:{type:"data_source_id",data_source_id:r},properties:l});return{page_id:p.id,url:p.url,created:!0}});return{action:"create_page",database_id:e.database_id,data_source_id:r,processed:d.length,results:d}}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:[m(e.title)],properties:e.properties};return e.description&&(t.description=[m(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=[m(e.title)]),e.description&&(t.description=[m(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=[m(e.title)]),e.description&&(t.description=[m(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 U(a,e){return g(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 me(a,e);case"duplicate":return await ge(a,e);default:throw new c(`Unknown action: ${e.action}`,"VALIDATION_ERROR","Supported actions: create, get, update, archive, restore, 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:[m(e.title)]})):o={title:{title:[m(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 f(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(l=>l.plain_text).join(""):s.type==="rich_text"&&s.rich_text?i[n]=s.rich_text.map(l=>l.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(l=>l.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:[m(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){if(e.content){let r=await f(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})}}return{action:"update",page_id:e.page_id,updated:!0}}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=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 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=await w(t,async o=>{let i=await a.pages.retrieve({page_id:o}),n=await f(p=>a.blocks.children.list({block_id:o,start_cursor:p,page_size:100})),d=i.parent,s;d.type==="data_source_id"?s={type:"data_source_id",data_source_id:d.data_source_id}:d.type==="database_id"?s={type:"database_id",database_id:d.database_id}:d.type==="page_id"?s={type:"page_id",page_id:d.page_id}:s=d;let l=await a.pages.create({parent:s,properties:i.properties,icon:i.icon,cover:i.cover});return n.length>0&&await a.blocks.children.append({block_id:l.id,children:n}),{original_id:o,duplicate_id:l.id,url:l.url}},{batchSize:5,concurrency:3});return{action:"duplicate",processed:r.length,results:r}}async function L(a,e){return g(async()=>{switch(e.action){case"list":{let t=await f(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 H(a,e){return g(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 f(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),V=N.endsWith("bin")?O(N,"..","build","src","docs"):O(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"}],M=[{name:"pages",description:"Page lifecycle: create, get, update, archive, restore, duplicate. Requires parent_id for create. Returns markdown content for get.",annotations:{title:"Pages",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},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:"[Deprecated] Not supported by Notion API \u2014 use blocks tool to insert at specific position"},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.",annotations:{title:"Databases",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},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.",annotations:{title:"Blocks",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},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.",annotations:{title:"Users",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},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.",annotations:{title:"Workspace",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},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","database"]}}},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.",annotations:{title:"Comments",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},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.",annotations:{title:"Content Convert",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},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.",annotations:{title:"Help",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},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 xe({auth:e,notionVersion:"2025-09-03"});a.setRequestHandler(we,async()=>({tools:M})),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=B(O(V,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 U(t,i);break;case"databases":n=await j(t,i);break;case"blocks":n=await A(t,i);break;case"users":n=await L(t,i);break;case"workspace":n=await H(t,i);break;case"comments":n=await S(t,i);break;case"content_convert":n=await q(i);break;case"help":{let d=i.tool_name,s=`${d}.md`;try{let l=B(O(V,s),"utf-8");n={tool:d,documentation:l}}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: ${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:E(d)}],isError:!0}}})}var De=Oe(import.meta.url),Ee=Ie(De);function Ae(){try{let a=ve(Ee,"..","package.json");return JSON.parse(Te(a,"utf-8")).version??"0.0.0"}catch{return"0.0.0"}}async function W(){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 Pe({name:"@n24q02m/better-notion-mcp",version:Ae()},{capabilities:{tools:{},resources:{}}});$(e,a);let t=new Ne;return await e.connect(t),e}async function Ce(){try{await W(),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)}}Ce();
|
|
@@ -44,6 +44,22 @@ Database operations: create, get, query, create_page, update_page, delete_page,
|
|
|
44
44
|
{"action": "delete_page", "page_ids": ["yyy", "zzz"]}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
### update_database
|
|
48
|
+
Update database container metadata. To update schema properties, use `update_data_source` instead.
|
|
49
|
+
```json
|
|
50
|
+
{"action": "update_database", "database_id": "xxx", "title": "Updated Title", "icon": "📋"}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### create_data_source
|
|
54
|
+
```json
|
|
55
|
+
{"action": "create_data_source", "database_id": "xxx", "title": "Q2 Data", "properties": {"Status": {"select": {"options": [{"name": "Active"}]}}}}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### update_data_source
|
|
59
|
+
```json
|
|
60
|
+
{"action": "update_data_source", "data_source_id": "xxx", "title": "Renamed Source", "properties": {"Status": {"select": {"options": [{"name": "Active"}, {"name": "Archived"}]}}}}
|
|
61
|
+
```
|
|
62
|
+
|
|
47
63
|
## Parameters
|
|
48
64
|
- `database_id` - Database ID
|
|
49
65
|
- `data_source_id` - Data source ID
|
package/build/src/docs/users.md
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
User info: list, get, me, from_workspace.
|
|
5
5
|
|
|
6
6
|
## Important
|
|
7
|
-
- `list`
|
|
8
|
-
- Use `
|
|
7
|
+
- `list` and `get` require **Enterprise plan** or explicit `read_user` capability granted by workspace admin. Most integrations will get "Integration does not have ability to..." error.
|
|
8
|
+
- Use `me` to get the bot's own info (always works).
|
|
9
|
+
- Use `from_workspace` as a reliable fallback — extracts users from created_by/last_edited_by metadata in accessible pages (no special permissions needed).
|
|
9
10
|
|
|
10
11
|
## Actions
|
|
11
12
|
|
|
@@ -5,7 +5,7 @@ Workspace: info, search.
|
|
|
5
5
|
|
|
6
6
|
## Important
|
|
7
7
|
- Search returns only content **shared with integration**
|
|
8
|
-
- Use `filter.object = "
|
|
8
|
+
- Use `filter.object = "database"` for databases
|
|
9
9
|
|
|
10
10
|
## Actions
|
|
11
11
|
|
|
@@ -22,7 +22,7 @@ Returns bot owner, workspace details.
|
|
|
22
22
|
|
|
23
23
|
Search databases:
|
|
24
24
|
```json
|
|
25
|
-
{"action": "search", "query": "tasks", "filter": {"object": "
|
|
25
|
+
{"action": "search", "query": "tasks", "filter": {"object": "database"}}
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Sort results:
|
|
@@ -32,7 +32,7 @@ Sort results:
|
|
|
32
32
|
|
|
33
33
|
## Parameters
|
|
34
34
|
- `query` - Search query
|
|
35
|
-
- `filter.object` - "page" or "
|
|
35
|
+
- `filter.object` - "page" or "database"
|
|
36
36
|
- `sort.direction` - "ascending" or "descending"
|
|
37
37
|
- `sort.timestamp` - "last_edited_time" or "created_time"
|
|
38
38
|
- `limit` - Max results
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-server.d.ts","sourceRoot":"","sources":["../../src/init-server.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"init-server.d.ts","sourceRoot":"","sources":["../../src/init-server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAiBlE,wBAAsB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+B/B"}
|
package/build/src/init-server.js
CHANGED
|
@@ -2,9 +2,24 @@
|
|
|
2
2
|
* Better Notion MCP Server
|
|
3
3
|
* Using composite tools for human-friendly AI agent interactions
|
|
4
4
|
*/
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { dirname, join } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
5
8
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
6
9
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
7
10
|
import { registerTools } from './tools/registry.js';
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = dirname(__filename);
|
|
13
|
+
function getVersion() {
|
|
14
|
+
try {
|
|
15
|
+
const pkgPath = join(__dirname, '..', 'package.json');
|
|
16
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
17
|
+
return pkg.version ?? '0.0.0';
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return '0.0.0';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
8
23
|
export async function initServer() {
|
|
9
24
|
// Get Notion token from environment
|
|
10
25
|
const notionToken = process.env.NOTION_TOKEN;
|
|
@@ -16,7 +31,7 @@ export async function initServer() {
|
|
|
16
31
|
// Create MCP server
|
|
17
32
|
const server = new Server({
|
|
18
33
|
name: '@n24q02m/better-notion-mcp',
|
|
19
|
-
version:
|
|
34
|
+
version: getVersion()
|
|
20
35
|
}, {
|
|
21
36
|
capabilities: {
|
|
22
37
|
tools: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-server.js","sourceRoot":"","sources":["../../src/init-server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,oCAAoC;IACpC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAA;IAE5C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAC9D,OAAO,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAA;QAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,oBAAoB;IACpB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;QACE,IAAI,EAAE,4BAA4B;QAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"init-server.js","sourceRoot":"","sources":["../../src/init-server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAErC,SAAS,UAAU;IAC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AAO9C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAA;IAGzE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IAGnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,
|
|
1
|
+
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../../src/tools/composite/pages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAO9C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAA;IAGzE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IAGnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IAGd,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;GAEG;AACH,wBAAsB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CA2B3E"}
|
|
@@ -25,7 +25,7 @@ export async function pages(notion, input) {
|
|
|
25
25
|
case 'duplicate':
|
|
26
26
|
return await duplicatePage(notion, input);
|
|
27
27
|
default:
|
|
28
|
-
throw new NotionMCPError(`Unknown action: ${input.action}`, 'VALIDATION_ERROR', 'Supported actions: create, get, update, archive, restore,
|
|
28
|
+
throw new NotionMCPError(`Unknown action: ${input.action}`, 'VALIDATION_ERROR', 'Supported actions: create, get, update, archive, restore, duplicate');
|
|
29
29
|
}
|
|
30
30
|
})();
|
|
31
31
|
}
|
|
@@ -181,7 +181,7 @@ async function updatePage(notion, input) {
|
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
// Handle content updates
|
|
184
|
-
if (input.content || input.append_content
|
|
184
|
+
if (input.content || input.append_content) {
|
|
185
185
|
if (input.content) {
|
|
186
186
|
// Replace all content
|
|
187
187
|
const existingBlocks = await autoPaginate((cursor) => notion.blocks.children.list({
|
|
@@ -209,30 +209,6 @@ async function updatePage(notion, input) {
|
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
else if (input.prepend_content) {
|
|
213
|
-
const existingBlocks = await autoPaginate((cursor) => notion.blocks.children.list({
|
|
214
|
-
block_id: input.page_id,
|
|
215
|
-
start_cursor: cursor,
|
|
216
|
-
page_size: 1
|
|
217
|
-
}));
|
|
218
|
-
const newBlocks = markdownToBlocks(input.prepend_content);
|
|
219
|
-
if (newBlocks.length > 0) {
|
|
220
|
-
const firstBlockId = existingBlocks[0]?.id;
|
|
221
|
-
if (firstBlockId) {
|
|
222
|
-
await notion.blocks.children.append({
|
|
223
|
-
block_id: input.page_id,
|
|
224
|
-
children: newBlocks,
|
|
225
|
-
after: undefined
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
await notion.blocks.children.append({
|
|
230
|
-
block_id: input.page_id,
|
|
231
|
-
children: newBlocks
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
212
|
}
|
|
237
213
|
return {
|
|
238
214
|
action: 'update',
|
|
@@ -286,9 +262,25 @@ async function duplicatePage(notion, input) {
|
|
|
286
262
|
start_cursor: cursor,
|
|
287
263
|
page_size: 100
|
|
288
264
|
}));
|
|
265
|
+
// Sanitize parent - API response may include extra fields that
|
|
266
|
+
// the create endpoint rejects (e.g. database_id in data_source parent)
|
|
267
|
+
const rawParent = originalPage.parent;
|
|
268
|
+
let parent;
|
|
269
|
+
if (rawParent.type === 'data_source_id') {
|
|
270
|
+
parent = { type: 'data_source_id', data_source_id: rawParent.data_source_id };
|
|
271
|
+
}
|
|
272
|
+
else if (rawParent.type === 'database_id') {
|
|
273
|
+
parent = { type: 'database_id', database_id: rawParent.database_id };
|
|
274
|
+
}
|
|
275
|
+
else if (rawParent.type === 'page_id') {
|
|
276
|
+
parent = { type: 'page_id', page_id: rawParent.page_id };
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
parent = rawParent;
|
|
280
|
+
}
|
|
289
281
|
// Create duplicate
|
|
290
282
|
const duplicatePage = await notion.pages.create({
|
|
291
|
-
parent
|
|
283
|
+
parent,
|
|
292
284
|
properties: originalPage.properties,
|
|
293
285
|
icon: originalPage.icon,
|
|
294
286
|
cover: originalPage.cover
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../../../../src/tools/composite/pages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAA;AAuBlD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,MAAc,EAAE,KAAiB;IAC3D,OAAO,iBAAiB,CAAC,KAAK,IAAI,EAAE;QAClC,QAAQ,KAAK,CAAC,M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EAAE,SAAS,CAAC,OAAO,EAAE,CAAA;QAC1D,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,SAAS,CAAA;QACpB,CAAC;QAED,mBAAmB;QACnB,MAAM,aAAa,GAAQ,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;YACnD,MAAM;YACN,UAAU,EAAE,YAAY,CAAC,UAAU;YACnC,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,KAAK,EAAE,YAAY,CAAC,KAAK;SAC1B,CAAC,CAAA;QAEF,eAAe;QACf,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAClC,QAAQ,EAAE,aAAa,CAAC,EAAE;gBAC1B,QAAQ,EAAE,cAAqB;aAChC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO;YACL,WAAW,EAAE,MAAM;YACnB,YAAY,EAAE,aAAa,CAAC,EAAE;YAC9B,GAAG,EAAE,aAAa,CAAC,GAAG;SACvB,CAAA;IACH,CAAC,EACD,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CACjC,CAAA;IAED,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,OAAO,CAAC,MAAM;QACzB,OAAO;KACR,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../../src/tools/composite/workspace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAI9C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAA;IAGzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../../src/tools/composite/workspace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAI9C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAA;IAGzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;QAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,KAAK,CAAC,EAAE,GAAG,CAAA;KACZ,CAAA;IACD,IAAI,CAAC,EAAE;QACL,SAAS,CAAC,EAAE,WAAW,GAAG,YAAY,CAAA;QACtC,SAAS,CAAC,EAAE,kBAAkB,GAAG,cAAc,CAAA;KAChD,CAAA;IACD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,CA2EnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AA+RvE;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAyHhE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool Registry -
|
|
2
|
+
* Tool Registry - 8 Composite Tools
|
|
3
3
|
* Consolidated registration for maximum coverage with minimal tools
|
|
4
4
|
*/
|
|
5
5
|
import { readFileSync } from 'node:fs';
|
|
@@ -37,7 +37,7 @@ const RESOURCES = [
|
|
|
37
37
|
{ uri: 'notion://docs/content_convert', name: 'Content Convert Tool Docs', file: 'content_convert.md' }
|
|
38
38
|
];
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* 8 Tools covering 75% of Official Notion API
|
|
41
41
|
* Compressed descriptions for token optimization (~77% reduction)
|
|
42
42
|
*/
|
|
43
43
|
const TOOLS = [
|
|
@@ -64,7 +64,10 @@ const TOOLS = [
|
|
|
64
64
|
title: { type: 'string', description: 'Page title' },
|
|
65
65
|
content: { type: 'string', description: 'Markdown content' },
|
|
66
66
|
append_content: { type: 'string', description: 'Markdown to append' },
|
|
67
|
-
prepend_content: {
|
|
67
|
+
prepend_content: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: '[Deprecated] Not supported by Notion API — use blocks tool to insert at specific position'
|
|
70
|
+
},
|
|
68
71
|
parent_id: { type: 'string', description: 'Parent page or database ID' },
|
|
69
72
|
properties: { type: 'object', description: 'Page properties (for database pages)' },
|
|
70
73
|
icon: { type: 'string', description: 'Emoji icon' },
|
|
@@ -192,7 +195,7 @@ const TOOLS = [
|
|
|
192
195
|
filter: {
|
|
193
196
|
type: 'object',
|
|
194
197
|
properties: {
|
|
195
|
-
object: { type: 'string', enum: ['page', '
|
|
198
|
+
object: { type: 'string', enum: ['page', 'database'] }
|
|
196
199
|
}
|
|
197
200
|
},
|
|
198
201
|
sort: {
|