Notion ACTION
Query Data Source
Filter and sort the pages (rows) inside a Notion database (data source) by their property values. Discover exact property names and option values with Retrieve Database Schema first, then build a filter against them. A
filter is a JSON object: a single condition { "property": "Status", "select": { "equals": "Escaped" } }, or a compound { "and": [ ... ] } / { "or": [ ... ] }. The condition key matches the property type — e.g. select, status, multi_select, number ({ "greater_than": 5 }), checkbox ({ "equals": true }), rich_text/title ({ "contains": "..." }), date. Omit filter to return all rows. Provide the data source ID (use Search with filter: data_source to resolve a database name). See the documentation- Action
- Read only
- OAuth
- SDK
- MCP
IMPLEMENTATION
Call this tool
Connect a user's Notion account once, then configure and run Query Data Source from your backend or agent.
import { PipedreamClient } from "@pipedream/sdk"
const pd = new PipedreamClient({
projectId: process.env.PIPEDREAM_PROJECT_ID!,
clientId: process.env.PIPEDREAM_CLIENT_ID!,
clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
projectEnvironment: "production",
})
const result = await pd.actions.run({
id: "notion-query-database",
externalUserId: "{external_user_id}", // any stable ID for this user in your system
configuredProps: {
notion: { authProvisionId: "apn_xxxxxxx" },
dataSourceId: "Data Source ID",
filter: "Filter",
},
})
console.log(result)curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
-H "Content-Type: application/json" \
-H "X-PD-Environment: production" \
-H "Authorization: Bearer {access_token}" \
-d '{
"external_user_id": "{external_user_id}",
"id": "notion-query-database",
"configured_props": {
"notion": { "authProvisionId": "apn_xxxxxxx" },
"dataSourceId": "Data Source ID",
"filter": "Filter"
}
}'// accessToken: mint a short-lived token with the Connect SDK — see the MCP guide
const transport = new StreamableHTTPClientTransport(
new URL("https://remote.mcp.pipedream.net/v3"),
{
requestInit: {
headers: {
Authorization: `Bearer ${accessToken}`,
"x-pd-project-id": "{project_id}",
"x-pd-environment": "production",
"x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
"x-pd-app-slug": "notion",
},
},
},
)
const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)
const { tools } = await mcp.listTools()
// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
name: "notion-query-database",
arguments: {
dataSourceId: "Data Source ID",
filter: "Filter",
},
})SCHEMA
Inputs
Pipedream supplies the connected account. Your application provides the operation-specific values below. Dynamic inputs are resolved against that user's account.
| Property | Type | Description |
|---|---|---|
dataSourceId Data Source ID | string | The ID of the database's data source. Use Search ( filter: data_source) to resolve a database name into its ID. Required |
filter Filter | string | A JSON object describing the filter. Two shapes for single-condition filters: (1) Property filter — { "property": "<column-name>", "<type>": { "<operator>": <value> } }, where <type> matches the database column type (title, rich_text, number, select, status, checkbox, date, people, …) and <operator> is type-specific. Example: { "property": "Status", "select": { "equals": "Escaped" } }. Filtering by title needs { "property": "<title-column-name>", "title": { "contains": "..." } } — call Retrieve Database Schema first if you don't already know the title column's exact name. (2) Timestamp filter — uses a top-level timestamp key (NOT property) set to "created_time" or "last_edited_time", plus a matching operator object. Example: { "timestamp": "created_time", "created_time": { "past_week": {} } }. Compound filters use { "and": [ ... ] } or { "or": [ ... ] }. Omit this prop to return all rows. See the documentation. Optional |
sorts Sorts | string | Sort order as a JSON array string. Example: [ { "property": "Name", "direction": "ascending" } ]. See the documentation. Optional |
pageSize Page Size | integer | The number of items from the full list desired in the response (max 100) Optional |
startCursor Start Cursor (page_id) | string | Pagination cursor from a previous response's next_cursor. Omit for the first page. Optional |
REFERENCE
Tool details
Behavior hints are published with the component in the Pipedream registry and surface as MCP tool annotations, so an agent can reason about a tool before it calls it.
- Registry key
- notion-query-database
- Version
- 1.1.1
- App
- Notion
- Authentication
- OAuth
- Read-only
- Yes
- Destructive
- No
- Open world
- Yes
- Source
- View on GitHub ↗