cortexflow-notion 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,7 @@
1
+ """cortexflow-notion — example CortexFlow plugin: Notion search."""
2
+
3
+ from cortexflow_notion.plugin import NotionPlugin
4
+ from cortexflow_notion.tool import NotionSearchTool
5
+
6
+ __all__ = ["NotionPlugin", "NotionSearchTool"]
7
+ __version__ = "0.1.0"
@@ -0,0 +1,28 @@
1
+ """NotionPlugin — registers NotionSearchTool with the CortexFlow gateway."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+
7
+ from cortexflow_sdk import Plugin, PluginMetadata
8
+
9
+ from cortexflow_notion.tool import NotionSearchTool
10
+
11
+
12
+ class NotionPlugin(Plugin):
13
+ """Adds a notion_search tool. Reads NOTION_TOKEN from the environment."""
14
+
15
+ metadata = PluginMetadata(
16
+ name="cortexflow-notion",
17
+ version="0.1.0",
18
+ plugin_type="tool",
19
+ description="Search Notion pages and databases.",
20
+ permissions=["network"],
21
+ homepage="https://github.com/TheAmitChandra/CortexFlow",
22
+ )
23
+
24
+ def __init__(self) -> None:
25
+ self._token = os.getenv("NOTION_TOKEN")
26
+
27
+ def get_tools(self):
28
+ return [NotionSearchTool(token=self._token)]
@@ -0,0 +1,77 @@
1
+ """NotionSearchTool — searches Notion pages and databases by query."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from cortexflow_sdk import Tool, ToolResult
8
+
9
+ _SEARCH_URL = "https://api.notion.com/v1/search"
10
+ _NOTION_VERSION = "2022-06-28"
11
+
12
+
13
+ def _extract_title(result: dict[str, Any]) -> str:
14
+ """Pull the plain-text title out of a Notion page/database object."""
15
+ for prop in result.get("properties", {}).values():
16
+ if prop.get("type") == "title":
17
+ texts = prop.get("title", [])
18
+ return "".join(t.get("plain_text", "") for t in texts) or "(untitled)"
19
+ return "(untitled)"
20
+
21
+
22
+ class NotionSearchTool(Tool):
23
+ """Searches Notion pages and databases shared with the integration."""
24
+
25
+ name = "notion_search"
26
+ description = "Search Notion pages and databases by query text."
27
+ parameters = {
28
+ "query": {"type": "str", "description": "Search text", "required": True},
29
+ "limit": {"type": "int", "description": "Max results to return (default 10)", "required": False},
30
+ }
31
+ permissions = ["network"]
32
+
33
+ def __init__(self, token: str | None = None) -> None:
34
+ self._token = token
35
+
36
+ async def execute(self, query: str, limit: int = 10, **_) -> ToolResult:
37
+ if not self._token:
38
+ return ToolResult(tool=self.name, output=None, error="NOTION_TOKEN not set")
39
+
40
+ try:
41
+ import httpx
42
+ except ImportError:
43
+ return ToolResult(tool=self.name, output=None, error="pip install httpx")
44
+
45
+ headers = {
46
+ "Authorization": f"Bearer {self._token}",
47
+ "Notion-Version": _NOTION_VERSION,
48
+ "Content-Type": "application/json",
49
+ }
50
+
51
+ try:
52
+ async with httpx.AsyncClient() as client:
53
+ resp = await client.post(
54
+ _SEARCH_URL,
55
+ headers=headers,
56
+ json={"query": query, "page_size": min(limit, 100)},
57
+ timeout=10.0,
58
+ )
59
+ resp.raise_for_status()
60
+ data = resp.json()
61
+ except Exception as exc:
62
+ return ToolResult(tool=self.name, output=None, error=str(exc))
63
+
64
+ results = [
65
+ {
66
+ "id": r.get("id", ""),
67
+ "type": r.get("object", "unknown"),
68
+ "url": r.get("url", ""),
69
+ "title": _extract_title(r),
70
+ }
71
+ for r in data.get("results", [])[:limit]
72
+ ]
73
+ return ToolResult(
74
+ tool=self.name,
75
+ output=results,
76
+ metadata={"query": query, "count": len(results)},
77
+ )
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: cortexflow-notion
3
+ Version: 0.1.0
4
+ Summary: CortexFlow plugin — search Notion pages and databases.
5
+ Author-email: Amit Chandra <amit.vervebot@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: cortexflow-sdk>=0.1.0
11
+ Requires-Dist: httpx>=0.27.0
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8.2.0; extra == "dev"
14
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
15
+ Dynamic: license-file
16
+
17
+ # cortexflow-notion
18
+
19
+ Example CortexFlow plugin: a `notion_search` tool that searches Notion pages
20
+ and databases shared with your Notion integration.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install -e ./cortexflow-sdk # not yet on PyPI
26
+ pip install -e examples/plugins/cortexflow-notion
27
+ ```
28
+
29
+ ## Setup
30
+
31
+ 1. Create a Notion integration at https://www.notion.so/my-integrations
32
+ 2. Share the pages/databases you want searchable with that integration
33
+ 3. Set `NOTION_TOKEN` in your environment to the integration's secret
34
+
35
+ ## Usage
36
+
37
+ ```python
38
+ from cortexflow_notion import NotionSearchTool
39
+
40
+ tool = NotionSearchTool(token="secret_...")
41
+ result = await tool.execute(query="Q3 roadmap", limit=5)
42
+ print(result.output)
43
+ ```
44
+
45
+ Once installed alongside the CortexFlow gateway, `PluginRegistry.discover()`
46
+ finds it via the `cortexflow.plugins` entry point declared in
47
+ `pyproject.toml`.
@@ -0,0 +1,9 @@
1
+ cortexflow_notion/__init__.py,sha256=Q4g1P_ycScOrQ0ldix_GPGb4ii_Tag0L1Gr8YQkFIXM,243
2
+ cortexflow_notion/plugin.py,sha256=a6vRnPi9ZuZp6xjWZXcj12mIsxnAmGMRrSyrpkeXBls,779
3
+ cortexflow_notion/tool.py,sha256=JXbkZNxotPQW5ikR6Php_5Fky4uB_h1yr_K9gcyK-e0,2623
4
+ cortexflow_notion-0.1.0.dist-info/licenses/LICENSE,sha256=7Dz5G7L1S2nxC1KQDChyyWKVx4NDmJJDf-KNruUtrHk,1069
5
+ cortexflow_notion-0.1.0.dist-info/METADATA,sha256=lgNqqImmpNZkYKQVv7ud82p12odBAR4WlytKA1RO6Iw,1345
6
+ cortexflow_notion-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ cortexflow_notion-0.1.0.dist-info/entry_points.txt,sha256=kbp9BHhk9gkebuu_8BlsQaIoAM8T8tkqd8Tnt8057hg,79
8
+ cortexflow_notion-0.1.0.dist-info/top_level.txt,sha256=2F6TccHK78WLJScQExeaXGE-0r-LaYyoySmSj9Ykpjs,18
9
+ cortexflow_notion-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [cortexflow.plugins]
2
+ cortexflow-notion = cortexflow_notion.plugin:NotionPlugin
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Amit Chandra
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.
@@ -0,0 +1 @@
1
+ cortexflow_notion