Class NotionTools

java.lang.Object
com.tnsai.tools.productivity.NotionTools

public class NotionTools extends Object
Function-shape Notion tools — page + database operations via the Notion REST API v1 (version pinned to 2022-06-28). Replaces the legacy NotionTool (single dispatched tool).
MethodEndpointIdempotent
notionSearch(java.lang.String)POST /searchtrue
notionGetPage(java.lang.String)GET /pages/{id}true
notionQueryDatabase(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>)POST /databases/{id}/querytrue
notionCreatePage(java.lang.String, java.lang.String, java.lang.String)POST /pagesfalse (creates a page)

Requires NOTION_API_KEY (Notion integration token, starts with secret_). Pin Notion-Version header so the response shape stays predictable across Notion API releases.

Since:
0.5.7 (Phase 2 batch 19a — built-in tool migration to function shape, see #188)
  • Constructor Details

    • NotionTools

      public NotionTools()
      Default constructor — picks NOTION_API_KEY from env.
    • NotionTools

      public NotionTools(String apiKey)
      Explicit-key constructor.
    • NotionTools

      public NotionTools(String apiKey, okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper)
      Full constructor for tests / shared HTTP.
  • Method Details

    • notionSearch

      @Tool(name="notion_search", description="Search across the Notion workspace by free-text {query}. Matches both pages and databases. Returns the raw JSON response with results array. Requires NOTION_API_KEY.", keywords={"notion","search","workspace","find"}, idempotent=true) public String notionSearch(@ToolParam(description="Free-text search query") String query) throws IOException
      Throws:
      IOException
    • notionGetPage

      @Tool(name="notion_get_page", description="Fetch a Notion page by id. Returns the raw JSON page object with properties + parent + url. Note this fetches metadata; for the page\'s body content blocks use the /blocks/{id}/children endpoint via http_request. Requires NOTION_API_KEY.", keywords={"notion","page","get","read"}, idempotent=true) public String notionGetPage(@ToolParam(description="Notion page id (UUID)") String pageId) throws IOException
      Throws:
      IOException
    • notionQueryDatabase

      @Tool(name="notion_query_database", description="Query a Notion database. Optional {filter} is a JSON filter object per the Notion API filter spec (e.g. { \"property\": \"Status\", \"select\": { \"equals\": \"Done\" } }). Returns the raw JSON results array.", keywords={"notion","database","query","filter"}, idempotent=true) public String notionQueryDatabase(@ToolParam(description="Notion database id") String databaseId, @ToolParam(description="Optional Notion filter object",required=false) Map<String,Object> filter) throws IOException
      Throws:
      IOException
    • notionCreatePage

      @Tool(name="notion_create_page", description="Create a new Notion page under {parentId} with a {title}. Optional {content} adds a single paragraph block as the page body. Returns the raw JSON of the created page (includes id + url). NOT idempotent \u2014 every call creates a new page even with the same arguments.", keywords={"notion","create","page","new"}, idempotent=false) public String notionCreatePage(@ToolParam(description="Parent page id (the new page becomes its child)") String parentId, @ToolParam(description="Page title") String title, @ToolParam(description="Optional page body (single paragraph)",required=false,defaultValue="") String content) throws IOException
      Throws:
      IOException