Skip to content

Commit a579034

Browse files
authored
Merge pull request #36 from SugiKent/feature/tool-args
add enabledTools args
2 parents 98a1916 + 66eda70 commit a579034

File tree

5 files changed

+311
-24
lines changed

5 files changed

+311
-24
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ or
6464
- `NOTION_API_TOKEN` (required): Your Notion API integration token.
6565
- `NOTION_MARKDOWN_CONVERSION`: Set to "true" to enable experimental Markdown conversion. This can significantly reduce token consumption when viewing content, but may cause issues when trying to edit page content.
6666

67+
## Command Line Arguments
68+
69+
- `--enabledTools`: Comma-separated list of tools to enable (e.g. "notion_retrieve_page,notion_query_database"). When specified, only the listed tools will be available. If not specified, all tools are enabled.
70+
71+
Read-only tools example (copy-paste friendly):
72+
```bash
73+
node build/index.js --enabledTools=notion_retrieve_block,notion_retrieve_block_children,notion_retrieve_page,notion_query_database,notion_retrieve_database,notion_search,notion_list_all_users,notion_retrieve_user,notion_retrieve_bot_user,notion_retrieve_comments
74+
```
75+
6776
## Advanced Configuration
6877

6978
### Markdown Conversion

notion/package-lock.json

+213-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notion/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
},
2929
"devDependencies": {
3030
"@types/node": "^20.11.24",
31-
"typescript": "^5.3.3"
31+
"@types/yargs": "^17.0.33",
32+
"typescript": "^5.3.3",
33+
"yargs": "^17.7.2"
3234
}
3335
}

notion/src/client.test.ts

+39
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
import { expect, test, describe, vi, beforeEach } from "vitest";
22
import { NotionClientWrapper } from "./index.js";
33
import { PageResponse } from "./types/index.js";
4+
import { filterTools } from "./index.js";
45

56
vi.mock("./markdown/index.js", () => ({
67
convertToMarkdown: vi.fn().mockReturnValue("# Test"),
78
}));
89

10+
// Mock tool list
11+
const mockInputSchema = { type: "object" as const }
12+
const mockTools = [
13+
{
14+
name: "notion_retrieve_block",
15+
inputSchema: mockInputSchema
16+
},
17+
{
18+
name: "notion_retrieve_page",
19+
inputSchema: mockInputSchema
20+
},
21+
{
22+
name: "notion_query_database",
23+
inputSchema: mockInputSchema
24+
}
25+
];
926
global.fetch = vi.fn();
1027

1128
describe("NotionClientWrapper", () => {
@@ -162,4 +179,26 @@ describe("NotionClientWrapper", () => {
162179

163180
expect(convertToMarkdown).toHaveBeenCalledWith(response);
164181
});
182+
183+
describe("filterTools", () => {
184+
test("should return all tools when no filter specified", () => {
185+
const result = filterTools(mockTools);
186+
expect(result).toEqual(mockTools);
187+
});
188+
189+
test("should filter tools based on enabledTools", () => {
190+
const enabledToolsSet = new Set(["notion_retrieve_block", "notion_query_database"]);
191+
const result = filterTools(mockTools, enabledToolsSet);
192+
expect(result).toEqual([
193+
{ name: "notion_retrieve_block", inputSchema: mockInputSchema },
194+
{ name: "notion_query_database", inputSchema: mockInputSchema }
195+
]);
196+
});
197+
198+
test("should return empty array when no tools match", () => {
199+
const enabledToolsSet = new Set(["non_existent_tool"]);
200+
const result = filterTools(mockTools, enabledToolsSet);
201+
expect(result).toEqual([]);
202+
});
203+
});
165204
});

0 commit comments

Comments
 (0)